his_api_controller.go 455KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394
  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. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. 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 +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. 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 +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&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)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. 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 +
  1082. "&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
  1083. fmt.Println(api)
  1084. } else {
  1085. 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 +
  1086. "&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)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. 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)
  1273. saveLog(result, requestLog, "1101", "获取人员信息")
  1274. fmt.Println(errMsgLog)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. res.ErrMsg = errMsgLog
  1289. if res.Infcode == 0 {
  1290. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1291. if err == gorm.ErrRecordNotFound {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1293. return
  1294. } else if err != nil {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1296. return
  1297. } else {
  1298. fmt.Println(res)
  1299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1301. infoStr := string(Iinfos)
  1302. idetinfoStr := string(Idetinfos)
  1303. psn := &models.HisPsn{
  1304. PsnNo: res.Output.Baseinfo.PsnNo,
  1305. Age: res.Output.Baseinfo.Age,
  1306. PatientId: patient.ID,
  1307. Certno: res.Output.Baseinfo.Certno,
  1308. Brdy: res.Output.Baseinfo.Brdy,
  1309. Gend: res.Output.Baseinfo.Gend,
  1310. Naty: res.Output.Baseinfo.Naty,
  1311. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1312. PsnName: res.Output.Baseinfo.PsnName,
  1313. Idetinfo: idetinfoStr,
  1314. Insuinfo: infoStr,
  1315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1316. CardInfo: basStr,
  1317. VerifyNumber: "",
  1318. }
  1319. service.CreateHisPsn(psn)
  1320. c.ServeSuccessJSON(map[string]interface{}{
  1321. "patient": patient,
  1322. "number": cardnum,
  1323. })
  1324. }
  1325. } else {
  1326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1327. return
  1328. }
  1329. } else {
  1330. if initFlag == 0 {
  1331. c.TestGetBasBaseInit()
  1332. }
  1333. basStr := c.GetBasBaseInfo()
  1334. if len(basStr) == 0 {
  1335. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1336. return
  1337. }
  1338. fmt.Println(basStr)
  1339. bas := strings.Split(basStr, "|")
  1340. basNumber := bas[1]
  1341. fmt.Println(basNumber)
  1342. card_sn := bas[3]
  1343. fmt.Println(card_sn)
  1344. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1345. var dat map[string]interface{}
  1346. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1347. fmt.Println(dat)
  1348. } else {
  1349. fmt.Println(err)
  1350. }
  1351. userJSONBytes, _ := json.Marshal(dat)
  1352. var res ResultTwo
  1353. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1354. utils.ErrorLog("解析失败:%v", err)
  1355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1356. return
  1357. }
  1358. if res.Infcode == 0 {
  1359. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1360. if err == gorm.ErrRecordNotFound {
  1361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1362. return
  1363. } else if err != nil {
  1364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1365. return
  1366. } else {
  1367. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1368. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1369. infoStr := string(Iinfos)
  1370. idetinfoStr := string(Idetinfos)
  1371. psn := &models.HisPsn{
  1372. PsnNo: res.Output.Baseinfo.PsnNo,
  1373. Age: res.Output.Baseinfo.Age,
  1374. PatientId: patient.ID,
  1375. Certno: res.Output.Baseinfo.Certno,
  1376. Brdy: res.Output.Baseinfo.Brdy,
  1377. Gend: res.Output.Baseinfo.Gend,
  1378. Naty: res.Output.Baseinfo.Naty,
  1379. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1380. PsnName: res.Output.Baseinfo.PsnName,
  1381. Idetinfo: idetinfoStr,
  1382. Insuinfo: infoStr,
  1383. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1384. CardInfo: basStr,
  1385. VerifyNumber: "",
  1386. }
  1387. service.CreateHisPsn(psn)
  1388. c.ServeSuccessJSON(map[string]interface{}{
  1389. "patient": patient,
  1390. "number": basNumber,
  1391. })
  1392. }
  1393. } else {
  1394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1395. return
  1396. }
  1397. break
  1398. }
  1399. case 2:
  1400. SFZStr := c.GetSFZBaseInfo()
  1401. id_card_str := strings.Split(SFZStr, "^")
  1402. id_card_number := id_card_str[0]
  1403. card_sn := ""
  1404. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1405. var dat map[string]interface{}
  1406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1407. fmt.Println(dat)
  1408. } else {
  1409. fmt.Println(err)
  1410. }
  1411. userJSONBytes, _ := json.Marshal(dat)
  1412. var res ResultTwo
  1413. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1414. utils.ErrorLog("解析失败:%v", err)
  1415. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1416. return
  1417. }
  1418. if res.Infcode == 0 {
  1419. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1420. if err == gorm.ErrRecordNotFound {
  1421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1422. return
  1423. } else if err != nil {
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1425. return
  1426. } else {
  1427. c.ServeSuccessJSON(map[string]interface{}{
  1428. "patient": patient,
  1429. "number": id_card_number,
  1430. })
  1431. }
  1432. } else {
  1433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1434. return
  1435. }
  1436. break
  1437. case 3:
  1438. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1439. var api string
  1440. if miConfig.MdtrtareaAdmvs == "320921" {
  1441. 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 +
  1442. "&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
  1443. fmt.Println(api)
  1444. } else {
  1445. 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 +
  1446. "&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)
  1447. }
  1448. resp, requestErr := http.Get(api)
  1449. if requestErr != nil {
  1450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1451. return
  1452. }
  1453. body, ioErr := ioutil.ReadAll(resp.Body)
  1454. if ioErr != nil {
  1455. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1457. return
  1458. }
  1459. var respJSON map[string]interface{}
  1460. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1461. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1462. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1463. return
  1464. }
  1465. var status string
  1466. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1467. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1468. var token string
  1469. var res ResultTwo //1101结果
  1470. var res10265 ResultTwo10265 //1101结果
  1471. var card_info string //卡信息
  1472. var busi_card_info string
  1473. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1474. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1475. if status == "0" { //读卡成功
  1476. if card_type == "1" {
  1477. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1478. result, _ := json.Marshal(respJSON)
  1479. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1480. utils.ErrorLog("解析失败:%v", err)
  1481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1482. return
  1483. }
  1484. res.ErrMsg = res10265.ErrMsg
  1485. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1486. res.Infcode = infocode
  1487. res.Output = res10265.Output
  1488. res.InfRefmsgid = res10265.InfRefmsgid
  1489. } else {
  1490. //var card_info string //卡信息
  1491. //var busi_card_info string
  1492. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1493. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1494. //fmt.Println(card_info)
  1495. //fmt.Println(busi_card_info)
  1496. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1497. result, _ := json.Marshal(respJSON)
  1498. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1499. utils.ErrorLog("解析失败:%v", err)
  1500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1501. return
  1502. }
  1503. res.ErrMsg = res10265.ErrMsg
  1504. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1505. res.Infcode = infocode
  1506. res.Output = res10265.Output
  1507. res.InfRefmsgid = res10265.InfRefmsgid
  1508. }
  1509. if res.Infcode == 0 {
  1510. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1511. if err == gorm.ErrRecordNotFound {
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1513. return
  1514. } else if err != nil {
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1516. return
  1517. } else {
  1518. if card_type == "1" {
  1519. bas := strings.Split(card_info, "|")
  1520. basNumber := bas[2]
  1521. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1522. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1523. infoStr := string(Iinfos)
  1524. idetinfoStr := string(Idetinfos)
  1525. psn := &models.HisPsn{
  1526. PsnNo: res.Output.Baseinfo.PsnNo,
  1527. Age: res.Output.Baseinfo.Age,
  1528. PatientId: patient.ID,
  1529. Certno: res.Output.Baseinfo.Certno,
  1530. Brdy: res.Output.Baseinfo.Brdy,
  1531. Gend: res.Output.Baseinfo.Gend,
  1532. Naty: res.Output.Baseinfo.Naty,
  1533. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1534. PsnName: res.Output.Baseinfo.PsnName,
  1535. Idetinfo: idetinfoStr,
  1536. Insuinfo: infoStr,
  1537. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1538. CardInfo: card_info,
  1539. VerifyNumber: busi_card_info,
  1540. }
  1541. service.CreateHisPsn(psn)
  1542. c.ServeSuccessJSON(map[string]interface{}{
  1543. "patient": patient,
  1544. "number": basNumber,
  1545. })
  1546. } else {
  1547. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1548. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1549. infoStr := string(Iinfos)
  1550. idetinfoStr := string(Idetinfos)
  1551. psn := &models.HisPsn{
  1552. PsnNo: res.Output.Baseinfo.PsnNo,
  1553. Age: res.Output.Baseinfo.Age,
  1554. PatientId: patient.ID,
  1555. Certno: res.Output.Baseinfo.Certno,
  1556. Brdy: res.Output.Baseinfo.Brdy,
  1557. Gend: res.Output.Baseinfo.Gend,
  1558. Naty: res.Output.Baseinfo.Naty,
  1559. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1560. PsnName: res.Output.Baseinfo.PsnName,
  1561. Idetinfo: idetinfoStr,
  1562. Insuinfo: infoStr,
  1563. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1564. CardInfo: card_info,
  1565. VerifyNumber: token,
  1566. }
  1567. service.CreateHisPsn(psn)
  1568. var rf []*ResultFive
  1569. json.Unmarshal([]byte(infoStr), &rf)
  1570. var insutypes []*ResultFive
  1571. var insutype string
  1572. var is390 int = 0
  1573. var is310 int = 0
  1574. for _, item := range rf {
  1575. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1576. insutypes = append(insutypes, item)
  1577. }
  1578. }
  1579. if len(insutypes) == 1 {
  1580. insutype = insutypes[0].Insutype
  1581. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1582. } else {
  1583. for _, i := range insutypes {
  1584. if i.Insutype == "390" {
  1585. is390 = 1
  1586. }
  1587. if i.Insutype == "310" {
  1588. is310 = 1
  1589. }
  1590. }
  1591. }
  1592. if is390 == 1 {
  1593. insutype = "390"
  1594. }
  1595. if is310 == 1 {
  1596. insutype = "310"
  1597. }
  1598. if len(insutypes) == 0 {
  1599. insutype = "310"
  1600. }
  1601. c.ServeSuccessJSON(map[string]interface{}{
  1602. "patient": patient,
  1603. "number": token,
  1604. "insutype": insutype,
  1605. })
  1606. }
  1607. }
  1608. } else {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1610. return
  1611. }
  1612. } else { //读卡失败
  1613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1614. return
  1615. }
  1616. }
  1617. break
  1618. case 4:
  1619. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1620. var api string
  1621. if miConfig.MdtrtareaAdmvs == "320921" {
  1622. 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 +
  1623. "&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
  1624. fmt.Println(api)
  1625. } else {
  1626. 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 +
  1627. "&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)
  1628. }
  1629. resp, requestErr := http.Get(api)
  1630. if requestErr != nil {
  1631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1632. return
  1633. }
  1634. body, ioErr := ioutil.ReadAll(resp.Body)
  1635. if ioErr != nil {
  1636. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1638. return
  1639. }
  1640. var respJSON map[string]interface{}
  1641. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1642. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1644. return
  1645. }
  1646. var status string
  1647. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1648. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1649. var token string
  1650. var res ResultTwo //1101结果
  1651. var res10265 ResultTwo10265 //1101结果
  1652. if status == "0" { //读卡成功
  1653. var card_info string //卡信息
  1654. var busi_card_info string
  1655. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1656. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1657. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1658. fmt.Println(card_info)
  1659. fmt.Println(busi_card_info)
  1660. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1661. result, _ := json.Marshal(respJSON)
  1662. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1663. utils.ErrorLog("解析失败:%v", err)
  1664. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1665. return
  1666. }
  1667. res.ErrMsg = res10265.ErrMsg
  1668. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1669. res.Infcode = infocode
  1670. res.Output = res10265.Output
  1671. res.InfRefmsgid = res10265.InfRefmsgid
  1672. if res.Infcode == 0 {
  1673. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1674. if err == gorm.ErrRecordNotFound {
  1675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1676. return
  1677. } else if err != nil {
  1678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1679. return
  1680. } else {
  1681. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1682. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1683. infoStr := string(Iinfos)
  1684. idetinfoStr := string(Idetinfos)
  1685. psn := &models.HisPsn{
  1686. PsnNo: res.Output.Baseinfo.PsnNo,
  1687. Age: res.Output.Baseinfo.Age,
  1688. PatientId: patient.ID,
  1689. Certno: res.Output.Baseinfo.Certno,
  1690. Brdy: res.Output.Baseinfo.Brdy,
  1691. Gend: res.Output.Baseinfo.Gend,
  1692. Naty: res.Output.Baseinfo.Naty,
  1693. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1694. PsnName: res.Output.Baseinfo.PsnName,
  1695. Idetinfo: idetinfoStr,
  1696. Insuinfo: infoStr,
  1697. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1698. CardInfo: card_info,
  1699. VerifyNumber: token,
  1700. }
  1701. service.CreateHisPsn(psn)
  1702. c.ServeSuccessJSON(map[string]interface{}{
  1703. "patient": patient,
  1704. "number": token,
  1705. })
  1706. }
  1707. } else {
  1708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1709. return
  1710. }
  1711. } else { //读卡失败
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1713. return
  1714. }
  1715. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1716. }
  1717. break
  1718. }
  1719. }
  1720. var initFlag int64 = 0
  1721. func (c *HisApiController) TestGetBasBaseInit() {
  1722. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1723. Iinit := DllDef.MustFindProc("Init")
  1724. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1725. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1726. if ret != 0 {
  1727. fmt.Println("SSCard的报错原因:", err)
  1728. fmt.Println("SSCard的运算结果为:", ret)
  1729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1730. return
  1731. }
  1732. result := int(ret)
  1733. fmt.Println("SSCard的运算结果为1:", result)
  1734. initFlag = 1
  1735. return
  1736. }
  1737. func (c *HisApiController) GetSFZBaseInfo() string {
  1738. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1739. readCard := DllDef.MustFindProc("ReadSFZ")
  1740. if readCard == nil {
  1741. fmt.Println("readcard is nil")
  1742. readCard = DllDef.MustFindProc("ReadSFZ")
  1743. }
  1744. str := make([]byte, 256)
  1745. str1 := make([]byte, 256)
  1746. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1747. fmt.Println(r)
  1748. return string(str)
  1749. }
  1750. func (c *HisApiController) GetBasBaseInfo() string {
  1751. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1752. readCard := DllDef.MustFindProc("ReadCardBas")
  1753. if readCard == nil {
  1754. fmt.Println("readcard is nil")
  1755. readCard = DllDef.MustFindProc("ReadCardBas")
  1756. }
  1757. str := make([]byte, 1024)
  1758. str1 := make([]byte, 1024)
  1759. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1760. fmt.Println(string(str1))
  1761. fmt.Println(string(str))
  1762. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1763. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1764. if ret2 != 0 {
  1765. return ""
  1766. }
  1767. return string(str)
  1768. }
  1769. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1770. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1771. readCard := DllDef.MustFindProc("read_cardinfo")
  1772. if readCard == nil {
  1773. fmt.Println("readcard is nil")
  1774. readCard = DllDef.MustFindProc("read_cardinfo")
  1775. }
  1776. str := make([]byte, 1024) //卡号
  1777. str1 := make([]byte, 1024) //卡识别码
  1778. str2 := make([]byte, 1024) //身份证号
  1779. str3 := make([]byte, 1024) //姓名
  1780. str4 := make([]byte, 1024) //错误信息
  1781. 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])))
  1782. fmt.Println(string(str1))
  1783. fmt.Println(string(str))
  1784. fmt.Println(string(str2))
  1785. fmt.Println(string(str3))
  1786. fmt.Println(string(str4))
  1787. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1788. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1789. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1790. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1791. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1792. if ret2 != 0 {
  1793. return "", "", "", "", ""
  1794. }
  1795. return string(str), string(str1), string(str2), string(str3), string(str4)
  1796. }
  1797. type CustomFundPay struct {
  1798. FundPayType string `json:"fund_pay_type"`
  1799. FundPayamt float64 `json:"fund_payamt"`
  1800. }
  1801. func (c *HisApiController) GetSettleList() {
  1802. order_id, _ := c.GetInt64("order_id")
  1803. admin_user_id, _ := c.GetInt64("admin_user_id")
  1804. order, _ := service.GetHisOrderByIDTwo(order_id)
  1805. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1806. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1807. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1808. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1809. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1810. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1811. if order.ID == 0 {
  1812. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1813. return
  1814. }
  1815. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1816. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1817. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1818. fmt.Println(count)
  1819. var zero string
  1820. number := count + 1
  1821. if number >= 1000 {
  1822. zero = "0000" + strconv.FormatInt(number, 10)
  1823. } else if number >= 10000 {
  1824. zero = "000" + strconv.FormatInt(number, 10)
  1825. } else if number >= 100000 {
  1826. zero = "00" + strconv.FormatInt(number, 10)
  1827. } else if number >= 1000000 {
  1828. zero = "0" + strconv.FormatInt(number, 10)
  1829. } else {
  1830. zero = strconv.FormatInt(number, 10)
  1831. }
  1832. fmt.Println(zero)
  1833. struct4101 := service.Struct4101{
  1834. PsnNo: order.PsnNo,
  1835. MdtrtId: order.MdtrtId,
  1836. SetlId: order.SetlId,
  1837. PsnName: order.PsnName,
  1838. Gend: order.Gend,
  1839. Brdy: his.Brdy,
  1840. Age: his.Age,
  1841. Naty: order.Naty,
  1842. PatnCertType: "01",
  1843. Certno: order.Certno,
  1844. Prfs: "90",
  1845. ConerName: roles[0].UserName,
  1846. PatnRlts: "99",
  1847. ConerAddr: miConfig.OrgName,
  1848. ConerTel: admin.Mobile,
  1849. HiType: order.Insutype,
  1850. Insuplc: miConfig.InsuplcAdmdvs,
  1851. MaindiagFlag: "1",
  1852. BillCode: last_order.FaPiaoCode,
  1853. BillNo: zero,
  1854. BizSn: order.Number,
  1855. PsnSelfPay: order.PsnPartAmt,
  1856. PsnOwnPay: order.PsnPartAmt,
  1857. AcctPay: order.AcctPay,
  1858. PsnCashpay: order.PsnCashPay,
  1859. HiPaymtd: "1",
  1860. Hsorg: miConfig.InsuplcAdmdvs,
  1861. HsorgOpter: miConfig.InsuplcAdmdvs,
  1862. MedinsFillPsn: curRoles.UserName,
  1863. MedinsFillDept: depart.Name,
  1864. IptMedType: "2",
  1865. }
  1866. struct4101.SetlBegnDate = order.SetlTime
  1867. struct4101.SetlEndDate = order.SetlTime
  1868. time_arr := strings.Split(order.SetlTime, " ")
  1869. struct4101.AdmTime = time_arr[0]
  1870. struct4101.AdmEndTime = time_arr[0]
  1871. var rf []CustomFundPay
  1872. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1873. var tempFunPays []service.CustomStruct
  1874. for _, item := range rf {
  1875. var tempFunPay service.CustomStruct
  1876. tempFunPay.FundPayamt = item.FundPayamt
  1877. tempFunPay.FundPayType = item.FundPayType
  1878. tempFunPays = append(tempFunPays, tempFunPay)
  1879. }
  1880. struct4101.CustomStruct = tempFunPays
  1881. var tempDiaginfos []service.DiaginfoStructTwo
  1882. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1883. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1884. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1885. var config []*models.HisXtDiagnoseConfig
  1886. for _, item := range diagnosis_ids {
  1887. id, _ := strconv.ParseInt(item, 10, 64)
  1888. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1889. config = append(config, &diagnosisConfig)
  1890. }
  1891. for index, item := range config {
  1892. if index == 0 {
  1893. var tempDiaginfo service.DiaginfoStructTwo
  1894. tempDiaginfo.DiagCode = item.CountryCode
  1895. tempDiaginfo.DiagName = item.CountryContentName
  1896. tempDiaginfo.DiagType = "1"
  1897. tempDiaginfo.MaindiagFlag = "1"
  1898. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1899. } else {
  1900. var tempDiaginfo service.DiaginfoStructTwo
  1901. tempDiaginfo.DiagCode = item.CountryCode
  1902. tempDiaginfo.DiagName = item.CountryContentName
  1903. tempDiaginfo.DiagType = "2"
  1904. tempDiaginfo.MaindiagFlag = "0"
  1905. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1906. }
  1907. }
  1908. struct4101.Diseinfo = tempDiaginfos
  1909. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1910. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1911. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1912. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1913. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1914. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1915. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1916. var iteminfo service.IteminfoStruct
  1917. var bedCostTotal float64 = 0 //床位总费
  1918. var bedCostSelfTotal float64 = 0 //床位自费
  1919. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1920. var operationCostTotal float64 = 0 //手术费
  1921. var operationCostSelfTotal float64 = 0 //手术费
  1922. var operationCostPartSelfTotal float64 = 0 //手术费
  1923. var otherCostTotal float64 = 0 //其他费用
  1924. var otherCostSelfTotal float64 = 0 //其他费用
  1925. var otherCostPartSelfTotal float64 = 0 //其他费用
  1926. var materialCostTotal float64 = 0 //材料费
  1927. var materialCostSelfTotal float64 = 0 //材料费
  1928. var materialCostPartSelfTotal float64 = 0 //材料费
  1929. var westernMedicineCostTotal float64 = 0 //西药费
  1930. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1931. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1932. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1933. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1934. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1935. var checkCostTotal float64 = 0 //检查费
  1936. var checkCostSelfTotal float64 = 0 //检查费
  1937. var checkCostPartSelfTotal float64 = 0 //检查费
  1938. var laboratoryCostTotal float64 = 0 //化验费
  1939. var laboratoryCostSelfTotal float64 = 0 //化验费
  1940. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1941. var treatCostTotal float64 = 0 //治疗费用
  1942. var treatCostSelfTotal float64 = 0 //治疗费用
  1943. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1944. decimal.DivisionPrecision = 2
  1945. var bed_fulamt_ownpay_amt float64 = 0
  1946. var operation_fulamt_ownpay_amt float64 = 0
  1947. var other_fulamt_ownpay_amt float64 = 0
  1948. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1949. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1950. var check_fulamt_ownpay_amt float64 = 0
  1951. var material_fulamt_ownpay_amt float64 = 0
  1952. var laboratory_fulamt_ownpay_amt float64 = 0
  1953. var treat_fulamt_ownpay_amt float64 = 0
  1954. var bed_claa_sunmfee float64 = 0
  1955. var bed_clab_amt float64 = 0
  1956. var bed_other_amt float64 = 0
  1957. var operation_claa_sunmfee float64 = 0
  1958. var operation_clab_amt float64 = 0
  1959. var operation_other_amt float64 = 0
  1960. var other_claa_sunmfee float64 = 0
  1961. var other_clab_amt float64 = 0
  1962. var other_other_amt float64 = 0
  1963. var westernMedicine_claa_sunmfee float64 = 0
  1964. var westernMedicine_clab_amt float64 = 0
  1965. var westernMedicine_other_amt float64 = 0
  1966. var chineseTraditional_claa_sunmfee float64 = 0
  1967. var chineseTraditional_clab_amt float64 = 0
  1968. var chineseTraditional_other_amt float64 = 0
  1969. var check_claa_sunmfee float64 = 0
  1970. var check_clab_amt float64 = 0
  1971. var check_other_amt float64 = 0
  1972. var material_claa_sunmfee float64 = 0
  1973. var material_clab_amt float64 = 0
  1974. var material_other_amt float64 = 0
  1975. var laboratory_claa_sunmfee float64 = 0
  1976. var laboratory_clab_amt float64 = 0
  1977. var laboratory_other_amt float64 = 0
  1978. var treat_claa_sunmfee float64 = 0
  1979. var treat_clab_amt float64 = 0
  1980. var treat_other_amt float64 = 0
  1981. for _, item := range order.HisOrderInfo {
  1982. if item.MedChrgitmType == "01" { //床位费
  1983. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "03" { //检查费
  1998. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. if item.MedChrgitmType == "04" { //化验费
  2013. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2014. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2015. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2016. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2017. if item.ChrgitmLv == "1" {
  2018. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2019. }
  2020. if item.ChrgitmLv == "2" {
  2021. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. }
  2023. if item.ChrgitmLv == "3" {
  2024. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2025. }
  2026. }
  2027. if item.MedChrgitmType == "05" { //治疗费
  2028. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2029. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2030. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2031. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2032. if item.ChrgitmLv == "1" {
  2033. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2034. }
  2035. if item.ChrgitmLv == "2" {
  2036. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. }
  2038. if item.ChrgitmLv == "3" {
  2039. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2040. }
  2041. }
  2042. if item.MedChrgitmType == "06" { //手术费
  2043. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2044. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2045. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2046. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2047. if item.ChrgitmLv == "1" {
  2048. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2049. }
  2050. if item.ChrgitmLv == "2" {
  2051. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. }
  2053. if item.ChrgitmLv == "3" {
  2054. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2055. }
  2056. }
  2057. if item.MedChrgitmType == "08" { //材料费
  2058. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2059. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2060. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2061. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2062. if item.ChrgitmLv == "1" {
  2063. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2064. }
  2065. if item.ChrgitmLv == "2" {
  2066. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. }
  2068. if item.ChrgitmLv == "3" {
  2069. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2070. }
  2071. }
  2072. if item.MedChrgitmType == "09" { //西药费
  2073. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2074. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2075. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2076. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2077. if item.ChrgitmLv == "1" {
  2078. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2079. }
  2080. if item.ChrgitmLv == "2" {
  2081. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. }
  2083. if item.ChrgitmLv == "3" {
  2084. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2085. }
  2086. }
  2087. if item.MedChrgitmType == "11" { //中成费
  2088. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2089. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2090. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2091. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2092. if item.ChrgitmLv == "1" {
  2093. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2094. }
  2095. if item.ChrgitmLv == "2" {
  2096. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. }
  2098. if item.ChrgitmLv == "3" {
  2099. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2100. }
  2101. }
  2102. if item.MedChrgitmType == "14" { //其他费
  2103. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2104. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2105. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2106. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2107. if item.ChrgitmLv == "1" {
  2108. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2109. }
  2110. if item.ChrgitmLv == "2" {
  2111. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2112. }
  2113. if item.ChrgitmLv == "3" {
  2114. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2115. }
  2116. }
  2117. }
  2118. var iteminfoStructs []service.IteminfoStruct
  2119. if bedCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "01"
  2121. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2122. iteminfo.Amt = bedCostTotal
  2123. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2124. iteminfo.ClabAmt = bed_clab_amt
  2125. iteminfo.OthAmt = bed_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if checkCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "03"
  2130. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2131. iteminfo.Amt = checkCostTotal
  2132. iteminfo.ClaaSumfee = check_claa_sunmfee
  2133. iteminfo.ClabAmt = check_clab_amt
  2134. iteminfo.OthAmt = check_other_amt
  2135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2136. }
  2137. if laboratoryCostTotal != 0 {
  2138. iteminfo.MedChrgitm = "04"
  2139. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2140. iteminfo.Amt = laboratoryCostTotal
  2141. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2142. iteminfo.ClabAmt = laboratory_clab_amt
  2143. iteminfo.OthAmt = laboratory_other_amt
  2144. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2145. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2146. }
  2147. if treatCostTotal != 0 {
  2148. iteminfo.MedChrgitm = "05"
  2149. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2150. iteminfo.Amt = treatCostTotal
  2151. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2152. iteminfo.ClabAmt = treat_clab_amt
  2153. iteminfo.OthAmt = treat_other_amt
  2154. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2155. //(struct4101.IteminfoStruct, iteminfo)
  2156. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2157. }
  2158. if operationCostTotal != 0 {
  2159. iteminfo.MedChrgitm = "06"
  2160. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2161. iteminfo.Amt = operationCostTotal
  2162. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2163. iteminfo.ClabAmt = operation_clab_amt
  2164. iteminfo.OthAmt = operation_other_amt
  2165. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2166. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2167. }
  2168. if materialCostTotal != 0 {
  2169. iteminfo.MedChrgitm = "08"
  2170. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2171. iteminfo.Amt = materialCostTotal
  2172. iteminfo.ClaaSumfee = material_claa_sunmfee
  2173. iteminfo.ClabAmt = material_clab_amt
  2174. iteminfo.OthAmt = material_other_amt
  2175. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2176. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2177. }
  2178. if westernMedicineCostTotal != 0 {
  2179. iteminfo.MedChrgitm = "09"
  2180. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2181. iteminfo.Amt = westernMedicineCostTotal
  2182. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2183. iteminfo.ClabAmt = westernMedicine_clab_amt
  2184. iteminfo.OthAmt = westernMedicine_other_amt
  2185. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2186. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2187. }
  2188. if chineseTraditionalMedicineCostTotal != 0 {
  2189. iteminfo.MedChrgitm = "11"
  2190. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2191. iteminfo.Amt = westernMedicineCostTotal
  2192. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2193. iteminfo.ClabAmt = westernMedicine_clab_amt
  2194. iteminfo.OthAmt = westernMedicine_other_amt
  2195. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2196. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2197. }
  2198. if otherCostTotal != 0 {
  2199. iteminfo.MedChrgitm = "14"
  2200. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2201. iteminfo.Amt = otherCostTotal
  2202. iteminfo.ClaaSumfee = other_claa_sunmfee
  2203. iteminfo.ClabAmt = other_clab_amt
  2204. iteminfo.OthAmt = other_other_amt
  2205. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2206. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2207. }
  2208. struct4101.IteminfoStruct = iteminfoStructs
  2209. struct4101.Ntly = "中国"
  2210. struct4101.AdmCaty = "A03.06"
  2211. var res ResultSeventeen
  2212. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2213. var resOther ResultSeventeenOther
  2214. var pp models.PublicParams
  2215. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2216. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2217. pp.FixmedinsName = miConfig.OrgName
  2218. pp.FixmedinsCode = miConfig.Code
  2219. pp.RequestUrl = miConfig.Url
  2220. pp.Cainfo = miConfig.Cainfo
  2221. pp.SecretKey = miConfig.SecretKey
  2222. pp.AccessKey = miConfig.AccessKey
  2223. pp.OpterName = curRoles.UserName
  2224. client := &http.Client{}
  2225. var req *http.Request
  2226. data := make(map[string]interface{})
  2227. data["struct4101"] = struct4101
  2228. data["pp"] = pp
  2229. bytesData, _ := json.Marshal(data)
  2230. if miConfig.MdtrtareaAdmvs == "320921" {
  2231. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2232. } else {
  2233. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2234. }
  2235. resp, _ := client.Do(req)
  2236. defer resp.Body.Close()
  2237. body, ioErr := ioutil.ReadAll(resp.Body)
  2238. if ioErr != nil {
  2239. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2241. return
  2242. }
  2243. var respJSON map[string]interface{}
  2244. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2245. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2250. userJSONBytes, _ := json.Marshal(respJSON)
  2251. fmt.Println("log")
  2252. fmt.Println(string(userJSONBytes))
  2253. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2254. utils.ErrorLog("解析失败:%v", err)
  2255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2256. return
  2257. }
  2258. res.InfRefmsgid = resOther.InfRefmsgid
  2259. res.Output = resOther.Output
  2260. res.ErrMsg = resOther.ErrMsg
  2261. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2262. res.Infcode = infocode
  2263. } else {
  2264. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2265. var dat map[string]interface{}
  2266. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2267. fmt.Println(dat)
  2268. } else {
  2269. fmt.Println(err)
  2270. }
  2271. userJSONBytes, _ := json.Marshal(dat)
  2272. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2273. utils.ErrorLog("解析失败:%v", err)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. }
  2278. if res.Infcode != 0 {
  2279. c.ServeSuccessJSON(map[string]interface{}{
  2280. "failed_code": -10,
  2281. "msg": res.ErrMsg,
  2282. })
  2283. return
  2284. } else {
  2285. order.FaPiaoNumber = zero
  2286. order.FaPiaoCode = last_order.FaPiaoCode
  2287. service.UpdateOrder(order)
  2288. hisFundSettleListResult := &models.HisFundSettleListResult{
  2289. Number: res.Output.SetlListId,
  2290. Status: 1,
  2291. Ctime: time.Now().Unix(),
  2292. Mtime: time.Now().Unix(),
  2293. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2294. IsUpload: 1,
  2295. OrderId: order_id,
  2296. }
  2297. service.CreateUploadRecord(hisFundSettleListResult)
  2298. c.ServeSuccessJSON(map[string]interface{}{
  2299. "msg": "上传成功",
  2300. "result": hisFundSettleListResult,
  2301. })
  2302. return
  2303. }
  2304. }
  2305. func (c *HisApiController) GetSettleListHospital() {
  2306. order_id, _ := c.GetInt64("order_id")
  2307. admin_user_id, _ := c.GetInt64("admin_user_id")
  2308. order, _ := service.GetHisOrderByIDTwo(order_id)
  2309. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2310. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2311. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2312. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2313. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2314. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2315. if order.ID == 0 {
  2316. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2317. return
  2318. }
  2319. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2320. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2321. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2322. fmt.Println(count)
  2323. var zero string
  2324. number := count + 1
  2325. if number >= 1000 {
  2326. zero = "0000" + strconv.FormatInt(number, 10)
  2327. } else if number >= 10000 {
  2328. zero = "000" + strconv.FormatInt(number, 10)
  2329. } else if number >= 100000 {
  2330. zero = "00" + strconv.FormatInt(number, 10)
  2331. } else if number >= 1000000 {
  2332. zero = "0" + strconv.FormatInt(number, 10)
  2333. } else {
  2334. zero = strconv.FormatInt(number, 10)
  2335. }
  2336. fmt.Println(zero)
  2337. struct4101 := service.Struct4101{
  2338. PsnNo: order.PsnNo,
  2339. MdtrtId: order.MdtrtId,
  2340. SetlId: order.SetlId,
  2341. PsnName: order.PsnName,
  2342. Gend: order.Gend,
  2343. Brdy: his.Brdy,
  2344. Age: int64(order.Age),
  2345. Naty: order.Naty,
  2346. PatnCertType: "01",
  2347. Certno: order.Certno,
  2348. Prfs: "90",
  2349. ConerName: roles[0].UserName,
  2350. PatnRlts: "99",
  2351. ConerAddr: miConfig.OrgName,
  2352. ConerTel: admin.Mobile,
  2353. HiType: order.Insutype,
  2354. Insuplc: miConfig.InsuplcAdmdvs,
  2355. MaindiagFlag: "1",
  2356. BillCode: last_order.FaPiaoCode,
  2357. BillNo: zero,
  2358. BizSn: order.Number,
  2359. PsnSelfPay: order.PsnPartAmt,
  2360. PsnOwnPay: order.PsnPartAmt,
  2361. AcctPay: order.AcctPay,
  2362. PsnCashpay: order.PsnCashPay,
  2363. HiPaymtd: "1",
  2364. Hsorg: miConfig.InsuplcAdmdvs,
  2365. HsorgOpter: miConfig.InsuplcAdmdvs,
  2366. MedinsFillPsn: curRoles.UserName,
  2367. MedinsFillDept: depart.Name,
  2368. IptMedType: "2",
  2369. AdmTime: his.InHosptialTime,
  2370. AdmEndTime: his.OutHosptialTime,
  2371. }
  2372. struct4101.SetlBegnDate = order.SetlTime
  2373. struct4101.SetlEndDate = order.SetlTime
  2374. var rf []CustomFundPay
  2375. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2376. var tempFunPays []service.CustomStruct
  2377. for _, item := range rf {
  2378. var tempFunPay service.CustomStruct
  2379. tempFunPay.FundPayamt = item.FundPayamt
  2380. tempFunPay.FundPayType = item.FundPayType
  2381. tempFunPays = append(tempFunPays, tempFunPay)
  2382. }
  2383. struct4101.CustomStruct = tempFunPays
  2384. var tempDiaginfos []service.DiaginfoStructTwo
  2385. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2386. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2387. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2388. var config []*models.HisXtDiagnoseConfig
  2389. for _, item := range diagnosis_ids {
  2390. id, _ := strconv.ParseInt(item, 10, 64)
  2391. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2392. config = append(config, &diagnosisConfig)
  2393. }
  2394. for index, item := range config {
  2395. if index == 0 {
  2396. var tempDiaginfo service.DiaginfoStructTwo
  2397. tempDiaginfo.DiagCode = item.CountryCode
  2398. tempDiaginfo.DiagName = item.CountryContentName
  2399. tempDiaginfo.DiagType = "1"
  2400. tempDiaginfo.MaindiagFlag = "1"
  2401. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2402. } else {
  2403. var tempDiaginfo service.DiaginfoStructTwo
  2404. tempDiaginfo.DiagCode = item.CountryCode
  2405. tempDiaginfo.DiagName = item.CountryContentName
  2406. tempDiaginfo.DiagType = "2"
  2407. tempDiaginfo.MaindiagFlag = "0"
  2408. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2409. }
  2410. }
  2411. struct4101.Diseinfo = tempDiaginfos
  2412. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2413. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2414. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2415. tempOpspdiseinfo2.OprnOprtCode = ""
  2416. tempOpspdiseinfo2.OprnOprtName = ""
  2417. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2418. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2419. var iteminfo service.IteminfoStruct
  2420. var bedCostTotal float64 = 0 //床位总费
  2421. var bedCostSelfTotal float64 = 0 //床位自费
  2422. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2423. var operationCostTotal float64 = 0 //手术费
  2424. var operationCostSelfTotal float64 = 0 //手术费
  2425. var operationCostPartSelfTotal float64 = 0 //手术费
  2426. var otherCostTotal float64 = 0 //其他费用
  2427. var otherCostSelfTotal float64 = 0 //其他费用
  2428. var otherCostPartSelfTotal float64 = 0 //其他费用
  2429. var materialCostTotal float64 = 0 //材料费
  2430. var materialCostSelfTotal float64 = 0 //材料费
  2431. var materialCostPartSelfTotal float64 = 0 //材料费
  2432. var westernMedicineCostTotal float64 = 0 //西药费
  2433. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2434. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2435. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2436. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2437. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2438. var checkCostTotal float64 = 0 //检查费
  2439. var checkCostSelfTotal float64 = 0 //检查费
  2440. var checkCostPartSelfTotal float64 = 0 //检查费
  2441. var laboratoryCostTotal float64 = 0 //化验费
  2442. var laboratoryCostSelfTotal float64 = 0 //化验费
  2443. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2444. var treatCostTotal float64 = 0 //治疗费用
  2445. var treatCostSelfTotal float64 = 0 //治疗费用
  2446. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2447. decimal.DivisionPrecision = 2
  2448. var bed_fulamt_ownpay_amt float64 = 0
  2449. var operation_fulamt_ownpay_amt float64 = 0
  2450. var other_fulamt_ownpay_amt float64 = 0
  2451. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2452. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2453. var check_fulamt_ownpay_amt float64 = 0
  2454. var material_fulamt_ownpay_amt float64 = 0
  2455. var laboratory_fulamt_ownpay_amt float64 = 0
  2456. var treat_fulamt_ownpay_amt float64 = 0
  2457. var bed_claa_sunmfee float64 = 0
  2458. var bed_clab_amt float64 = 0
  2459. var bed_other_amt float64 = 0
  2460. var operation_claa_sunmfee float64 = 0
  2461. var operation_clab_amt float64 = 0
  2462. var operation_other_amt float64 = 0
  2463. var other_claa_sunmfee float64 = 0
  2464. var other_clab_amt float64 = 0
  2465. var other_other_amt float64 = 0
  2466. var westernMedicine_claa_sunmfee float64 = 0
  2467. var westernMedicine_clab_amt float64 = 0
  2468. var westernMedicine_other_amt float64 = 0
  2469. var chineseTraditional_claa_sunmfee float64 = 0
  2470. var chineseTraditional_clab_amt float64 = 0
  2471. var chineseTraditional_other_amt float64 = 0
  2472. var check_claa_sunmfee float64 = 0
  2473. var check_clab_amt float64 = 0
  2474. var check_other_amt float64 = 0
  2475. var material_claa_sunmfee float64 = 0
  2476. var material_clab_amt float64 = 0
  2477. var material_other_amt float64 = 0
  2478. var laboratory_claa_sunmfee float64 = 0
  2479. var laboratory_clab_amt float64 = 0
  2480. var laboratory_other_amt float64 = 0
  2481. var treat_claa_sunmfee float64 = 0
  2482. var treat_clab_amt float64 = 0
  2483. var treat_other_amt float64 = 0
  2484. for _, item := range order.HisOrderInfo {
  2485. if item.MedChrgitmType == "01" { //床位费
  2486. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2487. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2488. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2489. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2490. if item.ChrgitmLv == "1" {
  2491. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2492. }
  2493. if item.ChrgitmLv == "2" {
  2494. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. }
  2496. if item.ChrgitmLv == "3" {
  2497. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2498. }
  2499. }
  2500. if item.MedChrgitmType == "03" { //检查费
  2501. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2502. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2503. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2504. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2505. if item.ChrgitmLv == "1" {
  2506. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2507. }
  2508. if item.ChrgitmLv == "2" {
  2509. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. }
  2511. if item.ChrgitmLv == "3" {
  2512. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2513. }
  2514. }
  2515. if item.MedChrgitmType == "04" { //化验费
  2516. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2517. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2518. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2519. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2520. if item.ChrgitmLv == "1" {
  2521. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2522. }
  2523. if item.ChrgitmLv == "2" {
  2524. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. }
  2526. if item.ChrgitmLv == "3" {
  2527. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2528. }
  2529. }
  2530. if item.MedChrgitmType == "05" { //治疗费
  2531. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2532. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2533. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2534. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2535. if item.ChrgitmLv == "1" {
  2536. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2537. }
  2538. if item.ChrgitmLv == "2" {
  2539. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2540. }
  2541. if item.ChrgitmLv == "3" {
  2542. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2543. }
  2544. }
  2545. if item.MedChrgitmType == "06" { //手术费
  2546. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2547. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2548. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2549. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2550. if item.ChrgitmLv == "1" {
  2551. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2552. }
  2553. if item.ChrgitmLv == "2" {
  2554. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2555. }
  2556. if item.ChrgitmLv == "3" {
  2557. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2558. }
  2559. }
  2560. if item.MedChrgitmType == "08" { //材料费
  2561. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2562. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2563. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2564. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2565. if item.ChrgitmLv == "1" {
  2566. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2567. }
  2568. if item.ChrgitmLv == "2" {
  2569. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2570. }
  2571. if item.ChrgitmLv == "3" {
  2572. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2573. }
  2574. }
  2575. if item.MedChrgitmType == "09" { //西药费
  2576. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2577. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2578. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2579. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2580. if item.ChrgitmLv == "1" {
  2581. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2582. }
  2583. if item.ChrgitmLv == "2" {
  2584. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2585. }
  2586. if item.ChrgitmLv == "3" {
  2587. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2588. }
  2589. }
  2590. if item.MedChrgitmType == "11" { //中成费
  2591. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2592. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2593. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2594. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2595. if item.ChrgitmLv == "1" {
  2596. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2597. }
  2598. if item.ChrgitmLv == "2" {
  2599. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. }
  2601. if item.ChrgitmLv == "3" {
  2602. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2603. }
  2604. }
  2605. if item.MedChrgitmType == "14" { //其他费
  2606. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2607. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2608. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2609. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2610. if item.ChrgitmLv == "1" {
  2611. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2612. }
  2613. if item.ChrgitmLv == "2" {
  2614. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2615. }
  2616. if item.ChrgitmLv == "3" {
  2617. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2618. }
  2619. }
  2620. }
  2621. var iteminfoStructs []service.IteminfoStruct
  2622. if bedCostTotal != 0 {
  2623. iteminfo.MedChrgitm = "01"
  2624. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2625. iteminfo.Amt = bedCostTotal
  2626. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2627. iteminfo.ClabAmt = bed_clab_amt
  2628. iteminfo.OthAmt = bed_other_amt
  2629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2630. }
  2631. if checkCostTotal != 0 {
  2632. iteminfo.MedChrgitm = "03"
  2633. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2634. iteminfo.Amt = checkCostTotal
  2635. iteminfo.ClaaSumfee = check_claa_sunmfee
  2636. iteminfo.ClabAmt = check_clab_amt
  2637. iteminfo.OthAmt = check_other_amt
  2638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2639. }
  2640. if laboratoryCostTotal != 0 {
  2641. iteminfo.MedChrgitm = "04"
  2642. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2643. iteminfo.Amt = laboratoryCostTotal
  2644. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2645. iteminfo.ClabAmt = laboratory_clab_amt
  2646. iteminfo.OthAmt = laboratory_other_amt
  2647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2648. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2649. }
  2650. if treatCostTotal != 0 {
  2651. iteminfo.MedChrgitm = "05"
  2652. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2653. iteminfo.Amt = treatCostTotal
  2654. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2655. iteminfo.ClabAmt = treat_clab_amt
  2656. iteminfo.OthAmt = treat_other_amt
  2657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2658. //(struct4101.IteminfoStruct, iteminfo)
  2659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2660. }
  2661. if operationCostTotal != 0 {
  2662. iteminfo.MedChrgitm = "06"
  2663. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2664. iteminfo.Amt = operationCostTotal
  2665. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2666. iteminfo.ClabAmt = operation_clab_amt
  2667. iteminfo.OthAmt = operation_other_amt
  2668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2670. }
  2671. if materialCostTotal != 0 {
  2672. iteminfo.MedChrgitm = "08"
  2673. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2674. iteminfo.Amt = materialCostTotal
  2675. iteminfo.ClaaSumfee = material_claa_sunmfee
  2676. iteminfo.ClabAmt = material_clab_amt
  2677. iteminfo.OthAmt = material_other_amt
  2678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2680. }
  2681. if westernMedicineCostTotal != 0 {
  2682. iteminfo.MedChrgitm = "09"
  2683. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2684. iteminfo.Amt = westernMedicineCostTotal
  2685. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2686. iteminfo.ClabAmt = westernMedicine_clab_amt
  2687. iteminfo.OthAmt = westernMedicine_other_amt
  2688. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2689. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2690. }
  2691. if chineseTraditionalMedicineCostTotal != 0 {
  2692. iteminfo.MedChrgitm = "11"
  2693. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2694. iteminfo.Amt = westernMedicineCostTotal
  2695. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2696. iteminfo.ClabAmt = westernMedicine_clab_amt
  2697. iteminfo.OthAmt = westernMedicine_other_amt
  2698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2700. }
  2701. if otherCostTotal != 0 {
  2702. iteminfo.MedChrgitm = "14"
  2703. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2704. iteminfo.Amt = otherCostTotal
  2705. iteminfo.ClaaSumfee = other_claa_sunmfee
  2706. iteminfo.ClabAmt = other_clab_amt
  2707. iteminfo.OthAmt = other_other_amt
  2708. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2709. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2710. }
  2711. struct4101.IteminfoStruct = iteminfoStructs
  2712. struct4101.Ntly = "中国"
  2713. struct4101.AdmCaty = "A03.06"
  2714. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2715. fmt.Println(result)
  2716. var dat map[string]interface{}
  2717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2718. fmt.Println(dat)
  2719. } else {
  2720. fmt.Println(err)
  2721. }
  2722. userJSONBytes, _ := json.Marshal(dat)
  2723. var res ResultSeventeen
  2724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2725. utils.ErrorLog("解析失败:%v", err)
  2726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2727. return
  2728. }
  2729. if res.Infcode != 0 {
  2730. c.ServeSuccessJSON(map[string]interface{}{
  2731. "failed_code": -10,
  2732. "msg": res.ErrMsg,
  2733. })
  2734. return
  2735. } else {
  2736. order.FaPiaoNumber = zero
  2737. order.FaPiaoCode = last_order.FaPiaoCode
  2738. service.UpdateOrder(order)
  2739. hisFundSettleListResult := &models.HisFundSettleListResult{
  2740. Number: res.Output.SetlListId,
  2741. Status: 1,
  2742. Ctime: time.Now().Unix(),
  2743. Mtime: time.Now().Unix(),
  2744. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2745. IsUpload: 1,
  2746. OrderId: order_id,
  2747. }
  2748. service.CreateUploadRecord(hisFundSettleListResult)
  2749. c.ServeSuccessJSON(map[string]interface{}{
  2750. "msg": "上传成功",
  2751. "result": hisFundSettleListResult,
  2752. })
  2753. return
  2754. }
  2755. }
  2756. func (c *HisApiController) GetBatchSettleList() {
  2757. orders, _ := service.GetAllHisOrder(10106)
  2758. for _, item := range orders {
  2759. order_id := item.ID
  2760. order, _ := service.GetHisOrderByIDTwo(order_id)
  2761. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2762. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2763. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2764. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2765. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2766. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2767. if order.ID == 0 {
  2768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2769. return
  2770. }
  2771. if his.BalanceAccountsType == 2 {
  2772. continue
  2773. }
  2774. struct4101 := service.Struct4101{
  2775. PsnNo: order.PsnNo,
  2776. MdtrtId: order.MdtrtId,
  2777. SetlId: order.SetlId,
  2778. PsnName: order.PsnName,
  2779. Gend: order.Gend,
  2780. Brdy: his.Brdy,
  2781. Age: his.Age,
  2782. Naty: order.Naty,
  2783. PatnCertType: "01",
  2784. Certno: order.Certno,
  2785. Prfs: "90",
  2786. ConerName: roles[0].UserName,
  2787. PatnRlts: "99",
  2788. ConerAddr: miConfig.OrgName,
  2789. ConerTel: admin.Mobile,
  2790. HiType: order.Insutype,
  2791. Insuplc: his.InsuplcAdmdvs,
  2792. MaindiagFlag: "1",
  2793. BillCode: order.FaPiaoCode,
  2794. BillNo: order.FaPiaoNumber,
  2795. BizSn: order.Number,
  2796. PsnSelfPay: order.PsnPartAmt,
  2797. PsnOwnPay: order.PsnPartAmt,
  2798. AcctPay: order.AcctPay,
  2799. PsnCashpay: order.PsnCashPay,
  2800. HiPaymtd: "1",
  2801. Hsorg: his.InsuplcAdmdvs,
  2802. HsorgOpter: his.InsuplcAdmdvs,
  2803. MedinsFillPsn: curRoles.UserName,
  2804. MedinsFillDept: depart.Name,
  2805. IptMedType: "2",
  2806. }
  2807. struct4101.SetlBegnDate = order.SetlTime
  2808. struct4101.SetlEndDate = order.SetlTime
  2809. //if order.SettleType == 1 {
  2810. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2811. // dateStr := t.Format("2006-01-02")
  2812. // struct4101.SetlBegnDate = dateStr
  2813. // struct4101.SetlEndDate = dateStr
  2814. //} else {
  2815. // t := time.Unix(int64(order.SettleStartTime), 0)
  2816. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2817. // dateStartStr := t.Format("2006-01-02")
  2818. // dateEndStr := t2.Format("2006-01-02")
  2819. // struct4101.SetlBegnDate = dateStartStr
  2820. // struct4101.SetlEndDate = dateEndStr
  2821. //}
  2822. var rf []CustomFundPay
  2823. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2824. var tempFunPays []service.CustomStruct
  2825. var tempFunPay610100 service.CustomStruct
  2826. for _, item := range rf {
  2827. if item.FundPayType == "610100" {
  2828. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2829. tempFunPay610100.FundPayType = item.FundPayType
  2830. } else {
  2831. var tempFunPay service.CustomStruct
  2832. tempFunPay.FundPayamt = item.FundPayamt
  2833. tempFunPay.FundPayType = item.FundPayType
  2834. tempFunPays = append(tempFunPays, tempFunPay)
  2835. }
  2836. }
  2837. tempFunPays = append(tempFunPays, tempFunPay610100)
  2838. struct4101.CustomStruct = tempFunPays
  2839. var tempDiaginfos []service.DiaginfoStructTwo
  2840. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2841. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2842. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2843. var config []*models.HisXtDiagnoseConfig
  2844. for _, item := range diagnosis_ids {
  2845. id, _ := strconv.ParseInt(item, 10, 64)
  2846. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2847. config = append(config, &diagnosisConfig)
  2848. }
  2849. for index, item := range config {
  2850. if index == 0 {
  2851. var tempDiaginfo service.DiaginfoStructTwo
  2852. tempDiaginfo.DiagCode = item.CountryCode
  2853. tempDiaginfo.DiagName = item.CountryContentName
  2854. tempDiaginfo.DiagType = "1"
  2855. tempDiaginfo.MaindiagFlag = "1"
  2856. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2857. } else {
  2858. var tempDiaginfo service.DiaginfoStructTwo
  2859. tempDiaginfo.DiagCode = item.CountryCode
  2860. tempDiaginfo.DiagName = item.CountryContentName
  2861. tempDiaginfo.DiagType = "2"
  2862. tempDiaginfo.MaindiagFlag = "0"
  2863. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2864. }
  2865. }
  2866. struct4101.Diseinfo = tempDiaginfos
  2867. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2868. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2869. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2870. tempOpspdiseinfo2.OprnOprtCode = ""
  2871. tempOpspdiseinfo2.OprnOprtName = ""
  2872. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2873. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2874. var iteminfo service.IteminfoStruct
  2875. var bedCostTotal float64 = 0 //床位总费
  2876. var bedCostSelfTotal float64 = 0 //床位自费
  2877. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2878. var examineCostTotal float64 = 0 //诊查总费
  2879. var examineCostSelfTotal float64 = 0 //诊查自费
  2880. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2881. var nursingCostTotal float64 = 0 //护理总费
  2882. var nursingCostSelfTotal float64 = 0 //护理自费
  2883. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2884. var chineseMedicineCostTotal float64 = 0 //中成药
  2885. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2886. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2887. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2888. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2889. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2890. var registerCostTotal float64 = 0 //一般诊疗费
  2891. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2892. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2893. var operationCostTotal float64 = 0 //手术费
  2894. var operationCostSelfTotal float64 = 0 //手术费
  2895. var operationCostPartSelfTotal float64 = 0 //手术费
  2896. var otherCostTotal float64 = 0 //其他费用
  2897. var otherCostSelfTotal float64 = 0 //其他费用
  2898. var otherCostPartSelfTotal float64 = 0 //其他费用
  2899. var materialCostTotal float64 = 0 //材料费
  2900. var materialCostSelfTotal float64 = 0 //材料费
  2901. var materialCostPartSelfTotal float64 = 0 //材料费
  2902. var westernMedicineCostTotal float64 = 0 //西药费
  2903. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2904. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2905. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2906. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2907. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2908. var checkCostTotal float64 = 0 //检查费
  2909. var checkCostSelfTotal float64 = 0 //检查费
  2910. var checkCostPartSelfTotal float64 = 0 //检查费
  2911. var laboratoryCostTotal float64 = 0 //化验费
  2912. var laboratoryCostSelfTotal float64 = 0 //化验费
  2913. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2914. var treatCostTotal float64 = 0 //治疗费用
  2915. var treatCostSelfTotal float64 = 0 //治疗费用
  2916. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2917. decimal.DivisionPrecision = 2
  2918. var bed_fulamt_ownpay_amt float64 = 0
  2919. var examine_fulamt_ownpay_amt float64 = 0
  2920. var nursing_fulamt_ownpay_amt float64 = 0
  2921. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2922. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2923. var register_fulamt_ownpay_amt float64 = 0
  2924. var operation_fulamt_ownpay_amt float64 = 0
  2925. var other_fulamt_ownpay_amt float64 = 0
  2926. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2927. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2928. var check_fulamt_ownpay_amt float64 = 0
  2929. var material_fulamt_ownpay_amt float64 = 0
  2930. var laboratory_fulamt_ownpay_amt float64 = 0
  2931. var treat_fulamt_ownpay_amt float64 = 0
  2932. var bed_claa_sunmfee float64 = 0
  2933. var bed_clab_amt float64 = 0
  2934. var bed_other_amt float64 = 0
  2935. var examine_claa_sunmfee float64 = 0
  2936. var examine_clab_amt float64 = 0
  2937. var examine_other_amt float64 = 0
  2938. var nursing_claa_sunmfee float64 = 0
  2939. var nursing_clab_amt float64 = 0
  2940. var nursing_other_amt float64 = 0
  2941. var chinese_medicine_claa_sunmfee float64 = 0
  2942. var chinese_medicine_clab_amt float64 = 0
  2943. var chinese_medicine_other_amt float64 = 0
  2944. var commonly_treatment_claa_sunmfee float64 = 0
  2945. var commonly_treatment_clab_amt float64 = 0
  2946. var commonly_treatment_other_amt float64 = 0
  2947. var operation_claa_sunmfee float64 = 0
  2948. var operation_clab_amt float64 = 0
  2949. var operation_other_amt float64 = 0
  2950. var other_claa_sunmfee float64 = 0
  2951. var other_clab_amt float64 = 0
  2952. var other_other_amt float64 = 0
  2953. var westernMedicine_claa_sunmfee float64 = 0
  2954. var westernMedicine_clab_amt float64 = 0
  2955. var westernMedicine_other_amt float64 = 0
  2956. var chineseTraditional_claa_sunmfee float64 = 0
  2957. var chineseTraditional_clab_amt float64 = 0
  2958. var chineseTraditional_other_amt float64 = 0
  2959. var check_claa_sunmfee float64 = 0
  2960. var check_clab_amt float64 = 0
  2961. var check_other_amt float64 = 0
  2962. var material_claa_sunmfee float64 = 0
  2963. var material_clab_amt float64 = 0
  2964. var material_other_amt float64 = 0
  2965. var laboratory_claa_sunmfee float64 = 0
  2966. var laboratory_clab_amt float64 = 0
  2967. var laboratory_other_amt float64 = 0
  2968. var treat_claa_sunmfee float64 = 0
  2969. var treat_clab_amt float64 = 0
  2970. var treat_other_amt float64 = 0
  2971. var register_claa_sunmfee float64 = 0
  2972. var register_clab_amt float64 = 0
  2973. var register_other_amt float64 = 0
  2974. for _, item := range order.HisOrderInfo {
  2975. if item.MedChrgitmType == "01" { //床位费
  2976. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2977. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2978. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2979. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2980. if item.ChrgitmLv == "1" {
  2981. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2982. }
  2983. if item.ChrgitmLv == "2" {
  2984. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. }
  2986. if item.ChrgitmLv == "3" {
  2987. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2988. }
  2989. }
  2990. if item.MedChrgitmType == "02" { //诊查
  2991. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2992. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2993. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2994. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2995. if item.ChrgitmLv == "1" {
  2996. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2997. }
  2998. if item.ChrgitmLv == "2" {
  2999. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. }
  3001. if item.ChrgitmLv == "3" {
  3002. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3003. }
  3004. }
  3005. if item.MedChrgitmType == "03" { //检查费
  3006. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3007. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3008. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3009. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3010. if item.ChrgitmLv == "1" {
  3011. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3012. }
  3013. if item.ChrgitmLv == "2" {
  3014. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. }
  3016. if item.ChrgitmLv == "3" {
  3017. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3018. }
  3019. }
  3020. if item.MedChrgitmType == "04" { //化验费
  3021. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3022. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3023. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3024. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3025. if item.ChrgitmLv == "1" {
  3026. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3027. }
  3028. if item.ChrgitmLv == "2" {
  3029. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. }
  3031. if item.ChrgitmLv == "3" {
  3032. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3033. }
  3034. }
  3035. if item.MedChrgitmType == "05" { //治疗费
  3036. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3037. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3038. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3039. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3040. if item.ChrgitmLv == "1" {
  3041. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3042. }
  3043. if item.ChrgitmLv == "2" {
  3044. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3045. }
  3046. if item.ChrgitmLv == "3" {
  3047. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3048. }
  3049. }
  3050. if item.MedChrgitmType == "06" { //手术费
  3051. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3052. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3053. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3054. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3055. if item.ChrgitmLv == "1" {
  3056. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3057. }
  3058. if item.ChrgitmLv == "2" {
  3059. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3060. }
  3061. if item.ChrgitmLv == "3" {
  3062. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3063. }
  3064. }
  3065. if item.MedChrgitmType == "07" { //手术费
  3066. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3067. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3068. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3069. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3070. if item.ChrgitmLv == "1" {
  3071. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3072. }
  3073. if item.ChrgitmLv == "2" {
  3074. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3075. }
  3076. if item.ChrgitmLv == "3" {
  3077. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3078. }
  3079. }
  3080. if item.MedChrgitmType == "08" { //材料费
  3081. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3082. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3083. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3084. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3085. if item.ChrgitmLv == "1" {
  3086. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3087. }
  3088. if item.ChrgitmLv == "2" {
  3089. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3090. }
  3091. if item.ChrgitmLv == "3" {
  3092. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3093. }
  3094. }
  3095. if item.MedChrgitmType == "09" { //西药费
  3096. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3097. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3098. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3099. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3100. if item.ChrgitmLv == "1" {
  3101. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3102. }
  3103. if item.ChrgitmLv == "2" {
  3104. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3105. }
  3106. if item.ChrgitmLv == "3" {
  3107. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3108. }
  3109. }
  3110. if item.MedChrgitmType == "10" { //中药饮片
  3111. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3112. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3113. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3114. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3115. if item.ChrgitmLv == "1" {
  3116. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3117. }
  3118. if item.ChrgitmLv == "2" {
  3119. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3120. }
  3121. if item.ChrgitmLv == "3" {
  3122. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3123. }
  3124. }
  3125. if item.MedChrgitmType == "11" { //中成费
  3126. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3127. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3128. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3129. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3130. if item.ChrgitmLv == "1" {
  3131. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3132. }
  3133. if item.ChrgitmLv == "2" {
  3134. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3135. }
  3136. if item.ChrgitmLv == "3" {
  3137. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3138. }
  3139. }
  3140. if item.MedChrgitmType == "12" { //中成费
  3141. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3142. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3143. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3144. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3145. if item.ChrgitmLv == "1" {
  3146. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3147. }
  3148. if item.ChrgitmLv == "2" {
  3149. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3150. }
  3151. if item.ChrgitmLv == "3" {
  3152. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3153. }
  3154. }
  3155. if item.MedChrgitmType == "13" { //中成费
  3156. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3157. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3158. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3159. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3160. if item.ChrgitmLv == "1" {
  3161. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3162. }
  3163. if item.ChrgitmLv == "2" {
  3164. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3165. }
  3166. if item.ChrgitmLv == "3" {
  3167. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3168. }
  3169. }
  3170. if item.MedChrgitmType == "14" { //其他费
  3171. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3172. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3173. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3174. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3175. if item.ChrgitmLv == "1" {
  3176. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3177. }
  3178. if item.ChrgitmLv == "2" {
  3179. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3180. }
  3181. if item.ChrgitmLv == "3" {
  3182. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3183. }
  3184. }
  3185. }
  3186. var iteminfoStructs []service.IteminfoStruct
  3187. if bedCostTotal != 0 {
  3188. iteminfo.MedChrgitm = "01"
  3189. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3190. iteminfo.Amt = bedCostTotal
  3191. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3192. iteminfo.ClabAmt = bed_clab_amt
  3193. iteminfo.OthAmt = bed_other_amt
  3194. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3195. }
  3196. if examineCostTotal != 0 {
  3197. iteminfo.MedChrgitm = "02"
  3198. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3199. iteminfo.Amt = examineCostTotal
  3200. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3201. iteminfo.ClabAmt = examine_clab_amt
  3202. iteminfo.OthAmt = examine_other_amt
  3203. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3205. }
  3206. if checkCostTotal != 0 {
  3207. iteminfo.MedChrgitm = "03"
  3208. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3209. iteminfo.Amt = checkCostTotal
  3210. iteminfo.ClaaSumfee = check_claa_sunmfee
  3211. iteminfo.ClabAmt = check_clab_amt
  3212. iteminfo.OthAmt = check_other_amt
  3213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3214. }
  3215. if laboratoryCostTotal != 0 {
  3216. iteminfo.MedChrgitm = "04"
  3217. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3218. iteminfo.Amt = laboratoryCostTotal
  3219. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3220. iteminfo.ClabAmt = laboratory_clab_amt
  3221. iteminfo.OthAmt = laboratory_other_amt
  3222. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3223. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3224. }
  3225. if treatCostTotal != 0 {
  3226. iteminfo.MedChrgitm = "05"
  3227. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3228. iteminfo.Amt = treatCostTotal
  3229. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3230. iteminfo.ClabAmt = treat_clab_amt
  3231. iteminfo.OthAmt = treat_other_amt
  3232. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3233. //(struct4101.IteminfoStruct, iteminfo)
  3234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3235. }
  3236. if operationCostTotal != 0 {
  3237. iteminfo.MedChrgitm = "06"
  3238. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3239. iteminfo.Amt = operationCostTotal
  3240. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3241. iteminfo.ClabAmt = operation_clab_amt
  3242. iteminfo.OthAmt = operation_other_amt
  3243. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3245. }
  3246. if nursingCostTotal != 0 {
  3247. iteminfo.MedChrgitm = "07"
  3248. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3249. iteminfo.Amt = nursingCostTotal
  3250. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3251. iteminfo.ClabAmt = nursing_clab_amt
  3252. iteminfo.OthAmt = nursing_other_amt
  3253. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3254. }
  3255. if materialCostTotal != 0 {
  3256. iteminfo.MedChrgitm = "08"
  3257. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3258. iteminfo.Amt = materialCostTotal
  3259. iteminfo.ClaaSumfee = material_claa_sunmfee
  3260. iteminfo.ClabAmt = material_clab_amt
  3261. iteminfo.OthAmt = material_other_amt
  3262. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3263. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3264. }
  3265. if westernMedicineCostTotal != 0 {
  3266. iteminfo.MedChrgitm = "09"
  3267. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3268. iteminfo.Amt = westernMedicineCostTotal
  3269. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3270. iteminfo.ClabAmt = westernMedicine_clab_amt
  3271. iteminfo.OthAmt = westernMedicine_other_amt
  3272. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3273. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3274. }
  3275. if chineseMedicineCostTotal != 0 {
  3276. iteminfo.MedChrgitm = "10"
  3277. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3278. iteminfo.Amt = chineseMedicineCostTotal
  3279. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3280. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3281. iteminfo.OthAmt = chinese_medicine_other_amt
  3282. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3284. }
  3285. if chineseTraditionalMedicineCostTotal != 0 {
  3286. iteminfo.MedChrgitm = "11"
  3287. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3288. iteminfo.Amt = westernMedicineCostTotal
  3289. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3290. iteminfo.ClabAmt = westernMedicine_clab_amt
  3291. iteminfo.OthAmt = westernMedicine_other_amt
  3292. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3293. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3294. }
  3295. if commonlyTreatmentCostTotal != 0 {
  3296. iteminfo.MedChrgitm = "12"
  3297. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3298. iteminfo.Amt = commonlyTreatmentCostTotal
  3299. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3300. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3301. iteminfo.OthAmt = commonly_treatment_other_amt
  3302. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3303. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3304. }
  3305. if registerCostTotal != 0 {
  3306. iteminfo.MedChrgitm = "13"
  3307. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3308. iteminfo.Amt = registerCostTotal
  3309. iteminfo.ClaaSumfee = register_claa_sunmfee
  3310. iteminfo.ClabAmt = register_clab_amt
  3311. iteminfo.OthAmt = register_other_amt
  3312. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3313. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3314. }
  3315. if otherCostTotal != 0 {
  3316. iteminfo.MedChrgitm = "14"
  3317. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3318. iteminfo.Amt = otherCostTotal
  3319. iteminfo.ClaaSumfee = other_claa_sunmfee
  3320. iteminfo.ClabAmt = other_clab_amt
  3321. iteminfo.OthAmt = other_other_amt
  3322. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3323. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3324. }
  3325. struct4101.IteminfoStruct = iteminfoStructs
  3326. struct4101.Ntly = "中国"
  3327. struct4101.AdmCaty = "A03.06"
  3328. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3329. fmt.Println(result)
  3330. var dat map[string]interface{}
  3331. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3332. fmt.Println(dat)
  3333. } else {
  3334. fmt.Println(err)
  3335. }
  3336. userJSONBytes, _ := json.Marshal(dat)
  3337. var res ResultSeventeen
  3338. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3339. utils.ErrorLog("解析失败:%v", err)
  3340. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3341. adminUser := c.GetAdminUserInfo()
  3342. errlog := &models.HisOrderError{
  3343. UserOrgId: adminUser.CurrentOrgId,
  3344. Ctime: time.Now().Unix(),
  3345. Mtime: time.Now().Unix(),
  3346. ErrMsg: res.ErrMsg + "解析失败",
  3347. Status: 1,
  3348. PatientId: order_id,
  3349. Stage: 10106,
  3350. }
  3351. service.CreateErrMsgLog(errlog)
  3352. continue
  3353. }
  3354. if res.Infcode != 0 {
  3355. adminUser := c.GetAdminUserInfo()
  3356. errlog := &models.HisOrderError{
  3357. UserOrgId: adminUser.CurrentOrgId,
  3358. Ctime: time.Now().Unix(),
  3359. Mtime: time.Now().Unix(),
  3360. ErrMsg: res.ErrMsg,
  3361. Status: 1,
  3362. PatientId: order_id,
  3363. Stage: 10106,
  3364. }
  3365. service.CreateErrMsgLog(errlog)
  3366. continue
  3367. } else {
  3368. hisFundSettleListResult := &models.HisFundSettleListResult{
  3369. Number: res.Output.SetlListId,
  3370. Status: 1,
  3371. Ctime: time.Now().Unix(),
  3372. Mtime: time.Now().Unix(),
  3373. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3374. IsUpload: 1,
  3375. OrderId: order_id,
  3376. }
  3377. service.CreateUploadRecord(hisFundSettleListResult)
  3378. continue
  3379. }
  3380. }
  3381. }
  3382. func (c *HisApiController) GetOrgInfo() {
  3383. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3384. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3385. }
  3386. func (c *HisApiController) GetHisPatientInfo() {
  3387. medical_insurance_card := c.GetString("medical_insurance_card")
  3388. id_card_type, _ := c.GetInt64("id_card_type")
  3389. id_card := c.GetString("id_card")
  3390. adminInfo := c.GetAdminUserInfo()
  3391. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3392. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3393. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3394. IdCardNo := ""
  3395. if id_card_type == 1 {
  3396. IdCardNo = medical_insurance_card
  3397. } else if id_card_type == 2 {
  3398. IdCardNo = id_card
  3399. }
  3400. if config.IsOpen == 1 {
  3401. 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
  3402. resp, requestErr := http.Get(api)
  3403. if requestErr != nil {
  3404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3405. return
  3406. }
  3407. defer resp.Body.Close()
  3408. body, ioErr := ioutil.ReadAll(resp.Body)
  3409. if ioErr != nil {
  3410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3412. return
  3413. }
  3414. var respJSON map[string]interface{}
  3415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3418. return
  3419. }
  3420. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3421. userJSONBytes, _ := json.Marshal(userJSON)
  3422. var res ResultTwo
  3423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3424. utils.ErrorLog("解析失败:%v", err)
  3425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3426. return
  3427. }
  3428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3430. infoStr := string(Iinfos)
  3431. idetinfoStr := string(Idetinfos)
  3432. if res.Infcode == 0 {
  3433. his := models.VMHisPatient{
  3434. Status: 1,
  3435. Ctime: time.Now().Unix(),
  3436. Mtime: time.Now().Unix(),
  3437. PsnNo: res.Output.Baseinfo.PsnNo,
  3438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3439. Certno: res.Output.Baseinfo.Certno,
  3440. PsnName: res.Output.Baseinfo.PsnName,
  3441. Gend: res.Output.Baseinfo.Gend,
  3442. Naty: res.Output.Baseinfo.Naty,
  3443. Brdy: res.Output.Baseinfo.Brdy,
  3444. Age: res.Output.Baseinfo.Age,
  3445. Iinfo: infoStr,
  3446. Idetinfo: idetinfoStr,
  3447. UserOrgId: adminInfo.CurrentOrgId,
  3448. IsReturn: 1,
  3449. IdCardType: id_card_type,
  3450. }
  3451. c.ServeSuccessJSON(map[string]interface{}{
  3452. "info": his,
  3453. })
  3454. } else {
  3455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3456. return
  3457. }
  3458. }
  3459. }
  3460. //func GetBasBaseInfo() (jsonStr string, err error) {
  3461. //
  3462. // handle := syscall.NewLazyDLL("SSCard.dll")
  3463. // add := handle.NewProc("ReadCardBas")
  3464. // str := make([]byte, 1024)
  3465. // str1 := make([]byte, 1024)
  3466. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3467. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3468. //
  3469. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3470. //
  3471. // fmt.Println("> Add(4,5)的结果为:", ret)
  3472. // handle.Release()
  3473. //
  3474. // return "", nil
  3475. //
  3476. //}
  3477. //func GetQRBaseInfo() (jsonStr string, err error) {
  3478. // handle := syscall.LoadDLL("SSCard.dll")
  3479. // ReadCardBas := handle.FindProc("GetQRBase")
  3480. //
  3481. // str := make([]byte, 256)
  3482. // str1 := make([]byte, 256)
  3483. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3484. //
  3485. // fmt.Println(string(str))
  3486. // fmt.Println(r)
  3487. // return string(str), nil
  3488. //}
  3489. //func CardInit() int {
  3490. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3491. // add := DllTestDef.MustFindProc("Init")
  3492. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3493. // if err != nil {
  3494. // fmt.Println("SSCard的运算结果为:", ret)
  3495. // }
  3496. // result := int(ret)
  3497. // return result
  3498. //}
  3499. //func CardInit() int {
  3500. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3501. // if err != nil {
  3502. // fmt.Println("SSCard的运算结果为:", ret)
  3503. // }
  3504. // fmt.Println(err)
  3505. // result := int(ret)
  3506. // return result
  3507. //}
  3508. func IntPtr(n int) uintptr {
  3509. return uintptr(n)
  3510. }
  3511. func StrPtr(s string) uintptr {
  3512. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3513. }
  3514. type Result2001 struct {
  3515. Cainfo interface{} `json:"cainfo"`
  3516. ErrMsg string `json:"err_msg"`
  3517. InfRefmsgid string `json:"inf_refmsgid"`
  3518. Infcode int64 `json:"infcode"`
  3519. Output struct {
  3520. Trtinfo struct {
  3521. PsnNo string `json:"psn_no"`
  3522. TrtChkType string `json:"trt_chk_type"`
  3523. FundPayType string `json:"fund_pay_type"`
  3524. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3525. Begndate string `json:"begndate"`
  3526. Enddate string `json:"enddate"`
  3527. TrtChkRslt string `json:"trt_chk_rslt"`
  3528. } `json:"trtinfo"`
  3529. } `json:"output"`
  3530. RefmsgTime string `json:"refmsg_time"`
  3531. RespondTime string `json:"respond_time"`
  3532. Signtype interface{} `json:"signtype"`
  3533. WarnMsg interface{} `json:"warn_msg"`
  3534. }
  3535. type Result2001Org10265 struct {
  3536. Cainfo interface{} `json:"cainfo"`
  3537. ErrMsg string `json:"err_msg"`
  3538. InfRefmsgid string `json:"inf_refmsgid"`
  3539. Infcode string `json:"infcode"`
  3540. Output struct {
  3541. Trtinfo struct {
  3542. PsnNo string `json:"psn_no"`
  3543. TrtChkType string `json:"trt_chk_type"`
  3544. FundPayType string `json:"fund_pay_type"`
  3545. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3546. Begndate string `json:"begndate"`
  3547. Enddate string `json:"enddate"`
  3548. TrtChkRslt string `json:"trt_chk_rslt"`
  3549. } `json:"trtinfo"`
  3550. } `json:"output"`
  3551. RefmsgTime string `json:"refmsg_time"`
  3552. RespondTime string `json:"respond_time"`
  3553. Signtype interface{} `json:"signtype"`
  3554. WarnMsg interface{} `json:"warn_msg"`
  3555. }
  3556. type ResultTwo struct {
  3557. ErrMsg string `json:"err_msg"`
  3558. InfRefmsgid string `json:"inf_refmsgid"`
  3559. Infcode int64 `json:"infcode"`
  3560. Output struct {
  3561. Baseinfo struct {
  3562. Age float64 `json:"age"`
  3563. Brdy string `json:"brdy"`
  3564. Certno string `json:"certno"`
  3565. Gend string `json:"gend"`
  3566. Naty string `json:"naty"`
  3567. PsnCertType string `json:"psn_cert_type"`
  3568. PsnName string `json:"psn_name"`
  3569. PsnNo string `json:"psn_no"`
  3570. } `json:"baseinfo"`
  3571. Idetinfo []interface{} `json:"idetinfo"`
  3572. Iinfo []struct {
  3573. Balc float64 `json:"balc"`
  3574. CvlservFlag string `json:"cvlserv_flag"`
  3575. EmpName string `json:"emp_name"`
  3576. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3577. Insutype string `json:"insutype"`
  3578. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3579. PausInsuDate string `json:"paus_insu_date"`
  3580. PsnInsuDate string `json:"psn_insu_date"`
  3581. PsnInsuStas string `json:"psn_insu_stas"`
  3582. PsnType string `json:"psn_type"`
  3583. } `json:"insuinfo"`
  3584. } `json:"output"`
  3585. RefmsgTime string `json:"refmsg_time"`
  3586. RespondTime string `json:"respond_time"`
  3587. Signtype interface{} `json:"signtype"`
  3588. WarnInfo interface{} `json:"warn_info"`
  3589. }
  3590. type ResultTwo10265 struct {
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode string `json:"infcode"`
  3594. Output struct {
  3595. Baseinfo struct {
  3596. Age float64 `json:"age"`
  3597. Brdy string `json:"brdy"`
  3598. Certno string `json:"certno"`
  3599. Gend string `json:"gend"`
  3600. Naty string `json:"naty"`
  3601. PsnCertType string `json:"psn_cert_type"`
  3602. PsnName string `json:"psn_name"`
  3603. PsnNo string `json:"psn_no"`
  3604. } `json:"baseinfo"`
  3605. Idetinfo []interface{} `json:"idetinfo"`
  3606. Iinfo []struct {
  3607. Balc float64 `json:"balc"`
  3608. CvlservFlag string `json:"cvlserv_flag"`
  3609. EmpName string `json:"emp_name"`
  3610. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3611. Insutype string `json:"insutype"`
  3612. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3613. PausInsuDate string `json:"paus_insu_date"`
  3614. PsnInsuDate string `json:"psn_insu_date"`
  3615. PsnInsuStas string `json:"psn_insu_stas"`
  3616. PsnType string `json:"psn_type"`
  3617. } `json:"insuinfo"`
  3618. } `json:"output"`
  3619. RefmsgTime string `json:"refmsg_time"`
  3620. RespondTime string `json:"respond_time"`
  3621. Signtype interface{} `json:"signtype"`
  3622. WarnInfo interface{} `json:"warn_info"`
  3623. }
  3624. type ResultThree struct {
  3625. Cainfo interface{} `json:"cainfo"`
  3626. ErrMsg string `json:"err_msg"`
  3627. InfRefmsgid string `json:"inf_refmsgid"`
  3628. Infcode int64 `json:"infcode"`
  3629. Output struct {
  3630. Data struct {
  3631. IptOtpNo string `json:"ipt_otp_no"`
  3632. MdtrtID string `json:"mdtrt_id"`
  3633. PsnNo string `json:"psn_no"`
  3634. } `json:"data"`
  3635. } `json:"output"`
  3636. RefmsgTime string `json:"refmsg_time"`
  3637. RespondTime string `json:"respond_time"`
  3638. Signtype interface{} `json:"signtype"`
  3639. WarnMsg interface{} `json:"warn_msg"`
  3640. }
  3641. type ResultThree10265 struct {
  3642. Cainfo interface{} `json:"cainfo"`
  3643. ErrMsg string `json:"err_msg"`
  3644. InfRefmsgid string `json:"inf_refmsgid"`
  3645. Infcode string `json:"infcode"`
  3646. Output struct {
  3647. Data struct {
  3648. IptOtpNo string `json:"ipt_otp_no"`
  3649. MdtrtID string `json:"mdtrt_id"`
  3650. PsnNo string `json:"psn_no"`
  3651. } `json:"data"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnMsg interface{} `json:"warn_msg"`
  3657. }
  3658. type ResultFour struct {
  3659. Cainfo string `json:"cainfo"`
  3660. ErrMsg string `json:"err_msg"`
  3661. InfRefmsgid string `json:"inf_refmsgid"`
  3662. Infcode int64 `json:"infcode"`
  3663. Output struct {
  3664. Result []struct {
  3665. BasMednFlag string `json:"bas_medn_flag"`
  3666. ChldMedcFlag string `json:"chld_medc_flag"`
  3667. ChrgitmLv string `json:"chrgitm_lv"`
  3668. Cnt float64 `json:"cnt"`
  3669. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3670. DrtReimFlag string `json:"drt_reim_flag"`
  3671. FeedetlSn string `json:"feedetl_sn"`
  3672. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3673. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3674. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3675. ListSpItemFlag string `json:"list_sp_item_flag"`
  3676. LmtUsedFlag string `json:"lmt_used_flag"`
  3677. MedChrgitmType string `json:"med_chrgitm_type"`
  3678. Memo string `json:"memo"`
  3679. OverlmtAmt float64 `json:"overlmt_amt"`
  3680. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3681. Pric float64 `json:"pric"`
  3682. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3683. SelfpayProp float64 `json:"selfpay_prop"`
  3684. } `json:"result"`
  3685. } `json:"output"`
  3686. RefmsgTime string `json:"refmsg_time"`
  3687. RespondTime string `json:"respond_time"`
  3688. Signtype string `json:"signtype"`
  3689. WarnMsg string `json:"warn_msg"`
  3690. }
  3691. type ResultFour10265 struct {
  3692. Cainfo string `json:"cainfo"`
  3693. ErrMsg string `json:"err_msg"`
  3694. InfRefmsgid string `json:"inf_refmsgid"`
  3695. Infcode string `json:"infcode"`
  3696. Output struct {
  3697. Result []struct {
  3698. BasMednFlag string `json:"bas_medn_flag"`
  3699. ChldMedcFlag string `json:"chld_medc_flag"`
  3700. ChrgitmLv string `json:"chrgitm_lv"`
  3701. Cnt float64 `json:"cnt"`
  3702. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3703. DrtReimFlag string `json:"drt_reim_flag"`
  3704. FeedetlSn string `json:"feedetl_sn"`
  3705. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3706. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3707. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3708. ListSpItemFlag string `json:"list_sp_item_flag"`
  3709. LmtUsedFlag string `json:"lmt_used_flag"`
  3710. MedChrgitmType string `json:"med_chrgitm_type"`
  3711. Memo string `json:"memo"`
  3712. OverlmtAmt float64 `json:"overlmt_amt"`
  3713. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3714. Pric float64 `json:"pric"`
  3715. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3716. SelfpayProp float64 `json:"selfpay_prop"`
  3717. } `json:"result"`
  3718. } `json:"output"`
  3719. RefmsgTime string `json:"refmsg_time"`
  3720. RespondTime string `json:"respond_time"`
  3721. Signtype string `json:"signtype"`
  3722. WarnMsg string `json:"warn_msg"`
  3723. }
  3724. type ResultFive struct {
  3725. Balc float64 `json:"balc"`
  3726. CvlservFlag string `json:"cvlserv_flag"`
  3727. EmpName string `json:"emp_name"`
  3728. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3729. Insutype string `json:"insutype"`
  3730. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3731. PausInsuDate string `json:"paus_insu_date"`
  3732. PsnInsuDate string `json:"psn_insu_date"`
  3733. PsnInsuStas string `json:"psn_insu_stas"`
  3734. PsnType string `json:"psn_type"`
  3735. }
  3736. type ResultSix struct {
  3737. Cainfo interface{} `json:"cainfo"`
  3738. ErrMsg string `json:"err_msg"`
  3739. InfRefmsgid string `json:"inf_refmsgid"`
  3740. Infcode int64 `json:"infcode"`
  3741. Output struct {
  3742. } `json:"output"`
  3743. RefmsgTime string `json:"refmsg_time"`
  3744. RespondTime string `json:"respond_time"`
  3745. Signtype interface{} `json:"signtype"`
  3746. WarnMsg interface{} `json:"warn_msg"`
  3747. }
  3748. type ResultSix10265 struct {
  3749. Cainfo interface{} `json:"cainfo"`
  3750. ErrMsg string `json:"err_msg"`
  3751. InfRefmsgid string `json:"inf_refmsgid"`
  3752. Infcode string `json:"infcode"`
  3753. Output struct {
  3754. } `json:"output"`
  3755. RefmsgTime string `json:"refmsg_time"`
  3756. RespondTime string `json:"respond_time"`
  3757. Signtype interface{} `json:"signtype"`
  3758. WarnMsg interface{} `json:"warn_msg"`
  3759. }
  3760. type ResultSeven struct {
  3761. Cainfo string `json:"cainfo"`
  3762. ErrMsg string `json:"err_msg"`
  3763. InfRefmsgid string `json:"inf_refmsgid"`
  3764. Infcode int64 `json:"infcode"`
  3765. Output struct {
  3766. Setldetail []interface{} `json:"setldetail"`
  3767. Setlinfo struct {
  3768. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3769. AcctPay float64 `json:"acct_pay"`
  3770. ActPayDedc float64 `json:"act_pay_dedc"`
  3771. Age float64 `json:"age"`
  3772. Balc float64 `json:"balc"`
  3773. Brdy string `json:"brdy"`
  3774. Certno string `json:"certno"`
  3775. ClrOptins string `json:"clr_optins"`
  3776. ClrType string `json:"clr_type"`
  3777. ClrWay string `json:"clr_way"`
  3778. CvlservFlag string `json:"cvlserv_flag"`
  3779. CvlservPay float64 `json:"cvlserv_pay"`
  3780. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3781. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3782. Gend string `json:"gend"`
  3783. HifesPay float64 `json:"hifes_pay"`
  3784. HifmiPay float64 `json:"hifmi_pay"`
  3785. HifpPay float64 `json:"hifp_pay"`
  3786. HospPartAmt float64 `json:"hosp_part_amt"`
  3787. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3788. Insutype string `json:"insutype"`
  3789. MafPay float64 `json:"maf_pay"`
  3790. MdtrtCertType string `json:"mdtrt_cert_type"`
  3791. HifobPay float64 `json:"hifob_pay"`
  3792. MdtrtID string `json:"mdtrt_id"`
  3793. MedType string `json:"med_type"`
  3794. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3795. MedinsSetlID string `json:"medins_setl_id"`
  3796. Naty string `json:"naty"`
  3797. OthPay float64 `json:"oth_pay"`
  3798. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3799. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3800. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3801. PsnCashPay float64 `json:"psn_cash_pay"`
  3802. PsnCertType string `json:"psn_cert_type"`
  3803. PsnName string `json:"psn_name"`
  3804. PsnNo string `json:"psn_no"`
  3805. PsnPartAmt float64 `json:"psn_part_amt"`
  3806. PsnType string `json:"psn_type"`
  3807. SetlID string `json:"setl_id"`
  3808. SetlTime string `json:"setl_time"`
  3809. } `json:"setlinfo"`
  3810. } `json:"output"`
  3811. RefmsgTime string `json:"refmsg_time"`
  3812. RespondTime string `json:"respond_time"`
  3813. Signtype interface{} `json:"signtype"`
  3814. WarnMsg interface{} `json:"warn_msg"`
  3815. }
  3816. type ResultSeven10265 struct {
  3817. Cainfo string `json:"cainfo"`
  3818. ErrMsg string `json:"err_msg"`
  3819. InfRefmsgid string `json:"inf_refmsgid"`
  3820. Infcode string `json:"infcode"`
  3821. Output struct {
  3822. Setldetail []interface{} `json:"setldetail"`
  3823. Setlinfo struct {
  3824. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3825. AcctPay float64 `json:"acct_pay"`
  3826. ActPayDedc float64 `json:"act_pay_dedc"`
  3827. Age float64 `json:"age"`
  3828. Balc float64 `json:"balc"`
  3829. Brdy string `json:"brdy"`
  3830. Certno string `json:"certno"`
  3831. ClrOptins string `json:"clr_optins"`
  3832. ClrType string `json:"clr_type"`
  3833. ClrWay string `json:"clr_way"`
  3834. CvlservFlag string `json:"cvlserv_flag"`
  3835. CvlservPay float64 `json:"cvlserv_pay"`
  3836. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3837. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3838. Gend string `json:"gend"`
  3839. HifesPay float64 `json:"hifes_pay"`
  3840. HifmiPay float64 `json:"hifmi_pay"`
  3841. HifpPay float64 `json:"hifp_pay"`
  3842. HospPartAmt float64 `json:"hosp_part_amt"`
  3843. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3844. Insutype string `json:"insutype"`
  3845. MafPay float64 `json:"maf_pay"`
  3846. MdtrtCertType string `json:"mdtrt_cert_type"`
  3847. HifobPay float64 `json:"hifob_pay"`
  3848. MdtrtID string `json:"mdtrt_id"`
  3849. MedType string `json:"med_type"`
  3850. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3851. MedinsSetlID string `json:"medins_setl_id"`
  3852. Naty string `json:"naty"`
  3853. OthPay float64 `json:"oth_pay"`
  3854. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3855. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3856. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3857. PsnCashPay float64 `json:"psn_cash_pay"`
  3858. PsnCertType string `json:"psn_cert_type"`
  3859. PsnName string `json:"psn_name"`
  3860. PsnNo string `json:"psn_no"`
  3861. PsnPartAmt float64 `json:"psn_part_amt"`
  3862. PsnType string `json:"psn_type"`
  3863. SetlID string `json:"setl_id"`
  3864. SetlTime string `json:"setl_time"`
  3865. } `json:"setlinfo"`
  3866. } `json:"output"`
  3867. RefmsgTime string `json:"refmsg_time"`
  3868. RespondTime string `json:"respond_time"`
  3869. Signtype interface{} `json:"signtype"`
  3870. WarnMsg interface{} `json:"warn_msg"`
  3871. }
  3872. type ResultEight struct {
  3873. Cainfo string `json:"cainfo"`
  3874. ErrMsg string `json:"err_msg"`
  3875. InfRefmsgid string `json:"inf_refmsgid"`
  3876. Infcode int64 `json:"infcode"`
  3877. Output struct {
  3878. Stmtinfo struct {
  3879. SetlOptins string `json:"setl_optins"`
  3880. StmtRslt string `json:"stmt_rslt"`
  3881. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3882. } `json:"stmtinfo"`
  3883. } `json:"output"`
  3884. RefmsgTime string `json:"refmsg_time"`
  3885. RespondTime string `json:"respond_time"`
  3886. Signtype interface{} `json:"signtype"`
  3887. WarnMsg interface{} `json:"warn_msg"`
  3888. }
  3889. type ResultEightFor10188 struct {
  3890. Cainfo string `json:"cainfo"`
  3891. ErrMsg string `json:"err_msg"`
  3892. InfRefmsgid string `json:"inf_refmsgid"`
  3893. Infcode string `json:"infcode"`
  3894. Output struct {
  3895. Stmtinfo struct {
  3896. SetlOptins string `json:"setl_optins"`
  3897. StmtRslt string `json:"stmt_rslt"`
  3898. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3899. } `json:"stmtinfo"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnMsg interface{} `json:"warn_msg"`
  3905. }
  3906. type ResultNine struct {
  3907. Cainfo string `json:"cainfo"`
  3908. ErrMsg string `json:"err_msg"`
  3909. InfRefmsgid string `json:"inf_refmsgid"`
  3910. Infcode int64 `json:"infcode"`
  3911. Output struct {
  3912. FileQuryNo string `json:"file_qury_no"`
  3913. } `json:"output"`
  3914. RefmsgTime string `json:"refmsg_time"`
  3915. RespondTime string `json:"respond_time"`
  3916. Signtype interface{} `json:"signtype"`
  3917. WarnMsg interface{} `json:"warn_msg"`
  3918. }
  3919. type ResultTen struct {
  3920. Cainfo string `json:"cainfo"`
  3921. ErrMsg string `json:"err_msg"`
  3922. InfRefmsgid string `json:"inf_refmsgid"`
  3923. Infcode int64 `json:"infcode"`
  3924. Output struct {
  3925. DldEndtime string `json:"dld_endtime"`
  3926. FileQuryNo string `json:"file_qury_no"`
  3927. Filename string `json:"filename"`
  3928. } `json:"output"`
  3929. RefmsgTime string `json:"refmsg_time"`
  3930. RespondTime string `json:"respond_time"`
  3931. Signtype interface{} `json:"signtype"`
  3932. WarnMsg interface{} `json:"warn_msg"`
  3933. }
  3934. //type Autogenerated struct {
  3935. // Output struct {
  3936. // Setlinfo struct {
  3937. // SetlTime string `json:"setl_time"`
  3938. // CvlservPay float64 `json:"cvlserv_pay"`
  3939. // Year string `json:"year"`
  3940. // MedType string `json:"med_type"`
  3941. // PsnPay float64 `json:"psn_pay"`
  3942. // OpterID string `json:"opter_id"`
  3943. // Begndate string `json:"begndate"`
  3944. // FlxempeFlag string `json:"flxempe_flag"`
  3945. // HifmiPay float64 `json:"hifmi_pay"`
  3946. // PsnNo string `json:"psn_no"`
  3947. // ActPayDedc float64 `json:"act_pay_dedc"`
  3948. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3949. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3950. // ClrWay string `json:"clr_way"`
  3951. // OthPay float64 `json:"oth_pay"`
  3952. // Gend string `json:"gend"`
  3953. // MdtrtID string `json:"mdtrt_id"`
  3954. // AcctPay float64 `json:"acct_pay"`
  3955. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3956. // Insutype string `json:"insutype"`
  3957. // Invono interface{} `json:"invono"`
  3958. // Enddate string `json:"enddate"`
  3959. // CashPayamt float64 `json:"cash_payamt"`
  3960. // PsnType string `json:"psn_type"`
  3961. // FixmedinsName string `json:"fixmedins_name"`
  3962. // HifpPay float64 `json:"hifp_pay"`
  3963. // NewFlag interface{} `json:"new_flag"`
  3964. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3965. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3966. // PayLoc string `json:"pay_loc"`
  3967. // ClrType string `json:"clr_type"`
  3968. // RefdSetlFlag string `json:"refd_setl_flag"`
  3969. // CvlservFlag string `json:"cvlserv_flag"`
  3970. // EmpName string `json:"emp_name"`
  3971. // Brdy string `json:"brdy"`
  3972. // Naty string `json:"naty"`
  3973. // Certno string `json:"certno"`
  3974. // DiseCode string `json:"dise_code"`
  3975. // FixmedinsCode string `json:"fixmedins_code"`
  3976. // DedcHospLv string `json:"dedc_hosp_lv"`
  3977. // OpterName string `json:"opter_name"`
  3978. // Balc float64 `json:"balc"`
  3979. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3980. // PsnCertType string `json:"psn_cert_type"`
  3981. // HifobPay float64 `json:"hifob_pay"`
  3982. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3983. // HifesPay float64 `json:"hifes_pay"`
  3984. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3985. // OptTime string `json:"opt_time"`
  3986. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3987. // SetlID string `json:"setl_id"`
  3988. // MafPay float64 `json:"maf_pay"`
  3989. // PsnName string `json:"psn_name"`
  3990. // InsuOptins interface{} `json:"insu_optins"`
  3991. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3992. // ClrOptins string `json:"clr_optins"`
  3993. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3994. // DiseName string `json:"dise_name"`
  3995. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3996. // Age float64 `json:"age"`
  3997. // DtrtCertType string `json:"dtrt_cert_type"`
  3998. // HospLv string `json:"hosp_lv"`
  3999. // } `json:"setlinfo"`
  4000. // Setldetail []struct {
  4001. // FundPayType string `json:"fund_pay_type"`
  4002. // FundPayamt float64 `json:"fund_payamt"`
  4003. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4004. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4005. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4006. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4007. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4008. // } `json:"setldetail"`
  4009. // } `json:"output"`
  4010. // Infcode int `json:"infcode"`
  4011. // WarnMsg interface{} `json:"warn_msg"`
  4012. // Cainfo interface{} `json:"cainfo"`
  4013. // ErrMsg interface{} `json:"err_msg"`
  4014. // RefmsgTime string `json:"refmsg_time"`
  4015. // Signtype interface{} `json:"signtype"`
  4016. // RespondTime string `json:"respond_time"`
  4017. // InfRefmsgid string `json:"inf_refmsgid"`
  4018. //}
  4019. type ResultEleven struct {
  4020. Cainfo string `json:"cainfo"`
  4021. ErrMsg string `json:"err_msg"`
  4022. InfRefmsgid string `json:"inf_refmsgid"`
  4023. Infcode int64 `json:"infcode"`
  4024. Output struct {
  4025. Setlinfo struct {
  4026. SetlTime string `json:"setl_time"`
  4027. CvlservPay float64 `json:"cvlserv_pay"`
  4028. Year string `json:"year"`
  4029. MedType string `json:"med_type"`
  4030. PsnPay float64 `json:"psn_pay"`
  4031. OpterID string `json:"opter_id"`
  4032. Begndate string `json:"begndate"`
  4033. FlxempeFlag string `json:"flxempe_flag"`
  4034. HifmiPay float64 `json:"hifmi_pay"`
  4035. PsnNo string `json:"psn_no"`
  4036. ActPayDedc float64 `json:"act_pay_dedc"`
  4037. MedinsSetlID interface{} `json:"medins_setl_id"`
  4038. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4039. ClrWay string `json:"clr_way"`
  4040. OthPay float64 `json:"oth_pay"`
  4041. Gend string `json:"gend"`
  4042. MdtrtID string `json:"mdtrt_id"`
  4043. AcctPay float64 `json:"acct_pay"`
  4044. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4045. Insutype string `json:"insutype"`
  4046. Invono interface{} `json:"invono"`
  4047. Enddate string `json:"enddate"`
  4048. CashPayamt float64 `json:"cash_payamt"`
  4049. PsnType string `json:"psn_type"`
  4050. FixmedinsName string `json:"fixmedins_name"`
  4051. HifpPay float64 `json:"hifp_pay"`
  4052. NewFlag interface{} `json:"new_flag"`
  4053. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4054. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4055. PayLoc string `json:"pay_loc"`
  4056. ClrType string `json:"clr_type"`
  4057. RefdSetlFlag string `json:"refd_setl_flag"`
  4058. CvlservFlag string `json:"cvlserv_flag"`
  4059. EmpName string `json:"emp_name"`
  4060. Brdy string `json:"brdy"`
  4061. Naty string `json:"naty"`
  4062. Certno string `json:"certno"`
  4063. DiseCode string `json:"dise_code"`
  4064. FixmedinsCode string `json:"fixmedins_code"`
  4065. DedcHospLv string `json:"dedc_hosp_lv"`
  4066. OpterName string `json:"opter_name"`
  4067. Balc float64 `json:"balc"`
  4068. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4069. PsnCertType string `json:"psn_cert_type"`
  4070. HifobPay float64 `json:"hifob_pay"`
  4071. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4072. HifesPay float64 `json:"hifes_pay"`
  4073. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4074. OptTime string `json:"opt_time"`
  4075. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4076. SetlID string `json:"setl_id"`
  4077. MafPay float64 `json:"maf_pay"`
  4078. PsnName string `json:"psn_name"`
  4079. InsuOptins interface{} `json:"insu_optins"`
  4080. PrefFundPay interface{} `json:"pref_fund_pay"`
  4081. ClrOptins string `json:"clr_optins"`
  4082. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4083. DiseName string `json:"dise_name"`
  4084. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4085. Age float64 `json:"age"`
  4086. DtrtCertType string `json:"dtrt_cert_type"`
  4087. HospLv string `json:"hosp_lv"`
  4088. } `json:"setlinfo"`
  4089. } `json:"output"`
  4090. RefmsgTime string `json:"refmsg_time"`
  4091. RespondTime string `json:"respond_time"`
  4092. Signtype interface{} `json:"signtype"`
  4093. WarnMsg interface{} `json:"warn_msg"`
  4094. }
  4095. type ResultEleven10265 struct {
  4096. Cainfo string `json:"cainfo"`
  4097. ErrMsg string `json:"err_msg"`
  4098. InfRefmsgid string `json:"inf_refmsgid"`
  4099. Infcode string `json:"infcode"`
  4100. Output struct {
  4101. Setlinfo struct {
  4102. SetlTime string `json:"setl_time"`
  4103. CvlservPay float64 `json:"cvlserv_pay"`
  4104. Year string `json:"year"`
  4105. MedType string `json:"med_type"`
  4106. PsnPay float64 `json:"psn_pay"`
  4107. OpterID string `json:"opter_id"`
  4108. Begndate string `json:"begndate"`
  4109. FlxempeFlag string `json:"flxempe_flag"`
  4110. HifmiPay float64 `json:"hifmi_pay"`
  4111. PsnNo string `json:"psn_no"`
  4112. ActPayDedc float64 `json:"act_pay_dedc"`
  4113. MedinsSetlID interface{} `json:"medins_setl_id"`
  4114. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4115. ClrWay string `json:"clr_way"`
  4116. OthPay float64 `json:"oth_pay"`
  4117. Gend string `json:"gend"`
  4118. MdtrtID string `json:"mdtrt_id"`
  4119. AcctPay float64 `json:"acct_pay"`
  4120. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4121. Insutype string `json:"insutype"`
  4122. Invono interface{} `json:"invono"`
  4123. Enddate string `json:"enddate"`
  4124. CashPayamt float64 `json:"cash_payamt"`
  4125. PsnType string `json:"psn_type"`
  4126. FixmedinsName string `json:"fixmedins_name"`
  4127. HifpPay float64 `json:"hifp_pay"`
  4128. NewFlag interface{} `json:"new_flag"`
  4129. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4130. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4131. PayLoc string `json:"pay_loc"`
  4132. ClrType string `json:"clr_type"`
  4133. RefdSetlFlag string `json:"refd_setl_flag"`
  4134. CvlservFlag string `json:"cvlserv_flag"`
  4135. EmpName string `json:"emp_name"`
  4136. Brdy string `json:"brdy"`
  4137. Naty string `json:"naty"`
  4138. Certno string `json:"certno"`
  4139. DiseCode string `json:"dise_code"`
  4140. FixmedinsCode string `json:"fixmedins_code"`
  4141. DedcHospLv string `json:"dedc_hosp_lv"`
  4142. OpterName string `json:"opter_name"`
  4143. Balc float64 `json:"balc"`
  4144. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4145. PsnCertType string `json:"psn_cert_type"`
  4146. HifobPay float64 `json:"hifob_pay"`
  4147. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4148. HifesPay float64 `json:"hifes_pay"`
  4149. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4150. OptTime string `json:"opt_time"`
  4151. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4152. SetlID string `json:"setl_id"`
  4153. MafPay float64 `json:"maf_pay"`
  4154. PsnName string `json:"psn_name"`
  4155. InsuOptins interface{} `json:"insu_optins"`
  4156. PrefFundPay interface{} `json:"pref_fund_pay"`
  4157. ClrOptins string `json:"clr_optins"`
  4158. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4159. DiseName string `json:"dise_name"`
  4160. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4161. Age float64 `json:"age"`
  4162. DtrtCertType string `json:"dtrt_cert_type"`
  4163. HospLv string `json:"hosp_lv"`
  4164. } `json:"setlinfo"`
  4165. } `json:"output"`
  4166. RefmsgTime string `json:"refmsg_time"`
  4167. RespondTime string `json:"respond_time"`
  4168. Signtype interface{} `json:"signtype"`
  4169. WarnMsg interface{} `json:"warn_msg"`
  4170. }
  4171. type ResultTwelve struct {
  4172. Cainfo string `json:"cainfo"`
  4173. ErrMsg string `json:"err_msg"`
  4174. InfRefmsgid string `json:"inf_refmsgid"`
  4175. Infcode int64 `json:"infcode"`
  4176. Output struct {
  4177. MdtrtId string `json:"mdtrt_id"`
  4178. ChrgBchno string `json:"chrg_bchno"`
  4179. PsnNo string `json:"psn_no"`
  4180. } `json:"output"`
  4181. RefmsgTime string `json:"refmsg_time"`
  4182. RespondTime string `json:"respond_time"`
  4183. Signtype interface{} `json:"signtype"`
  4184. WarnMsg interface{} `json:"warn_msg"`
  4185. }
  4186. type ResultThirteen struct {
  4187. ErrMsg string `json:"err_msg"`
  4188. InfRefmsgid string `json:"inf_refmsgid"`
  4189. Infcode int64 `json:"infcode"`
  4190. Output struct {
  4191. Result struct {
  4192. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4193. } `json:"result"`
  4194. } `json:"output"`
  4195. RefmsgTime string `json:"refmsg_time"`
  4196. RespondTime string `json:"respond_time"`
  4197. Signtype interface{} `json:"signtype"`
  4198. WarnInfo interface{} `json:"warn_info"`
  4199. }
  4200. type ResultThirteen10265 struct {
  4201. ErrMsg string `json:"err_msg"`
  4202. InfRefmsgid string `json:"inf_refmsgid"`
  4203. Infcode string `json:"infcode"`
  4204. Output struct {
  4205. Result struct {
  4206. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4207. } `json:"result"`
  4208. } `json:"output"`
  4209. RefmsgTime string `json:"refmsg_time"`
  4210. RespondTime string `json:"respond_time"`
  4211. Signtype interface{} `json:"signtype"`
  4212. WarnInfo interface{} `json:"warn_info"`
  4213. }
  4214. type ResultFourteen struct {
  4215. ErrMsg string `json:"err_msg"`
  4216. InfRefmsgid string `json:"inf_refmsgid"`
  4217. Infcode int64 `json:"infcode"`
  4218. Output struct {
  4219. } `json:"output"`
  4220. RefmsgTime string `json:"refmsg_time"`
  4221. RespondTime string `json:"respond_time"`
  4222. Signtype interface{} `json:"signtype"`
  4223. WarnInfo interface{} `json:"warn_info"`
  4224. }
  4225. type ResultFourteen10265 struct {
  4226. ErrMsg string `json:"err_msg"`
  4227. InfRefmsgid string `json:"inf_refmsgid"`
  4228. Infcode string `json:"infcode"`
  4229. Output struct {
  4230. } `json:"output"`
  4231. RefmsgTime string `json:"refmsg_time"`
  4232. RespondTime string `json:"respond_time"`
  4233. Signtype interface{} `json:"signtype"`
  4234. WarnInfo interface{} `json:"warn_info"`
  4235. }
  4236. type ResultSixteen struct {
  4237. Cainfo string `json:"cainfo"`
  4238. ErrMsg string `json:"err_msg"`
  4239. InfRefmsgid string `json:"inf_refmsgid"`
  4240. Infcode int64 `json:"infcode"`
  4241. Output struct {
  4242. Setldetail []interface{} `json:"setldetail"`
  4243. Setlinfo struct {
  4244. MdtrtID string `json:"mdtrt_id"`
  4245. SetlID string `json:"setl_id"`
  4246. ClrOptins string `json:"clr_optins"`
  4247. SetlTime string `json:"setl_time"`
  4248. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4249. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4250. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4251. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4252. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4253. ActPayDedc float64 `json:"act_pay_dedc"`
  4254. HifpPay float64 `json:"hifp_pay"`
  4255. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4256. Lfpay float64 `json:"selfpay"`
  4257. CvlservPay float64 `json:"cvlserv_pay"`
  4258. HifesPay float64 `json:"hifes_pay"`
  4259. HifmiPay float64 `json:"hifmi_pay"`
  4260. HifobPay float64 `json:"hifob_pay"`
  4261. MafPay float64 `json:"maf_pay"`
  4262. OthPay float64 `json:"oth_pay"`
  4263. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4264. PsnPartAmt float64 `json:"psn_part_amt"`
  4265. AcctPay float64 `json:"acct_pay"`
  4266. Balc float64 `json:"balc"`
  4267. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4268. HospPartAmt float64 `json:"hosp_part_amt"`
  4269. MedinsSetlID string `json:"medins_setl_id"`
  4270. PdnCashPay string `json:"pdn_cash_pay"`
  4271. } `json:"setlinfo"`
  4272. } `json:"output"`
  4273. RefmsgTime string `json:"refmsg_time"`
  4274. RespondTime string `json:"respond_time"`
  4275. Signtype interface{} `json:"signtype"`
  4276. WarnMsg interface{} `json:"warn_msg"`
  4277. }
  4278. type ResultSixteen10265 struct {
  4279. Cainfo string `json:"cainfo"`
  4280. ErrMsg string `json:"err_msg"`
  4281. InfRefmsgid string `json:"inf_refmsgid"`
  4282. Infcode string `json:"infcode"`
  4283. Output struct {
  4284. Setldetail []interface{} `json:"setldetail"`
  4285. Setlinfo struct {
  4286. MdtrtID string `json:"mdtrt_id"`
  4287. SetlID string `json:"setl_id"`
  4288. ClrOptins string `json:"clr_optins"`
  4289. SetlTime string `json:"setl_time"`
  4290. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4291. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4292. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4293. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4294. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4295. ActPayDedc float64 `json:"act_pay_dedc"`
  4296. HifpPay float64 `json:"hifp_pay"`
  4297. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4298. Lfpay float64 `json:"selfpay"`
  4299. CvlservPay float64 `json:"cvlserv_pay"`
  4300. HifesPay float64 `json:"hifes_pay"`
  4301. HifmiPay float64 `json:"hifmi_pay"`
  4302. HifobPay float64 `json:"hifob_pay"`
  4303. MafPay float64 `json:"maf_pay"`
  4304. OthPay float64 `json:"oth_pay"`
  4305. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4306. PsnPartAmt float64 `json:"psn_part_amt"`
  4307. AcctPay float64 `json:"acct_pay"`
  4308. Balc float64 `json:"balc"`
  4309. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4310. HospPartAmt float64 `json:"hosp_part_amt"`
  4311. MedinsSetlID string `json:"medins_setl_id"`
  4312. PdnCashPay string `json:"pdn_cash_pay"`
  4313. } `json:"setlinfo"`
  4314. } `json:"output"`
  4315. RefmsgTime string `json:"refmsg_time"`
  4316. RespondTime string `json:"respond_time"`
  4317. Signtype interface{} `json:"signtype"`
  4318. WarnMsg interface{} `json:"warn_msg"`
  4319. }
  4320. type ResultSeventeen struct {
  4321. ErrMsg string `json:"err_msg"`
  4322. InfRefmsgid string `json:"inf_refmsgid"`
  4323. Infcode int64 `json:"infcode"`
  4324. Output struct {
  4325. SetlListId string `json:"setl_list_id"`
  4326. } `json:"output"`
  4327. RefmsgTime string `json:"refmsg_time"`
  4328. RespondTime string `json:"respond_time"`
  4329. Signtype string `json:"signtype"`
  4330. WarnInfo string `json:"warn_info"`
  4331. }
  4332. type ResultSeventeenOther struct {
  4333. ErrMsg string `json:"err_msg"`
  4334. InfRefmsgid string `json:"inf_refmsgid"`
  4335. Infcode string `json:"infcode"`
  4336. Output struct {
  4337. SetlListId string `json:"setl_list_id"`
  4338. } `json:"output"`
  4339. RefmsgTime string `json:"refmsg_time"`
  4340. RespondTime string `json:"respond_time"`
  4341. Signtype string `json:"signtype"`
  4342. WarnInfo string `json:"warn_info"`
  4343. }
  4344. type Result90991 struct {
  4345. ErrMsg string `json:"err_msg"`
  4346. InfRefmsgid string `json:"inf_refmsgid"`
  4347. Infcode int64 `json:"infcode"`
  4348. Output struct {
  4349. Result struct {
  4350. PsnNo string `json:"psn_no"`
  4351. CardStat string `json:"card_stat"`
  4352. Certno string `json:"certno"`
  4353. PsnName string `json:"psn_name"`
  4354. CheckStat string `json:"check_stat"`
  4355. SscnoCheckStat string `json:"sscno_check_stat"`
  4356. } `json:"result"`
  4357. } `json:"output"`
  4358. RefmsgTime string `json:"refmsg_time"`
  4359. RespondTime string `json:"respond_time"`
  4360. Signtype interface{} `json:"signtype"`
  4361. WarnInfo interface{} `json:"warn_info"`
  4362. }
  4363. type Result90100 struct {
  4364. ErrMsg string `json:"err_msg"`
  4365. InfRefmsgid string `json:"inf_refmsgid"`
  4366. Infcode int64 `json:"infcode"`
  4367. Output struct {
  4368. PoolareaNo string `json:"poolarea_no"`
  4369. PoolareaNoName string `json:"poolarea_no_name"`
  4370. Insutype string `json:"insutype"`
  4371. InsutypeName string `json:"insutype_name"`
  4372. ClctType string `json:"clct_type"`
  4373. ClctTypeName string `json:"clct_type_name"`
  4374. ClctFlag string `json:"clct_flag"`
  4375. ClctFlagName string `json:"clct_flag_name"`
  4376. AccrymBegn string `json:"accrym_begn"`
  4377. AccrymEnd string `json:"accrym_end"`
  4378. ClctTime string `json:"clct_time"`
  4379. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4380. } `json:"output"`
  4381. RefmsgTime string `json:"refmsg_time"`
  4382. RespondTime string `json:"respond_time"`
  4383. Signtype interface{} `json:"signtype"`
  4384. WarnInfo interface{} `json:"warn_info"`
  4385. }
  4386. type Custom struct {
  4387. DetItemFeeSumamt string
  4388. Cut string
  4389. FeedetlSn string
  4390. Price string
  4391. MedListCodg string
  4392. Type int64
  4393. AdviceId int64
  4394. ProjectId int64
  4395. ItemId int64
  4396. }
  4397. type Result5301 struct {
  4398. ErrMsg string `json:"err_msg"`
  4399. InfRefmsgid string `json:"inf_refmsgid"`
  4400. Infcode int64 `json:"infcode"`
  4401. Output struct {
  4402. Result []struct {
  4403. OpspDiseCode string `json:"opsp_dise_code"`
  4404. OpspDiseName string `json:"opsp_dise_name"`
  4405. Begndate string `json:"begndate"`
  4406. Enddate string `json:"enddate"`
  4407. } `json:"feedetail"`
  4408. } `json:"output"`
  4409. RefmsgTime string `json:"refmsg_time"`
  4410. RespondTime string `json:"respond_time"`
  4411. Signtype interface{} `json:"signtype"`
  4412. WarnInfo interface{} `json:"warn_info"`
  4413. }
  4414. type Result5301For10265 struct {
  4415. ErrMsg string `json:"err_msg"`
  4416. InfRefmsgid string `json:"inf_refmsgid"`
  4417. Infcode string `json:"infcode"`
  4418. Output struct {
  4419. Result []struct {
  4420. OpspDiseCode string `json:"opsp_dise_code"`
  4421. OpspDiseName string `json:"opsp_dise_name"`
  4422. Begndate string `json:"begndate"`
  4423. Enddate string `json:"enddate"`
  4424. } `json:"feedetail"`
  4425. } `json:"output"`
  4426. RefmsgTime string `json:"refmsg_time"`
  4427. RespondTime string `json:"respond_time"`
  4428. Signtype interface{} `json:"signtype"`
  4429. WarnInfo interface{} `json:"warn_info"`
  4430. }
  4431. //获取个人信息----挂号-----上传就诊信息
  4432. func (c *HisApiController) GetRegisterInfo() {
  4433. id, _ := c.GetInt64("id")
  4434. record_time := c.GetString("record_time")
  4435. settlementValue, _ := c.GetInt64("settlement_value")
  4436. medical_insurance_card := c.GetString("medical_insurance_card")
  4437. name := c.GetString("name")
  4438. id_card_type, _ := c.GetInt64("id_card_type")
  4439. certificates, _ := c.GetInt64("certificates")
  4440. medical_care, _ := c.GetInt64("medical_care")
  4441. birthday := c.GetString("birthday")
  4442. id_card := c.GetString("id_card")
  4443. register_type, _ := c.GetInt64("register")
  4444. doctor, _ := c.GetInt64("doctor")
  4445. department, _ := c.GetInt64("department")
  4446. gender, _ := c.GetInt64("sex")
  4447. registration_fee, _ := c.GetFloat("registration_fee")
  4448. medical_expenses, _ := c.GetFloat("medical_expenses")
  4449. social_type, _ := c.GetInt64("social_type")
  4450. med_type := c.GetString("social_type")
  4451. admin_user_id, _ := c.GetInt64("admin_user_id")
  4452. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4453. timeLayout := "2006-01-02"
  4454. loc, _ := time.LoadLocation("Local")
  4455. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4456. birthUnix := birthdays.Unix()
  4457. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4458. if err != nil {
  4459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4460. return
  4461. }
  4462. recordDateTime := theTime.Unix()
  4463. adminInfo := c.GetAdminUserInfo()
  4464. var patient service.Patients
  4465. if id == 0 {
  4466. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4467. } else {
  4468. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4469. }
  4470. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4471. if patientPrescription.ID == 0 {
  4472. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4473. }
  4474. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4475. if patient.ID == 0 {
  4476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4477. return
  4478. }
  4479. if len(patient.IdCardNo) == 0 {
  4480. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4481. return
  4482. }
  4483. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4484. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4485. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4486. //就诊结算未完成,不能进行二次挂号
  4487. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4488. if len(his) >= 1 {
  4489. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4490. if len(his) >= 1 && order.ID == 0 {
  4491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4492. return
  4493. }
  4494. }
  4495. //var register_log string
  4496. if config.IsOpen == 1 {
  4497. var res ResultTwo
  4498. var res10265 ResultTwo10265
  4499. var PsnNo string
  4500. var PsnCertType string
  4501. var Certno string
  4502. var PsnName string
  4503. var Gend string
  4504. var Naty string
  4505. var Brdy string
  4506. var Age float64
  4507. var infoStr string
  4508. var idetinfoStr string
  4509. var infocode int64
  4510. var verify_number string
  4511. fmt.Println(verify_number)
  4512. if miConfig.MdtrtareaAdmvs == "421300" {
  4513. psn_info, _ := service.GetPsnByPatientId(id)
  4514. PsnNo = psn_info.PsnNo
  4515. PsnCertType = psn_info.PsnCertType
  4516. Certno = psn_info.Certno
  4517. PsnName = psn_info.PsnName
  4518. Gend = psn_info.Gend
  4519. Naty = psn_info.Naty
  4520. Brdy = psn_info.Brdy
  4521. Age = psn_info.Age
  4522. infoStr = psn_info.Insuinfo
  4523. idetinfoStr = psn_info.Idetinfo
  4524. infocode = 0
  4525. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4526. psn_info, _ := service.GetPsnByPatientId(id)
  4527. PsnNo = psn_info.PsnNo
  4528. PsnCertType = psn_info.PsnCertType
  4529. Certno = psn_info.Certno
  4530. PsnName = psn_info.PsnName
  4531. Gend = psn_info.Gend
  4532. Naty = psn_info.Naty
  4533. Brdy = psn_info.Brdy
  4534. Age = psn_info.Age
  4535. infoStr = psn_info.Insuinfo
  4536. idetinfoStr = psn_info.Idetinfo
  4537. infocode = 0
  4538. verify_number = psn_info.VerifyNumber
  4539. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4540. psn_info, _ := service.GetPsnByPatientId(id)
  4541. PsnNo = psn_info.PsnNo
  4542. PsnCertType = psn_info.PsnCertType
  4543. Certno = psn_info.Certno
  4544. PsnName = psn_info.PsnName
  4545. Gend = psn_info.Gend
  4546. Naty = psn_info.Naty
  4547. Brdy = psn_info.Brdy
  4548. Age = psn_info.Age
  4549. infoStr = psn_info.Insuinfo
  4550. idetinfoStr = psn_info.Idetinfo
  4551. infocode = 0
  4552. verify_number = psn_info.VerifyNumber
  4553. } else {
  4554. var result string
  4555. var requestLog string
  4556. if miConfig.UserOrgId == 10138 {
  4557. 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)
  4558. } else {
  4559. 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)
  4560. }
  4561. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4562. if miConfig.Code == "H15049901371" {
  4563. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4564. utils.ErrorLog("解析失败:%v", err)
  4565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. res.ErrMsg = res10265.ErrMsg
  4569. res.Output = res10265.Output
  4570. res.InfRefmsgid = res10265.InfRefmsgid
  4571. } else {
  4572. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4573. utils.ErrorLog("解析失败:%v", err)
  4574. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4575. return
  4576. }
  4577. }
  4578. PsnNo = res.Output.Baseinfo.PsnNo
  4579. PsnCertType = res.Output.Baseinfo.PsnCertType
  4580. Certno = res.Output.Baseinfo.Certno
  4581. PsnName = res.Output.Baseinfo.PsnName
  4582. Gend = res.Output.Baseinfo.Gend
  4583. Naty = res.Output.Baseinfo.Naty
  4584. Brdy = res.Output.Baseinfo.Brdy
  4585. Age = res.Output.Baseinfo.Age
  4586. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4587. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4588. infoStr = string(Iinfos)
  4589. idetinfoStr = string(Idetinfos)
  4590. if miConfig.Code == "H15049901371" {
  4591. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4592. } else {
  4593. infocode = res.Infcode
  4594. }
  4595. }
  4596. if infocode == 0 {
  4597. his := models.VMHisPatient{
  4598. Name: name,
  4599. Gender: gender,
  4600. Birthday: birthUnix,
  4601. MedicalTreatmentType: medical_care,
  4602. IdType: certificates,
  4603. IdCardNo: id_card,
  4604. BalanceAccountsType: settlementValue,
  4605. SocialType: social_type,
  4606. MedicalInsuranceNumber: medical_insurance_card,
  4607. RegisterType: register_type,
  4608. RegisterCost: registration_fee,
  4609. TreatmentCost: medical_expenses,
  4610. Status: 1,
  4611. Ctime: time.Now().Unix(),
  4612. Mtime: time.Now().Unix(),
  4613. PsnNo: PsnNo,
  4614. PsnCertType: PsnCertType,
  4615. Certno: Certno,
  4616. PsnName: PsnName,
  4617. Gend: Gend,
  4618. Naty: Naty,
  4619. Brdy: Brdy,
  4620. Age: Age,
  4621. Iinfo: infoStr,
  4622. Idetinfo: idetinfoStr,
  4623. PatientId: patient.ID,
  4624. RecordDate: theTime.Unix(),
  4625. UserOrgId: adminInfo.CurrentOrgId,
  4626. AdminUserId: admin_user_id,
  4627. IsReturn: 1,
  4628. IdCardType: id_card_type,
  4629. Doctor: doctor,
  4630. Departments: department,
  4631. }
  4632. timestamp := time.Now().Unix()
  4633. tempTime := time.Unix(timestamp, 0)
  4634. timeFormat := tempTime.Format("20060102150405")
  4635. chrgBchno := rand.Intn(100000) + 10000
  4636. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4637. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4638. department, _ := service.GetDepartMentDetail(department)
  4639. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4640. IdCardNo := ""
  4641. if id_card_type == 1 {
  4642. // IdCardNo = medical_insurance_card
  4643. IdCardNo = patient.IdCardNo
  4644. } else {
  4645. IdCardNo = patient.IdCardNo
  4646. }
  4647. var rf []*ResultFive
  4648. json.Unmarshal([]byte(his.Iinfo), &rf)
  4649. var insutypes []*ResultFive
  4650. var insutype string
  4651. var insuplc_admdvs_temp string
  4652. var is390 int = 0
  4653. var is310 int = 0
  4654. for _, item := range rf {
  4655. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4656. insutypes = append(insutypes, item)
  4657. }
  4658. }
  4659. if len(insutypes) == 1 {
  4660. insutype = insutypes[0].Insutype
  4661. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4662. } else {
  4663. for _, i := range insutypes {
  4664. if i.Insutype == "390" {
  4665. is390 = 1
  4666. }
  4667. if i.Insutype == "310" {
  4668. is310 = 1
  4669. }
  4670. }
  4671. }
  4672. if is390 == 1 {
  4673. insutype = "390"
  4674. }
  4675. if is310 == 1 {
  4676. insutype = "310"
  4677. }
  4678. if len(insutypes) == 0 {
  4679. insutype = "310"
  4680. }
  4681. if len(insutypes) == 2 {
  4682. insutype = med_type
  4683. }
  4684. if len(med_type) > 0 {
  4685. insutype = med_type
  4686. }
  4687. //for _, item := range rf {
  4688. // if item.Insutype == insutype {
  4689. // insuplc_admdvs = item.InsuplcAdmdvs
  4690. // }
  4691. //}
  4692. var infocode int64
  4693. var resThree ResultThree
  4694. var resThree10265 ResultThree10265
  4695. if len(insuplc_admdvs) == 0 {
  4696. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4697. } else {
  4698. insuplc_admdvs_temp = insuplc_admdvs
  4699. }
  4700. if miConfig.MdtrtareaAdmvs == "421300" {
  4701. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4702. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4703. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4704. "&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
  4705. resp, requestErr := http.Get(api)
  4706. if requestErr != nil {
  4707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4708. return
  4709. }
  4710. body, ioErr := ioutil.ReadAll(resp.Body)
  4711. if ioErr != nil {
  4712. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4714. return
  4715. }
  4716. var respJSON map[string]interface{}
  4717. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4718. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4720. return
  4721. }
  4722. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4723. result, _ := json.Marshal(respJSON)
  4724. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4725. utils.ErrorLog("解析失败:%v", err)
  4726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4727. return
  4728. }
  4729. infocode = resThree.Infcode
  4730. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4731. psn_info, _ := service.GetPsnByPatientId(id)
  4732. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4733. var cert_no string
  4734. if id_card_type == 3 {
  4735. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4736. cert_no = IdCardNo
  4737. } else if id_card_type == 4 {
  4738. cert_no = IdCardNo
  4739. psn_info.VerifyNumber = psn_info.VerifyNumber
  4740. } else {
  4741. bas := strings.Split(psn_info.CardInfo, "|")
  4742. cert_no = bas[2]
  4743. }
  4744. var api string
  4745. if miConfig.MdtrtareaAdmvs == "320921" {
  4746. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4747. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4748. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4749. } else {
  4750. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4751. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4752. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4753. }
  4754. resp, requestErr := http.Get(api)
  4755. if requestErr != nil {
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. body, ioErr := ioutil.ReadAll(resp.Body)
  4760. if ioErr != nil {
  4761. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4763. return
  4764. }
  4765. var respJSON map[string]interface{}
  4766. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4767. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4769. return
  4770. }
  4771. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4772. result, _ := json.Marshal(respJSON)
  4773. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4774. utils.ErrorLog("解析失败:%v", err)
  4775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4776. return
  4777. }
  4778. resThree.ErrMsg = resThree10265.ErrMsg
  4779. resThree.Output = resThree10265.Output
  4780. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4781. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4782. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4783. psn_info, _ := service.GetPsnByPatientId(id)
  4784. var cert_no string
  4785. if id_card_type == 1 {
  4786. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4787. }
  4788. fmt.Println(cert_no)
  4789. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, 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)
  4790. saveLog(result, requestLog, "2201", "挂号")
  4791. if miConfig.Code == "H15049901371" {
  4792. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4793. utils.ErrorLog("解析失败:%v", err)
  4794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4795. return
  4796. }
  4797. resThree.ErrMsg = resThree10265.ErrMsg
  4798. resThree.Output = resThree10265.Output
  4799. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4800. } else {
  4801. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4802. utils.ErrorLog("解析失败:%v", err)
  4803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4804. return
  4805. }
  4806. }
  4807. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4808. } else {
  4809. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4810. saveLog(result, requestLog, "2201A", "挂号")
  4811. if miConfig.Code == "H15049901371" {
  4812. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4813. utils.ErrorLog("解析失败:%v", err)
  4814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4815. return
  4816. }
  4817. resThree.ErrMsg = resThree10265.ErrMsg
  4818. resThree.Output = resThree10265.Output
  4819. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4820. } else {
  4821. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4822. utils.ErrorLog("解析失败:%v", err)
  4823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4824. return
  4825. }
  4826. }
  4827. if miConfig.Code == "H15049901371" {
  4828. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4829. } else {
  4830. infocode = resThree.Infcode
  4831. }
  4832. }
  4833. if infocode != 0 {
  4834. adminUser := c.GetAdminUserInfo()
  4835. errlog := &models.HisOrderError{
  4836. UserOrgId: adminUser.CurrentOrgId,
  4837. Ctime: time.Now().Unix(),
  4838. Mtime: time.Now().Unix(),
  4839. ErrMsg: resThree.ErrMsg,
  4840. Status: 1,
  4841. PatientId: id,
  4842. RecordTime: recordDateTime,
  4843. Stage: 2,
  4844. }
  4845. service.CreateErrMsgLog(errlog)
  4846. c.ServeSuccessJSON(map[string]interface{}{
  4847. "failed_code": -10,
  4848. "msg": resThree.ErrMsg,
  4849. })
  4850. return
  4851. }
  4852. his.Number = resThree.Output.Data.MdtrtID
  4853. his.PsnNo = resThree.Output.Data.PsnNo
  4854. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4855. his.IdCardNo = patient.IdCardNo
  4856. his.PhoneNumber = patient.Phone
  4857. his.UserOrgId = adminInfo.CurrentOrgId
  4858. his.Insutype = insutype
  4859. his.Ctime = time.Now().Unix()
  4860. his.Mtime = time.Now().Unix()
  4861. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4862. his.Status = 1
  4863. service.UpdateHisPatientStatus(&his)
  4864. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4865. c.ServeSuccessJSON(map[string]interface{}{
  4866. "his_info": his,
  4867. })
  4868. } else {
  4869. adminUser := c.GetAdminUserInfo()
  4870. errlog := &models.HisOrderError{
  4871. UserOrgId: adminUser.CurrentOrgId,
  4872. Ctime: time.Now().Unix(),
  4873. Mtime: time.Now().Unix(),
  4874. ErrMsg: res.ErrMsg,
  4875. Status: 1,
  4876. PatientId: id,
  4877. RecordTime: recordDateTime,
  4878. Stage: 1,
  4879. }
  4880. service.CreateErrMsgLog(errlog)
  4881. c.ServeSuccessJSON(map[string]interface{}{
  4882. "failed_code": -10,
  4883. "msg": res.ErrMsg,
  4884. })
  4885. return
  4886. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4887. }
  4888. }
  4889. }
  4890. //上传明细----预结算----确认订单
  4891. func (c *HisApiController) GetUploadInfo() {
  4892. id, _ := c.GetInt64("id")
  4893. record_time := c.GetString("record_time")
  4894. his_patient_id, _ := c.GetInt64("his_patient_id")
  4895. order_id, _ := c.GetInt64("order_id")
  4896. pay_way, _ := c.GetInt64("pay_way")
  4897. pay_price, _ := c.GetFloat("pay_price")
  4898. pay_card_no := c.GetString("pay_card_no")
  4899. token := c.GetString("token")
  4900. discount_price, _ := c.GetFloat("discount_price")
  4901. preferential_price, _ := c.GetFloat("preferential_price")
  4902. reality_price, _ := c.GetFloat("reality_price")
  4903. found_price, _ := c.GetFloat("found_price")
  4904. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4905. private_price, _ := c.GetFloat("private_price")
  4906. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4907. admin_user_id, _ := c.GetInt64("admin_user_id")
  4908. fapiao_code := c.GetString("fapiao_code")
  4909. fapiao_number := c.GetString("fapiao_number")
  4910. diagnosis_id := c.GetString("diagnosis")
  4911. sick_type, _ := c.GetInt64("sick_type")
  4912. reg_type, _ := c.GetInt64("p_type")
  4913. begin_time := c.GetString("begin_time")
  4914. id_str := c.GetString("ids")
  4915. ids_arr := strings.Split(id_str, ",")
  4916. timeLayout := "2006-01-02"
  4917. loc, _ := time.LoadLocation("Local")
  4918. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4919. if err != nil {
  4920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4921. return
  4922. }
  4923. recordDateTime := theTime.Unix()
  4924. adminUser := c.GetAdminUserInfo()
  4925. var tempOrder models.HisOrder
  4926. tempOrder, _ = service.GetHisOrderByID(order_id)
  4927. var prescriptions []*models.HisPrescription
  4928. var start_time int64
  4929. var end_time int64
  4930. //押金模块
  4931. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4932. tmp_decimal := c.GetString("tmp_decimal")
  4933. var decimal float64 //本次使用的押金
  4934. var errmsg error
  4935. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4936. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4937. return
  4938. }
  4939. if len(tmp_decimal) > 0 {
  4940. if tmp_decimal[0] == 45 {
  4941. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4942. return
  4943. }
  4944. }
  4945. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4946. fmt.Println(errs)
  4947. decimal = tt
  4948. //if adminUser.CurrentOrgId == 10106{
  4949. // if len(fapiao_code) == 0{
  4950. // fapiao_code = "144072080589"
  4951. // }
  4952. // if len(fapiao_number) == 0{
  4953. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4954. // if order.ID == 0{
  4955. // fapiao_number = "00001520"
  4956. // }else{
  4957. // //fapiao_code = "00001520"
  4958. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4959. // var zero string
  4960. // if fpNumber >= 1000{
  4961. // zero = "0000" + strconv.Itoa(fpNumber)
  4962. // }else if fpNumber >= 10000{
  4963. // zero = "000" + strconv.Itoa(fpNumber)
  4964. // } else if fpNumber >= 100000{
  4965. // zero = "00" + strconv.Itoa(fpNumber)
  4966. // } else if fpNumber >= 1000000{
  4967. // zero = "0" + strconv.Itoa(fpNumber)
  4968. // }else {
  4969. // zero = strconv.Itoa(fpNumber)
  4970. // }
  4971. // fapiao_number = zero
  4972. // }
  4973. // }
  4974. //}
  4975. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4976. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4977. var patientPrescription models.HisPrescriptionInfo
  4978. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4979. if patientPrescription.ID == 0 {
  4980. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4981. }
  4982. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4983. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4984. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4985. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4986. var config []*models.HisXtDiagnoseConfig
  4987. for _, item := range diagnosis_ids {
  4988. id, _ := strconv.ParseInt(item, 10, 64)
  4989. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4990. config = append(config, &diagnosisConfig)
  4991. }
  4992. sickConfig, _ := service.FindSickById(sick_type)
  4993. //if tempOrder.ID == 0 {
  4994. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4995. //}
  4996. if tempOrder.ID == 0 {
  4997. var result string
  4998. var requestLog string
  4999. var res2 ResultSix
  5000. var ressix10265 ResultSix10265
  5001. if miConfig.MdtrtareaAdmvs == "421300" {
  5002. data := make(map[string]interface{})
  5003. client := &http.Client{}
  5004. data["psn_no"] = his.PsnNo
  5005. data["mdtrt_id"] = his.Number
  5006. data["opter"] = roles.UserName
  5007. data["org_name"] = miConfig.OrgName
  5008. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5009. data["doctor_id"] = doctor_info.DoctorNumber
  5010. data["doctor_name"] = doctor_info.UserName
  5011. data["department"] = department.Name
  5012. data["fixmedins_code"] = miConfig.Code
  5013. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5014. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5015. data["secret_key"] = miConfig.SecretKey
  5016. data["sick_code"] = sickConfig.CountryCode
  5017. data["sick_name"] = sickConfig.ClassName
  5018. data["dept"] = strconv.FormatInt(department.ID, 10)
  5019. data["config"] = config
  5020. data["begin_time"] = begin_time
  5021. bytesData, _ := json.Marshal(data)
  5022. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5023. resp, _ := client.Do(req)
  5024. defer resp.Body.Close()
  5025. body, ioErr := ioutil.ReadAll(resp.Body)
  5026. if ioErr != nil {
  5027. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. return
  5030. }
  5031. var respJSON map[string]interface{}
  5032. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5033. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5035. return
  5036. }
  5037. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5038. userJSONBytes, _ := json.Marshal(respJSON)
  5039. fmt.Println("log")
  5040. fmt.Println(string(userJSONBytes))
  5041. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5042. utils.ErrorLog("解析失败:%v", err)
  5043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5044. return
  5045. }
  5046. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5047. //江苏地区国家医保医疗类别
  5048. //职工透析:医疗类别选特殊情况门诊9933
  5049. //居民血透门慢: 医疗类别选门诊慢病1402
  5050. //var med_type string
  5051. //if his.Insutype == "310" {
  5052. // if reg_type == 14 {
  5053. // med_type = "9933"
  5054. // } else if reg_type == 11 {
  5055. // med_type = "11"
  5056. //
  5057. // }
  5058. //} else if his.Insutype == "390" {
  5059. // if reg_type == 14 {
  5060. // med_type = "1402"
  5061. // } else if reg_type == 11 {
  5062. // med_type = "11"
  5063. // }
  5064. //}
  5065. data := make(map[string]interface{})
  5066. client := &http.Client{}
  5067. data["psn_no"] = his.PsnNo
  5068. data["mdtrt_id"] = his.Number
  5069. data["doctor"] = roles.UserName
  5070. data["department"] = department.Name
  5071. data["org_name"] = miConfig.OrgName
  5072. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5073. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5074. data["fixmedins_code"] = miConfig.Code
  5075. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5076. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5077. data["secret_key"] = miConfig.SecretKey
  5078. data["sick_code"] = sickConfig.CountryCode
  5079. data["sick_name"] = sickConfig.ClassName
  5080. data["url"] = miConfig.Url
  5081. data["ak"] = miConfig.AccessKey
  5082. data["begin_time"] = begin_time
  5083. data["cainfo"] = miConfig.Cainfo
  5084. data["dept"] = strconv.FormatInt(department.ID, 10)
  5085. data["config"] = config
  5086. bytesData, _ := json.Marshal(data)
  5087. var req *http.Request
  5088. if miConfig.MdtrtareaAdmvs == "320921" {
  5089. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5090. //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 +
  5091. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5092. } else {
  5093. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5094. }
  5095. resp, _ := client.Do(req)
  5096. defer resp.Body.Close()
  5097. body, ioErr := ioutil.ReadAll(resp.Body)
  5098. if ioErr != nil {
  5099. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. return
  5102. }
  5103. var respJSON map[string]interface{}
  5104. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5105. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5107. return
  5108. }
  5109. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5110. userJSONBytes, _ := json.Marshal(respJSON)
  5111. fmt.Println("log")
  5112. fmt.Println(string(userJSONBytes))
  5113. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5114. utils.ErrorLog("解析失败:%v", err)
  5115. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5116. return
  5117. }
  5118. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5119. res2.Output = ressix10265.Output
  5120. res2.ErrMsg = ressix10265.ErrMsg
  5121. res2.Cainfo = ressix10265.Cainfo
  5122. res2.WarnMsg = ressix10265.WarnMsg
  5123. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5124. res2.Infcode = infocode
  5125. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5126. 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)
  5127. saveLog(result, requestLog, "2203", "上传就诊信息")
  5128. var respJSON2 map[string]interface{}
  5129. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5130. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5132. return
  5133. }
  5134. userJSONBytes2, _ := json.Marshal(respJSON2)
  5135. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5136. utils.ErrorLog("解析失败:%v", err)
  5137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5138. return
  5139. }
  5140. } else {
  5141. if miConfig.MdtrtareaAdmvs == "440781" { //
  5142. 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)
  5143. } else {
  5144. if miConfig.Code == "H15049901371" {
  5145. //赤峰地区国家医保医疗类别
  5146. //职工透析:医疗类别选特殊情况门诊990502
  5147. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5148. var med_type string
  5149. if his.Insutype == "390" {
  5150. if reg_type == 14 {
  5151. med_type = "9933"
  5152. } else if reg_type == 11 {
  5153. med_type = "11"
  5154. }
  5155. } else if his.Insutype == "310" {
  5156. if reg_type == 14 {
  5157. med_type = "990502"
  5158. } else if reg_type == 11 {
  5159. med_type = "11"
  5160. }
  5161. }
  5162. 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)
  5163. } else {
  5164. 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)
  5165. }
  5166. }
  5167. saveLog(result, requestLog, "2203", "上传就诊信息")
  5168. var respJSON2 map[string]interface{}
  5169. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5170. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5171. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5172. return
  5173. }
  5174. userJSONBytes2, _ := json.Marshal(respJSON2)
  5175. if miConfig.Code == "H15049901371" {
  5176. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5177. utils.ErrorLog("解析失败:%v", err)
  5178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5179. return
  5180. }
  5181. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5182. res2.Output = ressix10265.Output
  5183. res2.ErrMsg = ressix10265.ErrMsg
  5184. res2.Cainfo = ressix10265.Cainfo
  5185. res2.WarnMsg = ressix10265.WarnMsg
  5186. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5187. res2.Infcode = infocode
  5188. } else {
  5189. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5190. utils.ErrorLog("解析失败:%v", err)
  5191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5192. return
  5193. }
  5194. }
  5195. }
  5196. if res2.Infcode != 0 {
  5197. adminUser := c.GetAdminUserInfo()
  5198. errlog := &models.HisOrderError{
  5199. UserOrgId: adminUser.CurrentOrgId,
  5200. Ctime: time.Now().Unix(),
  5201. Mtime: time.Now().Unix(),
  5202. ErrMsg: res2.ErrMsg,
  5203. Status: 1,
  5204. PatientId: id,
  5205. RecordTime: recordDateTime,
  5206. Stage: 3,
  5207. }
  5208. service.CreateErrMsgLog(errlog)
  5209. c.ServeSuccessJSON(map[string]interface{}{
  5210. "failed_code": -10,
  5211. "msg": res2.ErrMsg,
  5212. })
  5213. return
  5214. } else {
  5215. his.Diagnosis = diagnosis_id
  5216. his.SickType = sickConfig.ID
  5217. //var p_type int64
  5218. //if reg_type == 1111 || reg_type == 1112 {
  5219. // p_type = 11
  5220. //
  5221. //}
  5222. his.PType = fmt.Sprintf("%d", reg_type)
  5223. service.UpdateHisPatientThree(&his)
  5224. data := make(map[string]interface{})
  5225. if settle_accounts_type == 1 { //日结
  5226. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5227. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5228. } else {
  5229. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5230. }
  5231. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5232. data["pre"] = prescriptions
  5233. } else { //月结
  5234. start_time_str := c.GetString("start_time")
  5235. end_time_str := c.GetString("end_time")
  5236. timeLayout := "2006-01-02"
  5237. loc, _ := time.LoadLocation("Local")
  5238. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5239. if err != nil {
  5240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5241. return
  5242. }
  5243. recordStartTime := theStartTime.Unix()
  5244. start_time = recordStartTime
  5245. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5246. if err != nil {
  5247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5248. return
  5249. }
  5250. recordEndTime := theEndTime.Unix()
  5251. end_time = recordEndTime
  5252. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5253. data["pre"] = prescriptions
  5254. }
  5255. timestamp := time.Now().Unix()
  5256. tempTime := time.Unix(timestamp, 0)
  5257. timeFormat := tempTime.Format("20060102150405")
  5258. chrgBchno := rand.Intn(100000) + 10000
  5259. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5260. strconv.FormatInt(his.PatientId, 10)
  5261. client := &http.Client{}
  5262. data["psn_no"] = his.PsnNo
  5263. data["mdtrt_id"] = his.Number
  5264. data["chrg_bchno"] = chrg_bchno
  5265. data["org_name"] = miConfig.OrgName
  5266. data["doctor"] = doctor_info.UserName
  5267. data["doctor_id"] = doctor_info.DoctorNumber
  5268. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5269. data["fixmedins_code"] = miConfig.Code
  5270. data["opter"] = roles.UserName
  5271. data["dept_code"] = department.Number
  5272. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5273. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5274. data["secret_key"] = miConfig.SecretKey
  5275. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5276. data["url"] = miConfig.Url
  5277. data["ak"] = miConfig.AccessKey
  5278. data["new_doctor_name"] = patientPrescription.Doctor
  5279. data["diag_code"] = sickConfig.CountryCode
  5280. data["cainfo"] = miConfig.Cainfo
  5281. var ids []int64
  5282. for _, item := range prescriptions {
  5283. ids = append(ids, item.ID)
  5284. }
  5285. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5286. if config.IsOpen == 1 { //对接了医保,走医保流程
  5287. var res ResultFour
  5288. var resFour10265 ResultFour10265
  5289. if miConfig.MdtrtareaAdmvs == "421300" {
  5290. bytesData, _ := json.Marshal(data)
  5291. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5292. resp, _ := client.Do(req)
  5293. defer resp.Body.Close()
  5294. body, ioErr := ioutil.ReadAll(resp.Body)
  5295. if ioErr != nil {
  5296. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5298. return
  5299. }
  5300. var respJSON map[string]interface{}
  5301. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5302. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5304. return
  5305. }
  5306. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5307. userJSONBytes, _ := json.Marshal(respJSON)
  5308. fmt.Println("log")
  5309. fmt.Println(string(userJSONBytes))
  5310. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5311. utils.ErrorLog("解析失败:%v", err)
  5312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5313. return
  5314. }
  5315. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5316. bytesData, _ := json.Marshal(data)
  5317. var req *http.Request
  5318. if miConfig.MdtrtareaAdmvs == "320921" {
  5319. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5320. } else {
  5321. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5322. }
  5323. resp, _ := client.Do(req)
  5324. defer resp.Body.Close()
  5325. body, ioErr := ioutil.ReadAll(resp.Body)
  5326. if ioErr != nil {
  5327. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5329. return
  5330. }
  5331. var respJSON map[string]interface{}
  5332. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5333. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5335. return
  5336. }
  5337. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5338. userJSONBytes, _ := json.Marshal(respJSON)
  5339. fmt.Println("log")
  5340. fmt.Println(string(userJSONBytes))
  5341. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5342. utils.ErrorLog("解析失败:%v", err)
  5343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5344. return
  5345. }
  5346. res.InfRefmsgid = resFour10265.InfRefmsgid
  5347. res.Output = resFour10265.Output
  5348. res.ErrMsg = resFour10265.ErrMsg
  5349. res.Cainfo = resFour10265.Cainfo
  5350. res.WarnMsg = resFour10265.WarnMsg
  5351. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5352. res.Infcode = infocode
  5353. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5354. 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)
  5355. var dat map[string]interface{}
  5356. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5357. fmt.Println(dat)
  5358. } else {
  5359. fmt.Println(err)
  5360. }
  5361. saveLog(result, request_log, "2204", "上传费用明细")
  5362. userJSONBytes, _ := json.Marshal(dat)
  5363. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5364. utils.ErrorLog("解析失败:%v", err)
  5365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5366. return
  5367. }
  5368. res.InfRefmsgid = resFour10265.InfRefmsgid
  5369. res.Output = resFour10265.Output
  5370. res.ErrMsg = resFour10265.ErrMsg
  5371. res.Cainfo = resFour10265.Cainfo
  5372. res.WarnMsg = resFour10265.WarnMsg
  5373. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5374. res.Infcode = infocode
  5375. } else {
  5376. if miConfig.Code == "H15049901371" {
  5377. 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)
  5378. var dat map[string]interface{}
  5379. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5380. fmt.Println(dat)
  5381. } else {
  5382. fmt.Println(err)
  5383. }
  5384. saveLog(result, request_log, "2204", "上传费用明细")
  5385. userJSONBytes, _ := json.Marshal(dat)
  5386. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5387. utils.ErrorLog("解析失败:%v", err)
  5388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5389. return
  5390. }
  5391. res.InfRefmsgid = resFour10265.InfRefmsgid
  5392. res.Output = resFour10265.Output
  5393. res.ErrMsg = resFour10265.ErrMsg
  5394. res.Cainfo = resFour10265.Cainfo
  5395. res.WarnMsg = resFour10265.WarnMsg
  5396. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5397. res.Infcode = infocode
  5398. } else {
  5399. 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)
  5400. var dat map[string]interface{}
  5401. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5402. fmt.Println(dat)
  5403. } else {
  5404. fmt.Println(err)
  5405. }
  5406. saveLog(result, request_log, "2204", "上传费用明细")
  5407. userJSONBytes, _ := json.Marshal(dat)
  5408. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5409. utils.ErrorLog("解析失败:%v", err)
  5410. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5411. return
  5412. }
  5413. }
  5414. }
  5415. if res.Infcode == 0 {
  5416. order := &models.HisOrder{
  5417. UserOrgId: adminUser.CurrentOrgId,
  5418. HisPatientId: his.ID,
  5419. PatientId: his.PatientId,
  5420. SettleAccountsDate: recordDateTime,
  5421. MdtrtId: his.Number,
  5422. PsnNo: his.PsnNo,
  5423. MedType: strconv.FormatInt(reg_type, 10),
  5424. Ctime: time.Now().Unix(),
  5425. Mtime: time.Now().Unix(),
  5426. Status: 1,
  5427. Number: chrg_bchno,
  5428. Infcode: res.Infcode,
  5429. WarnMsg: res.WarnMsg,
  5430. Cainfo: res.Cainfo,
  5431. ErrMsg: res.ErrMsg,
  5432. RespondTime: res.RefmsgTime,
  5433. InfRefmsgid: res.InfRefmsgid,
  5434. OrderStatus: 1,
  5435. PayWay: pay_way,
  5436. PayPrice: pay_price,
  5437. PayCardNo: pay_card_no,
  5438. DiscountPrice: discount_price,
  5439. PreferentialPrice: preferential_price,
  5440. RealityPrice: reality_price,
  5441. FoundPrice: found_price,
  5442. MedicalInsurancePrice: medical_insurance_price,
  5443. PrivatePrice: private_price,
  5444. IsMedicineInsurance: 1,
  5445. SettleType: settle_accounts_type,
  5446. SettleStartTime: start_time,
  5447. SettleEndTime: end_time,
  5448. Creator: roles.AdminUserId,
  5449. Modify: roles.AdminUserId,
  5450. FaPiaoNumber: fapiao_number,
  5451. FaPiaoCode: fapiao_code,
  5452. PType: 2,
  5453. Diagnosis: diagnosis_id,
  5454. }
  5455. err = service.CreateOrder(order)
  5456. if err != nil {
  5457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5458. return
  5459. }
  5460. for _, item := range res.Output.Result {
  5461. temp := strings.Split(item.FeedetlSn, "-")
  5462. var advice_id int64 = 0
  5463. var project_id int64 = 0
  5464. var types int64 = 0
  5465. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5466. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5467. if temp[1] == "1" {
  5468. advice_id = id
  5469. project_id = 0
  5470. } else if temp[1] == "2" {
  5471. advice_id = 0
  5472. project_id = id
  5473. }
  5474. info := &models.HisOrderInfo{
  5475. OrderNumber: order.Number,
  5476. FeedetlSn: item.FeedetlSn,
  5477. UploadDate: time.Now().Unix(),
  5478. AdviceId: advice_id,
  5479. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5480. Cnt: item.Cnt,
  5481. Pric: float64(item.Pric),
  5482. PatientId: his.PatientId,
  5483. PricUplmtAmt: item.PricUplmtAmt,
  5484. SelfpayProp: item.SelfpayProp,
  5485. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5486. OverlmtAmt: item.OverlmtAmt,
  5487. PreselfpayAmt: item.PreselfpayAmt,
  5488. BasMednFlag: item.BasMednFlag,
  5489. MedChrgitmType: item.MedChrgitmType,
  5490. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5491. Status: 1,
  5492. Memo: item.Memo,
  5493. Mtime: time.Now().Unix(),
  5494. InscpScpAmt: item.InscpScpAmt,
  5495. DrtReimFlag: item.DrtReimFlag,
  5496. Ctime: time.Now().Unix(),
  5497. ListSpItemFlag: item.ListSpItemFlag,
  5498. ChldMedcFlag: item.ChldMedcFlag,
  5499. LmtUsedFlag: item.LmtUsedFlag,
  5500. ChrgitmLv: item.ChrgitmLv,
  5501. UserOrgId: adminUser.CurrentOrgId,
  5502. HisPatientId: his.ID,
  5503. OrderId: order.ID,
  5504. ProjectId: project_id,
  5505. Type: types,
  5506. }
  5507. service.CreateOrderInfo(info)
  5508. }
  5509. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5510. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5511. var total float64
  5512. for _, item := range prescriptions {
  5513. if item.Type == 1 { //药品
  5514. for _, subItem := range item.HisDoctorAdviceInfo {
  5515. total = total + (subItem.Price * subItem.PrescribingNumber)
  5516. }
  5517. }
  5518. if item.Type == 2 { //项目
  5519. for _, subItem := range item.HisPrescriptionProject {
  5520. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5521. total = total + (subItem.Price * cnt)
  5522. }
  5523. }
  5524. }
  5525. for _, item := range prescriptions {
  5526. for _, subItem := range item.HisAdditionalCharge {
  5527. total = total + (subItem.Price * float64(subItem.Count))
  5528. }
  5529. }
  5530. var allTotal string
  5531. if adminUser.CurrentOrgId == 9919 {
  5532. allTotal = fmt.Sprintf("%.4f", total)
  5533. } else {
  5534. allTotal = fmt.Sprintf("%.4f", total)
  5535. }
  5536. if res.Infcode == 0 {
  5537. var rf []*ResultFive
  5538. json.Unmarshal([]byte(his.Iinfo), &rf)
  5539. chrg_bchno := chrg_bchno
  5540. cert_no := his.Certno
  5541. var insutypes []string
  5542. var insutype string
  5543. var is390 int = 0
  5544. var is310 int = 0
  5545. for _, item := range rf {
  5546. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5547. insutypes = append(insutypes, item.Insutype)
  5548. }
  5549. }
  5550. if len(insutypes) == 1 {
  5551. insutype = insutypes[0]
  5552. } else {
  5553. for _, i := range insutypes {
  5554. if i == "390" {
  5555. is390 = 1
  5556. }
  5557. if i == "310" {
  5558. is310 = 1
  5559. }
  5560. }
  5561. }
  5562. if is390 == 1 {
  5563. insutype = "390"
  5564. }
  5565. if is310 == 1 {
  5566. insutype = "310"
  5567. }
  5568. if len(insutypes) == 0 {
  5569. insutype = "310"
  5570. }
  5571. if len(insutypes) == 2 {
  5572. insutype = strconv.FormatInt(his.SocialType, 10)
  5573. }
  5574. insutype = strconv.FormatInt(his.SocialType, 10)
  5575. //insutype = "390"
  5576. if his.IdCardType == 1 {
  5577. // cert_no = his.MedicalInsuranceNumber
  5578. cert_no = his.Certno
  5579. } else {
  5580. cert_no = his.Certno
  5581. }
  5582. var res ResultSeven
  5583. var resSeven10265 ResultSeven10265
  5584. var src_resquest string
  5585. var result2 string
  5586. var acct_used_flag string
  5587. fmt.Println("pay_way")
  5588. fmt.Println(pay_way)
  5589. fmt.Println("pay_way")
  5590. if pay_way == 4 {
  5591. acct_used_flag = "1"
  5592. } else {
  5593. acct_used_flag = "0"
  5594. }
  5595. if miConfig.MdtrtareaAdmvs == "421300" {
  5596. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5597. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5598. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5599. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5600. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5601. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5602. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5603. resp, requestErr := http.Get(api)
  5604. if requestErr != nil {
  5605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5606. return
  5607. }
  5608. body, ioErr := ioutil.ReadAll(resp.Body)
  5609. if ioErr != nil {
  5610. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5612. return
  5613. }
  5614. var respJSON map[string]interface{}
  5615. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5616. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5617. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5618. return
  5619. }
  5620. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5621. result, _ := json.Marshal(respJSON)
  5622. if miConfig.Code == "H15049901371" {
  5623. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5624. utils.ErrorLog("解析失败:%v", err)
  5625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5626. return
  5627. }
  5628. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5629. res.Output = resSeven10265.Output
  5630. res.ErrMsg = resSeven10265.ErrMsg
  5631. res.Cainfo = resSeven10265.Cainfo
  5632. res.WarnMsg = resSeven10265.WarnMsg
  5633. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5634. res.Infcode = infocode
  5635. } else {
  5636. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5637. utils.ErrorLog("解析失败:%v", err)
  5638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5639. return
  5640. }
  5641. }
  5642. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5643. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5644. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5645. bas := strings.Split(psn_info.CardInfo, "|")
  5646. if his.IdCardType == 1 {
  5647. cert_no = bas[2]
  5648. } else if his.IdCardType == 3 {
  5649. cert_no = his.Certno
  5650. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5651. } else if his.IdCardType == 4 {
  5652. cert_no = his.Certno
  5653. psn_info.VerifyNumber = token
  5654. }
  5655. var api string
  5656. if miConfig.MdtrtareaAdmvs == "320921" {
  5657. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5658. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5659. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5660. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5661. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5662. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5663. "&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
  5664. } else {
  5665. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5666. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5667. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5668. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5669. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5670. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5671. "&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
  5672. }
  5673. resp, requestErr := http.Get(api)
  5674. if requestErr != nil {
  5675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5676. return
  5677. }
  5678. body, ioErr := ioutil.ReadAll(resp.Body)
  5679. if ioErr != nil {
  5680. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5682. return
  5683. }
  5684. var respJSON map[string]interface{}
  5685. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5686. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5688. return
  5689. }
  5690. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5691. result, _ := json.Marshal(respJSON)
  5692. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5693. utils.ErrorLog("解析失败:%v", err)
  5694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5695. return
  5696. }
  5697. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5698. res.Output = resSeven10265.Output
  5699. res.ErrMsg = resSeven10265.ErrMsg
  5700. res.Cainfo = resSeven10265.Cainfo
  5701. res.WarnMsg = resSeven10265.WarnMsg
  5702. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5703. res.Infcode = infocode
  5704. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5705. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5706. var cert_no string
  5707. if his.IdCardType == 1 {
  5708. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5709. }
  5710. fmt.Println(cert_no)
  5711. 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)
  5712. //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)
  5713. var dat map[string]interface{}
  5714. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5715. fmt.Println(dat)
  5716. } else {
  5717. fmt.Println(err)
  5718. }
  5719. saveLog(result2, src_resquest, "2207", "结算")
  5720. userJSONBytes, _ := json.Marshal(dat)
  5721. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5722. utils.ErrorLog("解析失败:%v", err)
  5723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5724. return
  5725. }
  5726. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5727. res.Output = resSeven10265.Output
  5728. res.ErrMsg = resSeven10265.ErrMsg
  5729. res.Cainfo = resSeven10265.Cainfo
  5730. res.WarnMsg = resSeven10265.WarnMsg
  5731. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5732. res.Infcode = infocode
  5733. } else {
  5734. if miConfig.Code == "H15049901371" {
  5735. //赤峰地区国家医保医疗类别
  5736. //职工透析:医疗类别选特殊情况门诊990502
  5737. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5738. var med_type string
  5739. if his.Insutype == "390" {
  5740. if reg_type == 14 {
  5741. med_type = "9933"
  5742. } else if reg_type == 11 {
  5743. med_type = "11"
  5744. }
  5745. } else if his.Insutype == "310" {
  5746. if reg_type == 14 {
  5747. med_type = "990502"
  5748. } else if reg_type == 11 {
  5749. med_type = "11"
  5750. }
  5751. }
  5752. 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)
  5753. } else {
  5754. 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)
  5755. }
  5756. //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)
  5757. var dat map[string]interface{}
  5758. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5759. fmt.Println(dat)
  5760. } else {
  5761. fmt.Println(err)
  5762. }
  5763. saveLog(result2, src_resquest, "2207", "结算")
  5764. userJSONBytes, _ := json.Marshal(dat)
  5765. if miConfig.Code == "H15049901371" {
  5766. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5767. utils.ErrorLog("解析失败:%v", err)
  5768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5769. return
  5770. }
  5771. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5772. res.Output = resSeven10265.Output
  5773. res.ErrMsg = resSeven10265.ErrMsg
  5774. res.Cainfo = resSeven10265.Cainfo
  5775. res.WarnMsg = resSeven10265.WarnMsg
  5776. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5777. res.Infcode = infocode
  5778. } else {
  5779. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5780. utils.ErrorLog("解析失败:%v", err)
  5781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5782. return
  5783. }
  5784. }
  5785. }
  5786. if res.Infcode != 0 {
  5787. errlog := &models.HisOrderError{
  5788. UserOrgId: adminUser.CurrentOrgId,
  5789. Ctime: time.Now().Unix(),
  5790. Mtime: time.Now().Unix(),
  5791. Number: chrg_bchno,
  5792. ErrMsg: res.ErrMsg,
  5793. Status: 1,
  5794. PatientId: id,
  5795. RecordTime: recordDateTime,
  5796. Stage: 6,
  5797. }
  5798. service.CreateErrMsgLog(errlog)
  5799. c.ServeSuccessJSON(map[string]interface{}{
  5800. "failed_code": -10,
  5801. "msg": res.ErrMsg,
  5802. })
  5803. return
  5804. } else {
  5805. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5806. order.OrderStatus = 2
  5807. order.Status = 1
  5808. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5809. order.SetlId = res.Output.Setlinfo.SetlID
  5810. order.PsnNo = res.Output.Setlinfo.PsnNo
  5811. order.PsnName = res.Output.Setlinfo.PsnName
  5812. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5813. order.Certno = res.Output.Setlinfo.Certno
  5814. order.Gend = res.Output.Setlinfo.Gend
  5815. order.Naty = res.Output.Setlinfo.Naty
  5816. order.Age = res.Output.Setlinfo.Age
  5817. order.Insutype = res.Output.Setlinfo.Insutype
  5818. order.PsnType = res.Output.Setlinfo.PsnType
  5819. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5820. order.SetlTime = res.Output.Setlinfo.SetlTime
  5821. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5822. if res.Output.Setlinfo.MedType == "140101" {
  5823. order.MedType = "14"
  5824. } else {
  5825. order.MedType = res.Output.Setlinfo.MedType
  5826. }
  5827. if reg_type == 1112 {
  5828. order.MedType = "1112"
  5829. }
  5830. if reg_type == 1111 {
  5831. order.MedType = "1111"
  5832. }
  5833. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5834. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5835. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5836. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5837. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5838. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5839. order.HifpPay = res.Output.Setlinfo.HifpPay
  5840. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5841. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5842. order.HifesPay = res.Output.Setlinfo.HifesPay
  5843. order.HifobPay = res.Output.Setlinfo.HifobPay
  5844. order.MafPay = res.Output.Setlinfo.MafPay
  5845. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5846. order.OthPay = res.Output.Setlinfo.OthPay
  5847. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5848. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5849. order.AcctPay = res.Output.Setlinfo.AcctPay
  5850. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5851. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5852. order.Balc = res.Output.Setlinfo.Balc
  5853. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5854. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5855. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5856. order.ClrType = res.Output.Setlinfo.ClrType
  5857. order.ClrWay = res.Output.Setlinfo.ClrWay
  5858. order.Creator = order.Creator
  5859. order.Modify = roles.AdminUserId
  5860. order.RequestLog = src_resquest
  5861. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5862. detailStr := string(setlDetail)
  5863. order.SetlDetail = detailStr
  5864. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5865. err = service.UpDateOrder(order)
  5866. if err == nil {
  5867. //判断是否使用了押金
  5868. if dec_way == "true" {
  5869. tmpstring := strconv.FormatInt(order.ID, 10)
  5870. order.Decimal = decimal
  5871. service.UpDateOrder(order)
  5872. //扣押金
  5873. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5874. if errmsg != nil {
  5875. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5876. return
  5877. }
  5878. }
  5879. c.ServeSuccessJSON(map[string]interface{}{
  5880. "msg": "结算成功",
  5881. })
  5882. } else {
  5883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5884. return
  5885. }
  5886. }
  5887. } else {
  5888. adminUser := c.GetAdminUserInfo()
  5889. errlog := &models.HisOrderError{
  5890. UserOrgId: adminUser.CurrentOrgId,
  5891. Ctime: time.Now().Unix(),
  5892. Mtime: time.Now().Unix(),
  5893. ErrMsg: res.ErrMsg,
  5894. Status: 1,
  5895. PatientId: id,
  5896. RecordTime: recordDateTime,
  5897. Stage: 4,
  5898. }
  5899. service.CreateErrMsgLog(errlog)
  5900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5901. return
  5902. }
  5903. } else {
  5904. adminUser := c.GetAdminUserInfo()
  5905. errlog := &models.HisOrderError{
  5906. UserOrgId: adminUser.CurrentOrgId,
  5907. Ctime: time.Now().Unix(),
  5908. Mtime: time.Now().Unix(),
  5909. ErrMsg: res.ErrMsg,
  5910. Status: 1,
  5911. PatientId: id,
  5912. RecordTime: recordDateTime,
  5913. Stage: 4,
  5914. }
  5915. service.CreateErrMsgLog(errlog)
  5916. c.ServeSuccessJSON(map[string]interface{}{
  5917. "failed_code": -10,
  5918. "msg": res.ErrMsg,
  5919. })
  5920. return
  5921. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5922. //return
  5923. }
  5924. }
  5925. }
  5926. } else if tempOrder.ID > 0 {
  5927. if tempOrder.IsPre == 1 {
  5928. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5929. var rf []*ResultFive
  5930. json.Unmarshal([]byte(his.Iinfo), &rf)
  5931. chrg_bchno := tempOrder.Number
  5932. cert_no := his.Certno
  5933. var insutypes []string
  5934. var insutype string
  5935. var is390 int = 0
  5936. var is310 int = 0
  5937. for _, item := range rf {
  5938. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5939. insutypes = append(insutypes, item.Insutype)
  5940. }
  5941. }
  5942. if len(insutypes) == 1 {
  5943. insutype = insutypes[0]
  5944. } else {
  5945. for _, i := range insutypes {
  5946. if i == "390" {
  5947. is390 = 1
  5948. }
  5949. if i == "310" {
  5950. is310 = 1
  5951. }
  5952. }
  5953. }
  5954. if is390 == 1 {
  5955. insutype = "390"
  5956. }
  5957. if is310 == 1 {
  5958. insutype = "310"
  5959. }
  5960. if len(insutypes) == 0 {
  5961. insutype = "310"
  5962. }
  5963. if len(insutypes) == 2 {
  5964. insutype = strconv.FormatInt(his.SocialType, 64)
  5965. }
  5966. //insutype = "390"
  5967. if his.IdCardType == 1 {
  5968. // cert_no = his.MedicalInsuranceNumber
  5969. cert_no = his.Certno
  5970. } else {
  5971. cert_no = his.Certno
  5972. }
  5973. var res ResultSeven
  5974. var resSeven10265 ResultSeven10265
  5975. var src_resquest string
  5976. var result2 string
  5977. var acct_used_flag string
  5978. fmt.Println("pay_way")
  5979. fmt.Println(pay_way)
  5980. fmt.Println("pay_way")
  5981. if pay_way == 4 {
  5982. acct_used_flag = "1"
  5983. } else {
  5984. acct_used_flag = "0"
  5985. }
  5986. if miConfig.MdtrtareaAdmvs == "421300" {
  5987. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5988. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5989. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5990. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5991. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5992. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5993. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5994. resp, requestErr := http.Get(api)
  5995. if requestErr != nil {
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. return
  5998. }
  5999. body, ioErr := ioutil.ReadAll(resp.Body)
  6000. if ioErr != nil {
  6001. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. var respJSON map[string]interface{}
  6006. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6007. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6009. return
  6010. }
  6011. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6012. result, _ := json.Marshal(respJSON)
  6013. fmt.Println("log")
  6014. fmt.Println(string(result))
  6015. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6016. utils.ErrorLog("解析失败:%v", err)
  6017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6018. return
  6019. }
  6020. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6021. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6022. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6023. //psn_info, _ := service.GetPsnByPatientId(id)
  6024. bas := strings.Split(psn_info.CardInfo, "|")
  6025. if his.IdCardType == 1 {
  6026. cert_no = bas[2]
  6027. } else {
  6028. cert_no = bas[1]
  6029. }
  6030. //江苏地区国家医保医疗类别
  6031. //职工透析:医疗类别选特殊情况门诊9933
  6032. //居民血透门慢: 医疗类别选门诊慢病1402
  6033. //var med_type string
  6034. //if his.Insutype == "310" {
  6035. // if reg_type == 14 {
  6036. // med_type = "9933"
  6037. // } else if reg_type == 11 {
  6038. // med_type = "11"
  6039. //
  6040. // }
  6041. //} else if his.Insutype == "390" {
  6042. // if reg_type == 14 {
  6043. // med_type = "1402"
  6044. // } else if reg_type == 11 {
  6045. // med_type = "11"
  6046. // }
  6047. //}
  6048. var api string
  6049. if miConfig.MdtrtareaAdmvs == "320921" {
  6050. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6051. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6052. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6053. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6054. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6055. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6056. "&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
  6057. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6058. } else {
  6059. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6060. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6061. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6062. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6063. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6064. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6065. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6066. "&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
  6067. }
  6068. resp, requestErr := http.Get(api)
  6069. if requestErr != nil {
  6070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6071. return
  6072. }
  6073. body, ioErr := ioutil.ReadAll(resp.Body)
  6074. if ioErr != nil {
  6075. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6077. return
  6078. }
  6079. var respJSON map[string]interface{}
  6080. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6081. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6083. return
  6084. }
  6085. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6086. result, _ := json.Marshal(respJSON)
  6087. fmt.Println("log")
  6088. fmt.Println(string(result))
  6089. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6090. utils.ErrorLog("解析失败:%v", err)
  6091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. return
  6093. }
  6094. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6095. res.Output = resSeven10265.Output
  6096. res.ErrMsg = resSeven10265.ErrMsg
  6097. res.Cainfo = resSeven10265.Cainfo
  6098. res.WarnMsg = resSeven10265.WarnMsg
  6099. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6100. res.Infcode = infocode
  6101. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6102. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6103. var cert_no string
  6104. if his.IdCardType == 1 {
  6105. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6106. }
  6107. fmt.Println(cert_no)
  6108. 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)
  6109. var dat map[string]interface{}
  6110. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6111. fmt.Println(dat)
  6112. } else {
  6113. fmt.Println(err)
  6114. }
  6115. saveLog(result2, src_resquest, "2207", "结算")
  6116. userJSONBytes, _ := json.Marshal(dat)
  6117. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6118. utils.ErrorLog("解析失败:%v", err)
  6119. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6120. return
  6121. }
  6122. } else {
  6123. var src_resquest string
  6124. if miConfig.Code == "H15049901371" {
  6125. //赤峰地区国家医保医疗类别
  6126. //职工透析:医疗类别选特殊情况门诊990502
  6127. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6128. var med_type string
  6129. if his.Insutype == "390" {
  6130. if reg_type == 14 {
  6131. med_type = "9933"
  6132. } else if reg_type == 11 {
  6133. med_type = "11"
  6134. }
  6135. } else if his.Insutype == "310" {
  6136. if reg_type == 14 {
  6137. med_type = "990502"
  6138. } else if reg_type == 11 {
  6139. med_type = "11"
  6140. }
  6141. }
  6142. 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)
  6143. } else {
  6144. 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)
  6145. }
  6146. var dat map[string]interface{}
  6147. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6148. fmt.Println(dat)
  6149. } else {
  6150. fmt.Println(err)
  6151. }
  6152. saveLog(result2, src_resquest, "2207", "结算")
  6153. userJSONBytes, _ := json.Marshal(dat)
  6154. if miConfig.Code == "H15049901371" {
  6155. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6156. utils.ErrorLog("解析失败:%v", err)
  6157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6158. return
  6159. }
  6160. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6161. res.Output = resSeven10265.Output
  6162. res.ErrMsg = resSeven10265.ErrMsg
  6163. res.Cainfo = resSeven10265.Cainfo
  6164. res.WarnMsg = resSeven10265.WarnMsg
  6165. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6166. res.Infcode = infocode
  6167. } else {
  6168. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6169. utils.ErrorLog("解析失败:%v", err)
  6170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6171. return
  6172. }
  6173. }
  6174. }
  6175. if res.Infcode != 0 {
  6176. errlog := &models.HisOrderError{
  6177. UserOrgId: adminUser.CurrentOrgId,
  6178. Ctime: time.Now().Unix(),
  6179. Mtime: time.Now().Unix(),
  6180. Number: chrg_bchno,
  6181. ErrMsg: res.ErrMsg,
  6182. Status: 1,
  6183. PatientId: id,
  6184. RecordTime: recordDateTime,
  6185. Stage: 6,
  6186. }
  6187. service.CreateErrMsgLog(errlog)
  6188. c.ServeSuccessJSON(map[string]interface{}{
  6189. "failed_code": -10,
  6190. "msg": res.ErrMsg,
  6191. })
  6192. return
  6193. } else {
  6194. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6195. order.OrderStatus = 2
  6196. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6197. order.SetlId = res.Output.Setlinfo.SetlID
  6198. order.PsnNo = res.Output.Setlinfo.PsnNo
  6199. order.PsnName = res.Output.Setlinfo.PsnName
  6200. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6201. order.Certno = res.Output.Setlinfo.Certno
  6202. order.Gend = res.Output.Setlinfo.Gend
  6203. order.Naty = res.Output.Setlinfo.Naty
  6204. order.Age = res.Output.Setlinfo.Age
  6205. order.Insutype = res.Output.Setlinfo.Insutype
  6206. order.PsnType = res.Output.Setlinfo.PsnType
  6207. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6208. order.SetlTime = res.Output.Setlinfo.SetlTime
  6209. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6210. //order.MedType = res.Output.Setlinfo.MedType
  6211. if reg_type == 1112 {
  6212. order.MedType = "1112"
  6213. }
  6214. if reg_type == 1111 {
  6215. order.MedType = "1111"
  6216. }
  6217. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6218. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6219. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6220. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6221. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6222. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6223. order.HifpPay = res.Output.Setlinfo.HifpPay
  6224. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6225. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6226. order.HifesPay = res.Output.Setlinfo.HifesPay
  6227. order.HifobPay = res.Output.Setlinfo.HifobPay
  6228. order.MafPay = res.Output.Setlinfo.MafPay
  6229. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6230. order.OthPay = res.Output.Setlinfo.OthPay
  6231. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6232. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6233. order.AcctPay = res.Output.Setlinfo.AcctPay
  6234. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6235. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6236. order.Balc = res.Output.Setlinfo.Balc
  6237. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6238. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6239. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6240. order.ClrWay = res.Output.Setlinfo.ClrWay
  6241. order.Creator = order.Creator
  6242. order.Modify = roles.AdminUserId
  6243. order.RequestLog = src_resquest
  6244. order.Diagnosis = diagnosis_id
  6245. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6246. detailStr := string(setlDetail)
  6247. order.SetlDetail = detailStr
  6248. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6249. err = service.UpDateOrder(order)
  6250. if err == nil {
  6251. //判断是否使用了押金
  6252. if dec_way == "true" {
  6253. tmpstring := strconv.FormatInt(order.ID, 10)
  6254. //扣押金
  6255. order.Decimal = decimal
  6256. service.UpDateOrder(order)
  6257. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6258. if errmsg != nil {
  6259. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6260. return
  6261. }
  6262. }
  6263. c.ServeSuccessJSON(map[string]interface{}{
  6264. "msg": "结算成功",
  6265. })
  6266. } else {
  6267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6268. return
  6269. }
  6270. }
  6271. }
  6272. }
  6273. }
  6274. //func (c *HisApiController) GetPreUploadInfo() {
  6275. // id, _ := c.GetInt64("id")
  6276. // record_time := c.GetString("record_time")
  6277. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6278. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6279. //
  6280. // timeLayout := "2006-01-02"
  6281. // loc, _ := time.LoadLocation("Local")
  6282. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6283. // if err != nil {
  6284. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6285. // return
  6286. // }
  6287. // recordDateTime := theTime.Unix()
  6288. // adminUser := c.GetAdminUserInfo()
  6289. //
  6290. // var prescriptions []*models.HisPrescription
  6291. //
  6292. // var start_time int64
  6293. // var end_time int64
  6294. //
  6295. // data := make(map[string]interface{})
  6296. // if settle_accounts_type == 1 { //日结
  6297. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6298. // data["pre"] = prescriptions
  6299. //
  6300. // } else { //月结
  6301. // start_time_str := c.GetString("start_time")
  6302. // end_time_str := c.GetString("end_time")
  6303. // timeLayout := "2006-01-02"
  6304. // loc, _ := time.LoadLocation("Local")
  6305. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6306. // if err != nil {
  6307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6308. // return
  6309. // }
  6310. // recordStartTime := theStartTime.Unix()
  6311. // start_time = recordStartTime
  6312. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6313. // if err != nil {
  6314. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6315. // return
  6316. // }
  6317. // recordEndTime := theEndTime.Unix()
  6318. // end_time = recordEndTime
  6319. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6320. // data["pre"] = prescriptions
  6321. //
  6322. // }
  6323. //
  6324. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6325. //
  6326. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6327. // timestamp := time.Now().Unix()
  6328. // tempTime := time.Unix(timestamp, 0)
  6329. // timeFormat := tempTime.Format("20060102150405")
  6330. // chrgBchno := rand.Intn(100000) + 10000
  6331. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6332. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6333. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6334. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6335. // strconv.FormatInt(his.PatientId, 10)
  6336. // client := &http.Client{}
  6337. // data["psn_no"] = his.PsnNo
  6338. // data["mdtrt_id"] = his.Number
  6339. // data["chrg_bchno"] = chrg_bchno
  6340. // data["org_name"] = miConfig.OrgName
  6341. // data["doctor"] = roles.UserName
  6342. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6343. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6344. // data["fixmedins_code"] = miConfig.Code
  6345. // data["dept_code"] = department.Number
  6346. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6347. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6348. // data["secret_key"] = miConfig.SecretKey
  6349. // var ids []int64
  6350. //
  6351. // for _, item := range prescriptions {
  6352. // ids = append(ids, item.ID)
  6353. // }
  6354. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6355. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6356. // bytesData, _ := json.Marshal(data)
  6357. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6358. // resp, _ := client.Do(req)
  6359. // defer resp.Body.Close()
  6360. // body, ioErr := ioutil.ReadAll(resp.Body)
  6361. // if ioErr != nil {
  6362. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6364. // return
  6365. // }
  6366. // var respJSON map[string]interface{}
  6367. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6368. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6369. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6370. // return
  6371. // }
  6372. //
  6373. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6374. // userJSONBytes, _ := json.Marshal(respJSON)
  6375. // var res ResultFour
  6376. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6377. // utils.ErrorLog("解析失败:%v", err)
  6378. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6379. // return
  6380. // }
  6381. //
  6382. // if res.Infcode == 0 {
  6383. // order := &models.HisOrder{
  6384. // UserOrgId: adminUser.CurrentOrgId,
  6385. // HisPatientId: his.ID,
  6386. // PatientId: his.PatientId,
  6387. // SettleAccountsDate: recordDateTime,
  6388. // Ctime: time.Now().Unix(),
  6389. // Mtime: time.Now().Unix(),
  6390. // Status: 1,
  6391. // Number: chrg_bchno,
  6392. // Infcode: res.Infcode,
  6393. // WarnMsg: res.WarnMsg,
  6394. // Cainfo: res.Cainfo,
  6395. // ErrMsg: res.ErrMsg,
  6396. // RespondTime: res.RefmsgTime,
  6397. // InfRefmsgid: res.InfRefmsgid,
  6398. // OrderStatus: 1,
  6399. // IsMedicineInsurance: 1,
  6400. // SettleType: settle_accounts_type,
  6401. // SettleStartTime: start_time,
  6402. // SettleEndTime: end_time,
  6403. // Creator: roles.ID,
  6404. // Modify: roles.ID,
  6405. // PType: 2,
  6406. // }
  6407. // err = service.CreateOrder(order)
  6408. // if err != nil {
  6409. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6410. // return
  6411. // }
  6412. //
  6413. // for _, item := range res.Output.Result {
  6414. // temp := strings.Split(item.FeedetlSn, "-")
  6415. // var advice_id int64 = 0
  6416. // var project_id int64 = 0
  6417. // var types int64 = 0
  6418. //
  6419. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6420. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6421. //
  6422. // if temp[1] == "1" {
  6423. // advice_id = id
  6424. // project_id = 0
  6425. // } else if temp[1] == "2" {
  6426. // advice_id = 0
  6427. // project_id = id
  6428. // }
  6429. //
  6430. // info := &models.HisOrderInfo{
  6431. // OrderNumber: order.Number,
  6432. // FeedetlSn: item.FeedetlSn,
  6433. // UploadDate: time.Now().Unix(),
  6434. // AdviceId: advice_id,
  6435. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6436. // Cnt: item.Cnt,
  6437. // Pric: float64(item.Pric),
  6438. // PatientId: his.PatientId,
  6439. // PricUplmtAmt: item.PricUplmtAmt,
  6440. // SelfpayProp: item.SelfpayProp,
  6441. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6442. // OverlmtAmt: item.OverlmtAmt,
  6443. // PreselfpayAmt: item.PreselfpayAmt,
  6444. // BasMednFlag: item.BasMednFlag,
  6445. // MedChrgitmType: item.MedChrgitmType,
  6446. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6447. // Status: 1,
  6448. // Memo: item.Memo,
  6449. // Mtime: time.Now().Unix(),
  6450. // InscpScpAmt: item.InscpScpAmt,
  6451. // DrtReimFlag: item.DrtReimFlag,
  6452. // Ctime: time.Now().Unix(),
  6453. // ListSpItemFlag: item.ListSpItemFlag,
  6454. // ChldMedcFlag: item.ChldMedcFlag,
  6455. // LmtUsedFlag: item.LmtUsedFlag,
  6456. // ChrgitmLv: item.ChrgitmLv,
  6457. // UserOrgId: adminUser.CurrentOrgId,
  6458. // HisPatientId: his.ID,
  6459. // OrderId: order.ID,
  6460. // ProjectId: project_id,
  6461. // Type: types,
  6462. // }
  6463. // service.CreateOrderInfo(info)
  6464. //
  6465. // }
  6466. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6467. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6468. //
  6469. // var total float64
  6470. // for _, item := range prescriptions {
  6471. // if item.Type == 1 { //药品
  6472. // for _, subItem := range item.HisDoctorAdviceInfo {
  6473. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6474. // }
  6475. // }
  6476. // if item.Type == 2 { //项目
  6477. // for _, subItem := range item.HisPrescriptionProject {
  6478. // total = total + (subItem.Price * float64(subItem.Count))
  6479. // }
  6480. // }
  6481. // }
  6482. //
  6483. // for _, item := range prescriptions {
  6484. // for _, subItem := range item.HisAdditionalCharge {
  6485. // total = total + (subItem.Price * float64(subItem.Count))
  6486. // }
  6487. // }
  6488. //
  6489. // allTotal := fmt.Sprintf("%.2f", total)
  6490. // if res.Infcode == 0 {
  6491. // var rf []*ResultFive
  6492. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6493. // psn_no := his.PsnNo
  6494. // mdtrt_id := his.Number
  6495. // chrg_bchno := chrg_bchno
  6496. // cert_no := his.Certno
  6497. // insutype := rf[0].Insutype
  6498. //
  6499. // if his.IdCardType == 1 {
  6500. // cert_no = his.MedicalInsuranceNumber
  6501. //
  6502. // } else {
  6503. //
  6504. // cert_no = his.Certno
  6505. //
  6506. // }
  6507. //
  6508. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6509. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6510. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6511. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6512. // resp, requestErr := http.Get(api)
  6513. // if requestErr != nil {
  6514. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6515. // return
  6516. // }
  6517. // defer resp.Body.Close()
  6518. // body, ioErr := ioutil.ReadAll(resp.Body)
  6519. // if ioErr != nil {
  6520. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6521. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6522. // return
  6523. // }
  6524. // var respJSON map[string]interface{}
  6525. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6526. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6528. // return
  6529. // }
  6530. // fmt.Println(respJSON)
  6531. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6532. // userJSONBytes, _ := json.Marshal(respJSON)
  6533. // var res ResultSeven
  6534. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6535. // utils.ErrorLog("解析失败:%v", err)
  6536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6537. // return
  6538. // }
  6539. // if res.Infcode != 0 {
  6540. // errlog := &models.HisOrderError{
  6541. // UserOrgId: adminUser.CurrentOrgId,
  6542. // Ctime: time.Now().Unix(),
  6543. // Mtime: time.Now().Unix(),
  6544. // Number: chrg_bchno,
  6545. // ErrMsg: res.ErrMsg,
  6546. // Status: 1,
  6547. // PatientId: id,
  6548. // RecordTime: recordDateTime,
  6549. // Stage: 7,
  6550. // }
  6551. // service.CreateErrMsgLog(errlog)
  6552. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6553. // return
  6554. // } else {
  6555. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6556. // order.OrderStatus = 1
  6557. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6558. // order.SetlId = res.Output.Setlinfo.SetlID
  6559. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6560. // order.PsnName = res.Output.Setlinfo.PsnName
  6561. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6562. // order.Certno = res.Output.Setlinfo.Certno
  6563. // order.Gend = res.Output.Setlinfo.Gend
  6564. // order.Naty = res.Output.Setlinfo.Naty
  6565. // order.Age = res.Output.Setlinfo.Age
  6566. // order.Insutype = res.Output.Setlinfo.Insutype
  6567. // order.PsnType = res.Output.Setlinfo.PsnType
  6568. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6569. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6570. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6571. // order.MedType = res.Output.Setlinfo.MedType
  6572. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6573. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6574. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6575. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6576. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6577. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6578. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6579. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6580. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6581. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6582. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6583. // order.MafPay = res.Output.Setlinfo.MafPay
  6584. // order.OthPay = res.Output.Setlinfo.OthPay
  6585. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6586. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6587. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6588. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6589. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6590. // order.Balc = res.Output.Setlinfo.Balc
  6591. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6592. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6593. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6594. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6595. // order.Creator = order.Creator
  6596. // order.Modify = roles.ID
  6597. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6598. // detailStr := string(setlDetail)
  6599. // order.SetlDetail = detailStr
  6600. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6601. // err = service.UpDateOrder(order)
  6602. // if err == nil {
  6603. // c.ServeSuccessJSON(map[string]interface{}{
  6604. // "msg": "预结算成功",
  6605. // })
  6606. // } else {
  6607. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6608. // return
  6609. // }
  6610. // }
  6611. // } else {
  6612. // adminUser := c.GetAdminUserInfo()
  6613. // errlog := &models.HisOrderError{
  6614. // UserOrgId: adminUser.CurrentOrgId,
  6615. // Ctime: time.Now().Unix(),
  6616. // Mtime: time.Now().Unix(),
  6617. // ErrMsg: res.ErrMsg,
  6618. // Status: 1,
  6619. // PatientId: id,
  6620. // RecordTime: recordDateTime,
  6621. // Stage: 4,
  6622. // }
  6623. // service.CreateErrMsgLog(errlog)
  6624. //
  6625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6626. // return
  6627. // }
  6628. // } else {
  6629. // adminUser := c.GetAdminUserInfo()
  6630. // errlog := &models.HisOrderError{
  6631. // UserOrgId: adminUser.CurrentOrgId,
  6632. // Ctime: time.Now().Unix(),
  6633. // Mtime: time.Now().Unix(),
  6634. // ErrMsg: res.ErrMsg,
  6635. // Status: 1,
  6636. // PatientId: id,
  6637. // RecordTime: recordDateTime,
  6638. // Stage: 4,
  6639. // }
  6640. // service.CreateErrMsgLog(errlog)
  6641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6642. // return
  6643. // }
  6644. //
  6645. // } else {
  6646. // var total float64
  6647. // for _, item := range prescriptions {
  6648. // if item.Type == 1 { //药品
  6649. // for _, subItem := range item.HisDoctorAdviceInfo {
  6650. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6651. // }
  6652. // }
  6653. // if item.Type == 2 { //项目
  6654. // for _, subItem := range item.HisPrescriptionProject {
  6655. // total = total + (subItem.Price * float64(subItem.Count))
  6656. // }
  6657. // }
  6658. //
  6659. // for _, subItem := range item.HisAdditionalCharge {
  6660. // total = total + (subItem.Price * float64(subItem.Count))
  6661. // }
  6662. // }
  6663. //
  6664. // allTotal := fmt.Sprintf("%.2f", total)
  6665. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6666. // order := &models.HisOrder{
  6667. // UserOrgId: adminUser.CurrentOrgId,
  6668. // HisPatientId: his.ID,
  6669. // PatientId: id,
  6670. // SettleAccountsDate: recordDateTime,
  6671. // Ctime: time.Now().Unix(),
  6672. // Mtime: time.Now().Unix(),
  6673. // Status: 1,
  6674. // OrderStatus: 2,
  6675. // Number: chrg_bchno,
  6676. // MedfeeSumamt: totals,
  6677. // }
  6678. // err = service.CreateOrder(order)
  6679. // if err != nil {
  6680. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6681. // return
  6682. // }
  6683. //
  6684. // var customs []*Custom
  6685. // for _, item := range prescriptions {
  6686. //
  6687. // if item.Type == 1 { //药品
  6688. // for _, subItem := range item.HisDoctorAdviceInfo {
  6689. // cus := &Custom{
  6690. // AdviceId: subItem.ID,
  6691. // ProjectId: 0,
  6692. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6693. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6694. // FeedetlSn: subItem.FeedetlSn,
  6695. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6696. // MedListCodg: subItem.MedListCodg,
  6697. // Type: 1,
  6698. // }
  6699. // customs = append(customs, cus)
  6700. // }
  6701. // }
  6702. //
  6703. // if item.Type == 2 { //项目
  6704. // for _, subItem := range item.HisPrescriptionProject {
  6705. //
  6706. // cus := &Custom{
  6707. // AdviceId: 0,
  6708. // ProjectId: subItem.ID,
  6709. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6710. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6711. // FeedetlSn: subItem.FeedetlSn,
  6712. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6713. // MedListCodg: subItem.MedListCodg,
  6714. // Type: 2,
  6715. // }
  6716. //
  6717. // customs = append(customs, cus)
  6718. // }
  6719. // }
  6720. //
  6721. // for _, item := range item.HisAdditionalCharge {
  6722. // cus := &Custom{
  6723. // ItemId: item.ID,
  6724. // AdviceId: 0,
  6725. // ProjectId: 0,
  6726. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6727. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6728. // FeedetlSn: item.FeedetlSn,
  6729. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6730. // MedListCodg: item.XtHisAddtionConfig.Code,
  6731. // Type: 3,
  6732. // }
  6733. //
  6734. // customs = append(customs, cus)
  6735. // }
  6736. //
  6737. // }
  6738. //
  6739. // for _, item := range customs {
  6740. // var advice_id int64 = 0
  6741. // var project_id int64 = 0
  6742. // var item_id int64 = 0
  6743. //
  6744. // var types int64 = 0
  6745. //
  6746. // if item.Type == 1 {
  6747. // advice_id = item.AdviceId
  6748. // project_id = 0
  6749. // item_id = 0
  6750. // } else if item.Type == 2 {
  6751. // advice_id = 0
  6752. // item_id = 0
  6753. //
  6754. // project_id = item.ProjectId
  6755. // } else if item.Type == 3 {
  6756. // advice_id = 0
  6757. // item_id = item.ItemId
  6758. // project_id = 0
  6759. // }
  6760. //
  6761. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6762. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6763. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6764. //
  6765. // info := &models.HisOrderInfo{
  6766. // OrderNumber: order.Number,
  6767. // UploadDate: time.Now().Unix(),
  6768. // AdviceId: advice_id,
  6769. // DetItemFeeSumamt: detItemFeeSumamt,
  6770. // Cnt: cut,
  6771. // Pric: pric,
  6772. // PatientId: id,
  6773. // Status: 1,
  6774. // Mtime: time.Now().Unix(),
  6775. // Ctime: time.Now().Unix(),
  6776. // UserOrgId: adminUser.CurrentOrgId,
  6777. // HisPatientId: his.ID,
  6778. // OrderId: order.ID,
  6779. // ProjectId: project_id,
  6780. // Type: types,
  6781. // ItemId: item_id,
  6782. // }
  6783. // service.CreateOrderInfo(info)
  6784. // }
  6785. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6786. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6787. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6788. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6789. // if err == nil {
  6790. // c.ServeSuccessJSON(map[string]interface{}{
  6791. // "msg": "结算成功",
  6792. // })
  6793. // } else {
  6794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6795. // return
  6796. // }
  6797. // }
  6798. //}
  6799. //上传明细-预结算-
  6800. func (c *HisApiController) GetPreUploadInfo() {
  6801. id, _ := c.GetInt64("id")
  6802. record_time := c.GetString("record_time")
  6803. his_patient_id, _ := c.GetInt64("his_patient_id")
  6804. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6805. admin_user_id, _ := c.GetInt64("admin_user_id")
  6806. diagnosis_id := c.GetString("diagnosis")
  6807. sick_type, _ := c.GetInt64("sick_type")
  6808. reg_type, _ := c.GetInt64("p_type")
  6809. begin_time := c.GetString("begin_time")
  6810. id_str := c.GetString("ids")
  6811. ids_arr := strings.Split(id_str, ",")
  6812. timeLayout := "2006-01-02"
  6813. loc, _ := time.LoadLocation("Local")
  6814. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6815. if err != nil {
  6816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6817. return
  6818. }
  6819. recordDateTime := theTime.Unix()
  6820. adminUser := c.GetAdminUserInfo()
  6821. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6822. var config []*models.HisXtDiagnoseConfig
  6823. for _, item := range diagnosis_ids {
  6824. id, _ := strconv.ParseInt(item, 10, 64)
  6825. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6826. config = append(config, &diagnosisConfig)
  6827. }
  6828. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6829. sickConfig, _ := service.FindSickById(sick_type)
  6830. var prescriptions []*models.HisPrescription
  6831. var start_time int64
  6832. var end_time int64
  6833. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6834. fmt.Println(his_patient_id)
  6835. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6836. timestamp := time.Now().Unix()
  6837. tempTime := time.Unix(timestamp, 0)
  6838. timeFormat := tempTime.Format("20060102150405")
  6839. chrgBchno := rand.Intn(100000) + 10000
  6840. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6841. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6842. var patientPrescription models.HisPrescriptionInfo
  6843. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6844. if patientPrescription.ID == 0 {
  6845. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6846. }
  6847. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6848. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6849. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6850. strconv.FormatInt(his.PatientId, 10)
  6851. var res2 ResultSix
  6852. var resSix10265 ResultSix10265
  6853. var time_stamp string
  6854. if miConfig.MdtrtareaAdmvs == "421300" {
  6855. data := make(map[string]interface{})
  6856. client := &http.Client{}
  6857. data["psn_no"] = his.PsnNo
  6858. data["mdtrt_id"] = his.Number
  6859. data["department"] = department.Name
  6860. data["org_name"] = miConfig.OrgName
  6861. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6862. data["doctor_id"] = doctor_info.DoctorNumber
  6863. data["doctor_name"] = roles.UserName
  6864. data["fixmedins_code"] = miConfig.Code
  6865. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6866. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6867. data["secret_key"] = miConfig.SecretKey
  6868. data["sick_code"] = sickConfig.CountryCode
  6869. data["sick_name"] = sickConfig.ClassName
  6870. data["begin_time"] = begin_time
  6871. data["dept"] = strconv.FormatInt(department.ID, 10)
  6872. data["config"] = config
  6873. data["opter"] = roles.UserName
  6874. fmt.Println(data)
  6875. bytesData, _ := json.Marshal(data)
  6876. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6877. resp, _ := client.Do(req)
  6878. defer resp.Body.Close()
  6879. body, ioErr := ioutil.ReadAll(resp.Body)
  6880. if ioErr != nil {
  6881. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6883. return
  6884. }
  6885. var respJSON map[string]interface{}
  6886. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6887. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6889. return
  6890. }
  6891. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6892. userJSONBytes, _ := json.Marshal(respJSON)
  6893. fmt.Println("log")
  6894. fmt.Println(string(userJSONBytes))
  6895. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6896. utils.ErrorLog("解析失败:%v", err)
  6897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6898. return
  6899. }
  6900. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6901. data := make(map[string]interface{})
  6902. client := &http.Client{}
  6903. data["psn_no"] = his.PsnNo
  6904. data["mdtrt_id"] = his.Number
  6905. data["doctor"] = roles.UserName
  6906. data["department"] = department.Name
  6907. data["org_name"] = miConfig.OrgName
  6908. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6909. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6910. data["fixmedins_code"] = miConfig.Code
  6911. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6912. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6913. data["secret_key"] = miConfig.SecretKey
  6914. data["sick_code"] = sickConfig.CountryCode
  6915. data["sick_name"] = sickConfig.ClassName
  6916. data["begin_time"] = begin_time
  6917. data["dept"] = strconv.FormatInt(department.ID, 10)
  6918. data["config"] = config
  6919. data["url"] = miConfig.Url
  6920. data["ak"] = miConfig.AccessKey
  6921. data["cainfo"] = miConfig.Cainfo
  6922. bytesData, _ := json.Marshal(data)
  6923. var req *http.Request
  6924. if miConfig.MdtrtareaAdmvs == "320921" {
  6925. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6926. //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 +
  6927. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6928. } else {
  6929. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6930. }
  6931. resp, _ := client.Do(req)
  6932. defer resp.Body.Close()
  6933. body, ioErr := ioutil.ReadAll(resp.Body)
  6934. if ioErr != nil {
  6935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6937. return
  6938. }
  6939. var respJSON map[string]interface{}
  6940. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6943. return
  6944. }
  6945. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6946. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6947. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6948. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6949. userJSONBytes, _ := json.Marshal(respJSON)
  6950. fmt.Println("log")
  6951. fmt.Println(string(userJSONBytes))
  6952. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6953. utils.ErrorLog("解析失败:%v", err)
  6954. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6955. return
  6956. }
  6957. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6958. res2.Output = resSix10265.Output
  6959. res2.ErrMsg = resSix10265.ErrMsg
  6960. res2.Cainfo = resSix10265.Cainfo
  6961. res2.WarnMsg = resSix10265.WarnMsg
  6962. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6963. res2.Infcode = infocode
  6964. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6965. 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)
  6966. saveLog(result, requestLog, "2203", "上传就诊信息")
  6967. var respJSON2 map[string]interface{}
  6968. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6969. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6970. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6971. return
  6972. }
  6973. userJSONBytes2, _ := json.Marshal(respJSON2)
  6974. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6975. utils.ErrorLog("解析失败:%v", err)
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6977. return
  6978. }
  6979. } else {
  6980. var result string
  6981. var requestLog string
  6982. if miConfig.MdtrtareaAdmvs == "440781" { //
  6983. 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)
  6984. } else {
  6985. if miConfig.Code == "H15049901371" {
  6986. //赤峰地区国家医保医疗类别
  6987. //职工透析:医疗类别选特殊情况门诊990502
  6988. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6989. var med_type string
  6990. if his.Insutype == "390" {
  6991. if reg_type == 14 {
  6992. med_type = "9933"
  6993. } else if reg_type == 11 {
  6994. med_type = "11"
  6995. }
  6996. } else if his.Insutype == "310" {
  6997. if reg_type == 14 {
  6998. med_type = "990502"
  6999. } else if reg_type == 11 {
  7000. med_type = "11"
  7001. }
  7002. }
  7003. 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)
  7004. } else {
  7005. 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)
  7006. }
  7007. saveLog(result, requestLog, "2203", "上传就诊信息")
  7008. var respJSON2 map[string]interface{}
  7009. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7010. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7012. return
  7013. }
  7014. userJSONBytes2, _ := json.Marshal(respJSON2)
  7015. if miConfig.Code == "H15049901371" {
  7016. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7017. utils.ErrorLog("解析失败:%v", err)
  7018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7019. return
  7020. }
  7021. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7022. res2.Output = resSix10265.Output
  7023. res2.ErrMsg = resSix10265.ErrMsg
  7024. res2.Cainfo = resSix10265.Cainfo
  7025. res2.WarnMsg = resSix10265.WarnMsg
  7026. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7027. res2.Infcode = infocode
  7028. } else {
  7029. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7030. utils.ErrorLog("解析失败:%v", err)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. }
  7035. }
  7036. }
  7037. if res2.Infcode != 0 {
  7038. adminUser := c.GetAdminUserInfo()
  7039. errlog := &models.HisOrderError{
  7040. UserOrgId: adminUser.CurrentOrgId,
  7041. Ctime: time.Now().Unix(),
  7042. Mtime: time.Now().Unix(),
  7043. ErrMsg: res2.ErrMsg,
  7044. Status: 1,
  7045. PatientId: id,
  7046. RecordTime: recordDateTime,
  7047. Stage: 3,
  7048. }
  7049. service.CreateErrMsgLog(errlog)
  7050. c.ServeSuccessJSON(map[string]interface{}{
  7051. "failed_code": -10,
  7052. "msg": res2.ErrMsg,
  7053. })
  7054. return
  7055. } else {
  7056. his.Diagnosis = diagnosis_id
  7057. his.SickType = sickConfig.ID
  7058. his.PType = fmt.Sprintf("%d", reg_type)
  7059. service.UpdateHisPatientThree(&his)
  7060. data := make(map[string]interface{})
  7061. if settle_accounts_type == 1 { //日结
  7062. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7063. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7064. } else {
  7065. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7066. }
  7067. data["pre"] = prescriptions
  7068. } else { //月结
  7069. start_time_str := c.GetString("start_time")
  7070. end_time_str := c.GetString("end_time")
  7071. timeLayout := "2006-01-02"
  7072. loc, _ := time.LoadLocation("Local")
  7073. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7074. if err != nil {
  7075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7076. return
  7077. }
  7078. recordStartTime := theStartTime.Unix()
  7079. start_time = recordStartTime
  7080. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7081. if err != nil {
  7082. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7083. return
  7084. }
  7085. recordEndTime := theEndTime.Unix()
  7086. end_time = recordEndTime
  7087. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7088. data["pre"] = prescriptions
  7089. }
  7090. client := &http.Client{}
  7091. data["psn_no"] = his.PsnNo
  7092. data["mdtrt_id"] = his.Number
  7093. data["chrg_bchno"] = chrg_bchno
  7094. data["org_name"] = miConfig.OrgName
  7095. data["doctor"] = roles.UserName
  7096. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7097. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7098. data["fixmedins_code"] = miConfig.Code
  7099. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7100. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7101. data["dept_code"] = "15"
  7102. } else {
  7103. data["dept_code"] = department.Number
  7104. }
  7105. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7106. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7107. data["secret_key"] = miConfig.SecretKey
  7108. data["url"] = miConfig.Url
  7109. data["ak"] = miConfig.AccessKey
  7110. data["new_doctor_name"] = patientPrescription.Doctor
  7111. data["diag_code"] = sickConfig.CountryCode
  7112. data["time_stamp"] = time_stamp
  7113. data["cainfo"] = miConfig.Cainfo
  7114. var ids []int64
  7115. for _, item := range prescriptions {
  7116. ids = append(ids, item.ID)
  7117. }
  7118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7119. if config.IsOpen == 1 { //对接了医保,走医保流程
  7120. var res ResultFour
  7121. var resFour10265 ResultFour10265
  7122. if miConfig.MdtrtareaAdmvs == "421300" {
  7123. bytesData, _ := json.Marshal(data)
  7124. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7125. resp, _ := client.Do(req)
  7126. defer resp.Body.Close()
  7127. body, ioErr := ioutil.ReadAll(resp.Body)
  7128. if ioErr != nil {
  7129. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7131. return
  7132. }
  7133. var respJSON map[string]interface{}
  7134. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7135. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7137. return
  7138. }
  7139. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7140. userJSONBytes, _ := json.Marshal(respJSON)
  7141. fmt.Println("log")
  7142. fmt.Println(string(userJSONBytes))
  7143. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7144. utils.ErrorLog("解析失败:%v", err)
  7145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7146. return
  7147. }
  7148. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7149. bytesData, _ := json.Marshal(data)
  7150. var req *http.Request
  7151. if miConfig.MdtrtareaAdmvs == "320921" {
  7152. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7153. } else {
  7154. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7155. }
  7156. resp, _ := client.Do(req)
  7157. defer resp.Body.Close()
  7158. body, ioErr := ioutil.ReadAll(resp.Body)
  7159. if ioErr != nil {
  7160. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7162. return
  7163. }
  7164. var respJSON map[string]interface{}
  7165. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7168. return
  7169. }
  7170. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7171. userJSONBytes, _ := json.Marshal(respJSON)
  7172. fmt.Println("log")
  7173. fmt.Println(string(userJSONBytes))
  7174. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7175. utils.ErrorLog("解析失败:%v", err)
  7176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7177. return
  7178. }
  7179. res.InfRefmsgid = resFour10265.InfRefmsgid
  7180. res.Output = resFour10265.Output
  7181. res.ErrMsg = resFour10265.ErrMsg
  7182. res.Cainfo = resFour10265.Cainfo
  7183. res.WarnMsg = resFour10265.WarnMsg
  7184. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7185. res.Infcode = infocode
  7186. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7187. 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)
  7188. var dat map[string]interface{}
  7189. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7190. fmt.Println(dat)
  7191. } else {
  7192. fmt.Println(err)
  7193. }
  7194. saveLog(result, request_log, "2204", "上传费用明细")
  7195. userJSONBytes, _ := json.Marshal(dat)
  7196. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7197. utils.ErrorLog("解析失败:%v", err)
  7198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7199. return
  7200. }
  7201. } else {
  7202. if miConfig.Code == "H15049901371" {
  7203. 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)
  7204. var dat map[string]interface{}
  7205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7206. fmt.Println(dat)
  7207. } else {
  7208. fmt.Println(err)
  7209. }
  7210. saveLog(result, request_log, "2204", "上传费用明细")
  7211. userJSONBytes, _ := json.Marshal(dat)
  7212. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7213. utils.ErrorLog("解析失败:%v", err)
  7214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7215. return
  7216. }
  7217. res.InfRefmsgid = resFour10265.InfRefmsgid
  7218. res.Output = resFour10265.Output
  7219. res.ErrMsg = resFour10265.ErrMsg
  7220. res.Cainfo = resFour10265.Cainfo
  7221. res.WarnMsg = resFour10265.WarnMsg
  7222. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7223. res.Infcode = infocode
  7224. } else {
  7225. 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)
  7226. var dat map[string]interface{}
  7227. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7228. fmt.Println(dat)
  7229. } else {
  7230. fmt.Println(err)
  7231. }
  7232. saveLog(result, request_log, "2204", "上传费用明细")
  7233. userJSONBytes, _ := json.Marshal(dat)
  7234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7235. utils.ErrorLog("解析失败:%v", err)
  7236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7237. return
  7238. }
  7239. }
  7240. }
  7241. if res.Infcode == 0 {
  7242. order := &models.HisOrder{
  7243. UserOrgId: adminUser.CurrentOrgId,
  7244. HisPatientId: his.ID,
  7245. PatientId: his.PatientId,
  7246. SettleAccountsDate: recordDateTime,
  7247. Ctime: time.Now().Unix(),
  7248. Mtime: time.Now().Unix(),
  7249. MdtrtId: his.Number,
  7250. PsnNo: his.PsnNo,
  7251. MedType: strconv.FormatInt(reg_type, 10),
  7252. Status: 1,
  7253. Number: chrg_bchno,
  7254. Infcode: res.Infcode,
  7255. WarnMsg: res.WarnMsg,
  7256. Cainfo: res.Cainfo,
  7257. ErrMsg: res.ErrMsg,
  7258. RespondTime: res.RefmsgTime,
  7259. InfRefmsgid: res.InfRefmsgid,
  7260. OrderStatus: 1,
  7261. IsMedicineInsurance: 1,
  7262. SettleType: settle_accounts_type,
  7263. SettleStartTime: start_time,
  7264. SettleEndTime: end_time,
  7265. Creator: roles.AdminUserId,
  7266. Modify: roles.AdminUserId,
  7267. PType: 2,
  7268. Diagnosis: diagnosis_id,
  7269. }
  7270. err = service.CreateOrder(order)
  7271. if err != nil {
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7273. return
  7274. }
  7275. for _, item := range res.Output.Result {
  7276. temp := strings.Split(item.FeedetlSn, "-")
  7277. var advice_id int64 = 0
  7278. var project_id int64 = 0
  7279. var types int64 = 0
  7280. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7281. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7282. if temp[1] == "1" {
  7283. advice_id = id
  7284. project_id = 0
  7285. } else if temp[1] == "2" {
  7286. advice_id = 0
  7287. project_id = id
  7288. }
  7289. info := &models.HisOrderInfo{
  7290. OrderNumber: order.Number,
  7291. FeedetlSn: item.FeedetlSn,
  7292. UploadDate: time.Now().Unix(),
  7293. AdviceId: advice_id,
  7294. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7295. Cnt: item.Cnt,
  7296. Pric: float64(item.Pric),
  7297. PatientId: his.PatientId,
  7298. PricUplmtAmt: item.PricUplmtAmt,
  7299. SelfpayProp: item.SelfpayProp,
  7300. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7301. OverlmtAmt: item.OverlmtAmt,
  7302. PreselfpayAmt: item.PreselfpayAmt,
  7303. BasMednFlag: item.BasMednFlag,
  7304. MedChrgitmType: item.MedChrgitmType,
  7305. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7306. Status: 1,
  7307. Memo: item.Memo,
  7308. Mtime: time.Now().Unix(),
  7309. InscpScpAmt: item.InscpScpAmt,
  7310. DrtReimFlag: item.DrtReimFlag,
  7311. Ctime: time.Now().Unix(),
  7312. ListSpItemFlag: item.ListSpItemFlag,
  7313. ChldMedcFlag: item.ChldMedcFlag,
  7314. LmtUsedFlag: item.LmtUsedFlag,
  7315. ChrgitmLv: item.ChrgitmLv,
  7316. UserOrgId: adminUser.CurrentOrgId,
  7317. HisPatientId: his.ID,
  7318. OrderId: order.ID,
  7319. ProjectId: project_id,
  7320. Type: types,
  7321. }
  7322. service.CreateOrderInfo(info)
  7323. }
  7324. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7325. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7326. var total float64
  7327. for _, item := range prescriptions {
  7328. if item.Type == 1 { //药品
  7329. for _, subItem := range item.HisDoctorAdviceInfo {
  7330. total = total + (subItem.Price * subItem.PrescribingNumber)
  7331. }
  7332. }
  7333. if item.Type == 2 { //项目
  7334. for _, subItem := range item.HisPrescriptionProject {
  7335. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7336. total = total + (subItem.Price * cnt)
  7337. }
  7338. }
  7339. }
  7340. for _, item := range prescriptions {
  7341. for _, subItem := range item.HisAdditionalCharge {
  7342. total = total + (subItem.Price * float64(subItem.Count))
  7343. }
  7344. }
  7345. allTotal := fmt.Sprintf("%.4f", total)
  7346. if res.Infcode == 0 {
  7347. var rf []*ResultFive
  7348. json.Unmarshal([]byte(his.Iinfo), &rf)
  7349. chrg_bchno := chrg_bchno
  7350. cert_no := his.Certno
  7351. var insutypes []string
  7352. var insutype string
  7353. var is390 int = 0
  7354. var is310 int = 0
  7355. for _, item := range rf {
  7356. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7357. insutypes = append(insutypes, item.Insutype)
  7358. }
  7359. }
  7360. if len(insutypes) == 1 {
  7361. insutype = insutypes[0]
  7362. } else {
  7363. for _, i := range insutypes {
  7364. if i == "390" {
  7365. is390 = 1
  7366. }
  7367. if i == "310" {
  7368. is310 = 1
  7369. }
  7370. }
  7371. }
  7372. if is390 == 1 {
  7373. insutype = "390"
  7374. }
  7375. if is310 == 1 {
  7376. insutype = "310"
  7377. }
  7378. if len(insutypes) == 0 {
  7379. insutype = "310"
  7380. }
  7381. if len(insutypes) == 2 {
  7382. insutype = strconv.FormatInt(his.SocialType, 64)
  7383. }
  7384. //insutype = "390"
  7385. if his.IdCardType == 1 {
  7386. cert_no = his.MedicalInsuranceNumber
  7387. } else {
  7388. cert_no = his.Certno
  7389. }
  7390. var res ResultSeven
  7391. var resSeven10265 ResultSeven10265
  7392. if miConfig.MdtrtareaAdmvs == "421300" {
  7393. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7394. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7395. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7396. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7397. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7398. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7399. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7400. resp, requestErr := http.Get(api)
  7401. if requestErr != nil {
  7402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7403. return
  7404. }
  7405. body, ioErr := ioutil.ReadAll(resp.Body)
  7406. if ioErr != nil {
  7407. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7409. return
  7410. }
  7411. var respJSON map[string]interface{}
  7412. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7413. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7415. return
  7416. }
  7417. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7418. result, _ := json.Marshal(respJSON)
  7419. fmt.Println("log")
  7420. fmt.Println(string(result))
  7421. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7422. utils.ErrorLog("解析失败:%v", err)
  7423. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7424. return
  7425. }
  7426. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7427. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7428. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7429. bas := strings.Split(psn_info.CardInfo, "|")
  7430. if his.IdCardType == 1 {
  7431. cert_no = bas[2]
  7432. } else {
  7433. cert_no = bas[1]
  7434. }
  7435. //江苏地区国家医保医疗类别
  7436. //职工透析:医疗类别选特殊情况门诊9933
  7437. //居民血透门慢: 医疗类别选门诊慢病1402
  7438. //var med_type string
  7439. //if his.Insutype == "310" {
  7440. // if reg_type == 14 {
  7441. // med_type = "9933"
  7442. // } else if reg_type == 11 {
  7443. // med_type = "11"
  7444. //
  7445. // }
  7446. //} else if his.Insutype == "390" {
  7447. // if reg_type == 14 {
  7448. // med_type = "1402"
  7449. // } else if reg_type == 11 {
  7450. // med_type = "11"
  7451. // }
  7452. //}
  7453. var api string
  7454. if miConfig.MdtrtareaAdmvs == "320921" {
  7455. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7456. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7457. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7458. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7459. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7460. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7461. "&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
  7462. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7463. } else {
  7464. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7465. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7466. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7467. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7468. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7469. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7470. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7471. "&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
  7472. }
  7473. resp, requestErr := http.Get(api)
  7474. if requestErr != nil {
  7475. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7476. return
  7477. }
  7478. body, ioErr := ioutil.ReadAll(resp.Body)
  7479. if ioErr != nil {
  7480. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7482. return
  7483. }
  7484. var respJSON map[string]interface{}
  7485. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7486. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7487. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7488. return
  7489. }
  7490. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7491. result, _ := json.Marshal(respJSON)
  7492. fmt.Println("log")
  7493. fmt.Println(string(result))
  7494. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7495. utils.ErrorLog("解析失败:%v", err)
  7496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7497. return
  7498. }
  7499. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7500. res.Output = resSeven10265.Output
  7501. res.ErrMsg = resSeven10265.ErrMsg
  7502. res.Cainfo = resSeven10265.Cainfo
  7503. res.WarnMsg = resSeven10265.WarnMsg
  7504. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7505. res.Infcode = infocode
  7506. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7507. 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)
  7508. var dat map[string]interface{}
  7509. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7510. fmt.Println(dat)
  7511. } else {
  7512. fmt.Println(err)
  7513. }
  7514. saveLog(result, request_log, "2206", "预结算")
  7515. userJSONBytes, _ := json.Marshal(dat)
  7516. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7517. utils.ErrorLog("解析失败:%v", err)
  7518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7519. return
  7520. }
  7521. } else {
  7522. var result string
  7523. var request_log string
  7524. if miConfig.Code == "H15049901371" {
  7525. //赤峰地区国家医保医疗类别
  7526. //职工透析:医疗类别选特殊情况门诊990502
  7527. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7528. var med_type string
  7529. if his.Insutype == "390" {
  7530. if reg_type == 14 {
  7531. med_type = "9933"
  7532. } else if reg_type == 11 {
  7533. med_type = "11"
  7534. }
  7535. } else if his.Insutype == "310" {
  7536. if reg_type == 14 {
  7537. med_type = "990502"
  7538. } else if reg_type == 11 {
  7539. med_type = "11"
  7540. }
  7541. }
  7542. 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)
  7543. } else {
  7544. 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)
  7545. }
  7546. var dat map[string]interface{}
  7547. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7548. fmt.Println(dat)
  7549. } else {
  7550. fmt.Println(err)
  7551. }
  7552. saveLog(result, request_log, "2206", "预结算")
  7553. //userJSONBytes, _ := json.Marshal(dat)
  7554. //
  7555. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7556. // utils.ErrorLog("解析失败:%v", err)
  7557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7558. // return
  7559. //}
  7560. userJSONBytes, _ := json.Marshal(dat)
  7561. if miConfig.Code == "H15049901371" {
  7562. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7563. utils.ErrorLog("解析失败:%v", err)
  7564. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7565. return
  7566. }
  7567. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7568. res.Output = resSeven10265.Output
  7569. res.ErrMsg = resSeven10265.ErrMsg
  7570. res.Cainfo = resSeven10265.Cainfo
  7571. res.WarnMsg = resSeven10265.WarnMsg
  7572. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7573. res.Infcode = infocode
  7574. } else {
  7575. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7576. utils.ErrorLog("解析失败:%v", err)
  7577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7578. return
  7579. }
  7580. }
  7581. }
  7582. if res.Infcode != 0 {
  7583. errlog := &models.HisOrderError{
  7584. UserOrgId: adminUser.CurrentOrgId,
  7585. Ctime: time.Now().Unix(),
  7586. Mtime: time.Now().Unix(),
  7587. Number: chrg_bchno,
  7588. ErrMsg: res.ErrMsg,
  7589. Status: 1,
  7590. PatientId: id,
  7591. RecordTime: recordDateTime,
  7592. Stage: 20,
  7593. }
  7594. service.CreateErrMsgLog(errlog)
  7595. c.ServeSuccessJSON(map[string]interface{}{
  7596. "failed_code": -10,
  7597. "msg": res.ErrMsg,
  7598. })
  7599. return
  7600. } else {
  7601. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7602. order.OrderStatus = 1
  7603. order.IsPre = 1
  7604. order.Status = 1
  7605. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7606. order.SetlId = res.Output.Setlinfo.SetlID
  7607. order.PsnNo = res.Output.Setlinfo.PsnNo
  7608. order.PsnName = res.Output.Setlinfo.PsnName
  7609. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7610. order.Certno = res.Output.Setlinfo.Certno
  7611. order.Gend = res.Output.Setlinfo.Gend
  7612. order.Naty = res.Output.Setlinfo.Naty
  7613. order.Age = res.Output.Setlinfo.Age
  7614. order.Insutype = res.Output.Setlinfo.Insutype
  7615. order.PsnType = res.Output.Setlinfo.PsnType
  7616. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7617. order.SetlTime = res.Output.Setlinfo.SetlTime
  7618. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7619. if res.Output.Setlinfo.MedType == "140101" {
  7620. order.MedType = "14"
  7621. } else {
  7622. order.MedType = res.Output.Setlinfo.MedType
  7623. }
  7624. if reg_type == 1112 {
  7625. order.MedType = "1112"
  7626. }
  7627. if reg_type == 1111 {
  7628. order.MedType = "1111"
  7629. }
  7630. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7631. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7632. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7633. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7634. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7635. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7636. order.HifpPay = res.Output.Setlinfo.HifpPay
  7637. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7638. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7639. order.HifesPay = res.Output.Setlinfo.HifesPay
  7640. order.HifobPay = res.Output.Setlinfo.HifobPay
  7641. order.MafPay = res.Output.Setlinfo.MafPay
  7642. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7643. order.OthPay = res.Output.Setlinfo.OthPay
  7644. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7645. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7646. order.AcctPay = res.Output.Setlinfo.AcctPay
  7647. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7648. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7649. order.Balc = res.Output.Setlinfo.Balc
  7650. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7651. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7652. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7653. order.ClrWay = res.Output.Setlinfo.ClrWay
  7654. order.Creator = order.Creator
  7655. order.Modify = roles.AdminUserId
  7656. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7657. detailStr := string(setlDetail)
  7658. order.SetlDetail = detailStr
  7659. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7660. err = service.UpDateOrder(order)
  7661. if err == nil {
  7662. c.ServeSuccessJSON(map[string]interface{}{
  7663. "msg": "预结算成功",
  7664. })
  7665. } else {
  7666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7667. return
  7668. }
  7669. }
  7670. } else {
  7671. adminUser := c.GetAdminUserInfo()
  7672. errlog := &models.HisOrderError{
  7673. UserOrgId: adminUser.CurrentOrgId,
  7674. Ctime: time.Now().Unix(),
  7675. Mtime: time.Now().Unix(),
  7676. ErrMsg: res.ErrMsg,
  7677. Status: 1,
  7678. PatientId: id,
  7679. RecordTime: recordDateTime,
  7680. Stage: 4,
  7681. }
  7682. service.CreateErrMsgLog(errlog)
  7683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7684. return
  7685. }
  7686. } else {
  7687. adminUser := c.GetAdminUserInfo()
  7688. errlog := &models.HisOrderError{
  7689. UserOrgId: adminUser.CurrentOrgId,
  7690. Ctime: time.Now().Unix(),
  7691. Mtime: time.Now().Unix(),
  7692. ErrMsg: res.ErrMsg,
  7693. Status: 1,
  7694. PatientId: id,
  7695. RecordTime: recordDateTime,
  7696. Stage: 4,
  7697. }
  7698. service.CreateErrMsgLog(errlog)
  7699. c.ServeSuccessJSON(map[string]interface{}{
  7700. "failed_code": -10,
  7701. "msg": res.ErrMsg,
  7702. })
  7703. return
  7704. }
  7705. }
  7706. }
  7707. }
  7708. //退款
  7709. func (c *HisApiController) Refund() {
  7710. order_id, _ := c.GetInt64("order_id")
  7711. admin_user_id, _ := c.GetInt64("admin_user_id")
  7712. adminUser := c.GetAdminUserInfo()
  7713. var order models.HisOrder
  7714. order, _ = service.GetHisOrderByID(order_id)
  7715. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7716. if order.ID == 0 {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7718. return
  7719. }
  7720. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7721. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7722. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7723. if config.IsOpen == 1 { //对接了医保,走医保流程
  7724. var res ResultSixteen
  7725. var resSixteen10265 ResultSixteen10265
  7726. var src_resquest string
  7727. var result string
  7728. if miConfig.MdtrtareaAdmvs == "421300" {
  7729. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7730. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7731. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7732. resp3, requestErr3 := http.Get(api3)
  7733. if requestErr3 != nil {
  7734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7735. return
  7736. }
  7737. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7738. if ioErr3 != nil {
  7739. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7741. return
  7742. }
  7743. var respJSON3 map[string]interface{}
  7744. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7745. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7747. return
  7748. }
  7749. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7750. userJSONBytes3, _ := json.Marshal(respJSON3)
  7751. fmt.Println("log")
  7752. fmt.Println(string(userJSONBytes3))
  7753. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7754. utils.ErrorLog("解析失败:%v", err)
  7755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7756. return
  7757. }
  7758. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7759. var api3 string
  7760. if miConfig.MdtrtareaAdmvs == "320921" {
  7761. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7762. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7763. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7764. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7765. } else {
  7766. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7767. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7768. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7769. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7770. }
  7771. resp3, requestErr3 := http.Get(api3)
  7772. if requestErr3 != nil {
  7773. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7774. return
  7775. }
  7776. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7777. if ioErr3 != nil {
  7778. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7780. return
  7781. }
  7782. var respJSON3 map[string]interface{}
  7783. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7784. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7786. return
  7787. }
  7788. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7789. userJSONBytes3, _ := json.Marshal(respJSON3)
  7790. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7791. utils.ErrorLog("解析失败:%v", err)
  7792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7793. return
  7794. }
  7795. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7796. res.Output = resSixteen10265.Output
  7797. res.ErrMsg = resSixteen10265.ErrMsg
  7798. res.Cainfo = resSixteen10265.Cainfo
  7799. res.WarnMsg = resSixteen10265.WarnMsg
  7800. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7801. res.Infcode = infocode
  7802. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7803. 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)
  7804. var dat map[string]interface{}
  7805. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7806. fmt.Println(dat)
  7807. } else {
  7808. fmt.Println(err)
  7809. }
  7810. saveLog(result, src_resquest, "2208", "退费")
  7811. userJSONBytes, _ := json.Marshal(dat)
  7812. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7813. utils.ErrorLog("解析失败:%v", err)
  7814. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7815. return
  7816. }
  7817. } else {
  7818. if miConfig.Code == "H15049901371" {
  7819. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7820. var dat map[string]interface{}
  7821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7822. fmt.Println(dat)
  7823. } else {
  7824. fmt.Println(err)
  7825. }
  7826. saveLog(result, src_resquest, "2208", "退费")
  7827. userJSONBytes, _ := json.Marshal(dat)
  7828. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7829. utils.ErrorLog("解析失败:%v", err)
  7830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7831. return
  7832. }
  7833. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7834. res.Output = resSixteen10265.Output
  7835. res.ErrMsg = resSixteen10265.ErrMsg
  7836. res.Cainfo = resSixteen10265.Cainfo
  7837. res.WarnMsg = resSixteen10265.WarnMsg
  7838. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7839. res.Infcode = infocode
  7840. } else {
  7841. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7842. var dat map[string]interface{}
  7843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7844. fmt.Println(dat)
  7845. } else {
  7846. fmt.Println(err)
  7847. }
  7848. saveLog(result, src_resquest, "2208", "退费")
  7849. userJSONBytes, _ := json.Marshal(dat)
  7850. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7851. utils.ErrorLog("解析失败:%v", err)
  7852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7853. return
  7854. }
  7855. }
  7856. }
  7857. if res.Infcode == 0 {
  7858. var res2 ResultSix
  7859. var resSix10265 ResultSix10265
  7860. if miConfig.MdtrtareaAdmvs == "421300" {
  7861. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7862. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7863. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7864. resp3, requestErr3 := http.Get(api3)
  7865. if requestErr3 != nil {
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7870. if ioErr3 != nil {
  7871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. return
  7874. }
  7875. var respJSON3 map[string]interface{}
  7876. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7879. return
  7880. }
  7881. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7882. userJSONBytes3, _ := json.Marshal(respJSON3)
  7883. fmt.Println("log")
  7884. fmt.Println(string(userJSONBytes3))
  7885. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7886. utils.ErrorLog("解析失败:%v", err)
  7887. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7888. return
  7889. }
  7890. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7891. var api3 string
  7892. if miConfig.MdtrtareaAdmvs == "320921" {
  7893. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7894. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7895. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7896. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7897. } else {
  7898. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7899. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7900. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7901. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7902. }
  7903. resp3, requestErr3 := http.Get(api3)
  7904. if requestErr3 != nil {
  7905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7906. return
  7907. }
  7908. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7909. if ioErr3 != nil {
  7910. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7912. return
  7913. }
  7914. var respJSON3 map[string]interface{}
  7915. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7916. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7918. return
  7919. }
  7920. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7921. userJSONBytes3, _ := json.Marshal(respJSON3)
  7922. fmt.Println("log")
  7923. fmt.Println(string(userJSONBytes3))
  7924. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7925. utils.ErrorLog("解析失败:%v", err)
  7926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7927. return
  7928. }
  7929. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7930. res2.Output = resSix10265.Output
  7931. res2.ErrMsg = resSix10265.ErrMsg
  7932. res2.Cainfo = resSix10265.Cainfo
  7933. res2.WarnMsg = resSix10265.WarnMsg
  7934. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7935. res2.Infcode = infocode
  7936. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7937. 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)
  7938. var dat map[string]interface{}
  7939. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7940. fmt.Println(dat)
  7941. } else {
  7942. fmt.Println(err)
  7943. }
  7944. saveLog(result2, src_request, "2205", "撤销明细")
  7945. userJSONBytes, _ := json.Marshal(dat)
  7946. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7947. utils.ErrorLog("解析失败:%v", err)
  7948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. return
  7950. }
  7951. } else {
  7952. if miConfig.Code == "H15049901371" {
  7953. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7954. var dat map[string]interface{}
  7955. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7956. fmt.Println(dat)
  7957. } else {
  7958. fmt.Println(err)
  7959. }
  7960. saveLog(result2, src_request, "2205", "撤销明细")
  7961. userJSONBytes, _ := json.Marshal(dat)
  7962. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7963. utils.ErrorLog("解析失败:%v", err)
  7964. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7965. return
  7966. }
  7967. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7968. res2.Output = resSix10265.Output
  7969. res2.ErrMsg = resSix10265.ErrMsg
  7970. res2.Cainfo = resSix10265.Cainfo
  7971. res2.WarnMsg = resSix10265.WarnMsg
  7972. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7973. res2.Infcode = infocode
  7974. } else {
  7975. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7976. var dat map[string]interface{}
  7977. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7978. fmt.Println(dat)
  7979. } else {
  7980. fmt.Println(err)
  7981. }
  7982. saveLog(result2, src_request, "2205", "撤销明细")
  7983. userJSONBytes, _ := json.Marshal(dat)
  7984. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7985. utils.ErrorLog("解析失败:%v", err)
  7986. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7987. return
  7988. }
  7989. }
  7990. }
  7991. if res2.Infcode == 0 {
  7992. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7993. if err == nil {
  7994. //当押金不为零时产生退费记录
  7995. if order.Decimal != 0 {
  7996. tmp := strconv.FormatInt(order.ID, 10)
  7997. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7998. if err != nil {
  7999. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8000. return
  8001. }
  8002. }
  8003. c.ServeSuccessJSON(map[string]interface{}{
  8004. "msg": "退费成功",
  8005. })
  8006. } else {
  8007. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8008. return
  8009. }
  8010. } else {
  8011. c.ServeSuccessJSON(map[string]interface{}{
  8012. "code": -10,
  8013. "msg": res2.ErrMsg,
  8014. })
  8015. }
  8016. } else {
  8017. c.ServeSuccessJSON(map[string]interface{}{
  8018. "code": -10,
  8019. "msg": res.ErrMsg,
  8020. })
  8021. }
  8022. }
  8023. }
  8024. func (c *HisApiController) RefundNumber() {
  8025. record_time := c.GetString("record_time")
  8026. //patient_id, _ := c.GetInt64("patient_id")
  8027. admin_user_id, _ := c.GetInt64("admin_user_id")
  8028. his_patient_id, _ := c.GetInt64("id")
  8029. timeLayout := "2006-01-02"
  8030. loc, _ := time.LoadLocation("Local")
  8031. adminUser := c.GetAdminUserInfo()
  8032. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8033. fmt.Println(err)
  8034. if err != nil {
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8036. return
  8037. }
  8038. recordDateTime := theTime.Unix()
  8039. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8040. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8041. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8042. //order, _ := service.GetHisOrderByID(order_id)
  8043. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8044. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8045. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8046. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8047. if count > 0 {
  8048. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8049. return
  8050. }
  8051. if config.IsOpen == 1 { //对接了医保,走医保流程
  8052. var res2 ResultSix
  8053. var resSix10265 ResultSix10265
  8054. if miConfig.MdtrtareaAdmvs == "421300" {
  8055. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8056. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8057. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8058. resp3, requestErr3 := http.Get(api3)
  8059. if requestErr3 != nil {
  8060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8061. return
  8062. }
  8063. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8064. if ioErr3 != nil {
  8065. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8066. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8067. return
  8068. }
  8069. var respJSON3 map[string]interface{}
  8070. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8071. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8072. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8073. return
  8074. }
  8075. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8076. userJSONBytes3, _ := json.Marshal(respJSON3)
  8077. fmt.Println("log")
  8078. fmt.Println(string(userJSONBytes3))
  8079. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8080. utils.ErrorLog("解析失败:%v", err)
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8082. return
  8083. }
  8084. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8085. var api3 string
  8086. if miConfig.MdtrtareaAdmvs == "320921" {
  8087. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8088. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8089. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8090. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8091. } else {
  8092. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8093. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8094. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8095. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8096. }
  8097. resp3, requestErr3 := http.Get(api3)
  8098. if requestErr3 != nil {
  8099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8100. return
  8101. }
  8102. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8103. if ioErr3 != nil {
  8104. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8106. return
  8107. }
  8108. var respJSON3 map[string]interface{}
  8109. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8110. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8112. return
  8113. }
  8114. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8115. userJSONBytes3, _ := json.Marshal(respJSON3)
  8116. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8117. utils.ErrorLog("解析失败:%v", err)
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8122. res2.Output = resSix10265.Output
  8123. res2.ErrMsg = resSix10265.ErrMsg
  8124. res2.Cainfo = resSix10265.Cainfo
  8125. res2.WarnMsg = resSix10265.WarnMsg
  8126. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8127. res2.Infcode = infocode
  8128. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8129. 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)
  8130. var dat map[string]interface{}
  8131. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8132. fmt.Println(dat)
  8133. } else {
  8134. fmt.Println(err)
  8135. }
  8136. saveLog(result, request, "2202", "退号")
  8137. userJSONBytes, _ := json.Marshal(dat)
  8138. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8139. utils.ErrorLog("解析失败:%v", err)
  8140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8141. return
  8142. }
  8143. } else {
  8144. var api3 string
  8145. if miConfig.Code == "H15049901371" {
  8146. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8147. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8148. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8149. } else {
  8150. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8151. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8152. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8153. }
  8154. resp3, requestErr3 := http.Get(api3)
  8155. if requestErr3 != nil {
  8156. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8157. return
  8158. }
  8159. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8160. if ioErr3 != nil {
  8161. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8162. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8163. return
  8164. }
  8165. var respJSON3 map[string]interface{}
  8166. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8167. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8168. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8169. return
  8170. }
  8171. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8172. userJSONBytes3, _ := json.Marshal(respJSON3)
  8173. if miConfig.Code == "H15049901371" {
  8174. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8180. res2.Output = resSix10265.Output
  8181. res2.ErrMsg = resSix10265.ErrMsg
  8182. res2.Cainfo = resSix10265.Cainfo
  8183. res2.WarnMsg = resSix10265.WarnMsg
  8184. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8185. res2.Infcode = infocode
  8186. } else {
  8187. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8188. utils.ErrorLog("解析失败:%v", err)
  8189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8190. return
  8191. }
  8192. }
  8193. }
  8194. if res2.Infcode == 0 {
  8195. if err == nil {
  8196. c.ServeSuccessJSON(map[string]interface{}{
  8197. "msg": "退号成功",
  8198. })
  8199. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8200. } else {
  8201. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8202. return
  8203. }
  8204. } else {
  8205. c.ServeSuccessJSON(map[string]interface{}{
  8206. "code": -10,
  8207. "msg": res2.ErrMsg,
  8208. })
  8209. }
  8210. } else {
  8211. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8212. //if err == nil {
  8213. // c.ServeSuccessJSON(map[string]interface{}{
  8214. // "msg": "退费成功",
  8215. // })
  8216. //} else {
  8217. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8218. // return
  8219. //}
  8220. }
  8221. }
  8222. func (c *HisApiController) RefundDetail() {
  8223. order_id, _ := c.GetInt64("order_id")
  8224. admin_user_id, _ := c.GetInt64("admin_user_id")
  8225. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8226. number := c.GetString("number")
  8227. record_time := c.GetString("record_time")
  8228. patient_id, _ := c.GetInt64("patient_id")
  8229. //med_type, _ := c.GetInt64("med_type")
  8230. timeLayout := "2006-01-02"
  8231. loc, _ := time.LoadLocation("Local")
  8232. adminUser := c.GetAdminUserInfo()
  8233. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8234. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8235. fmt.Println(err)
  8236. if err != nil {
  8237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8238. return
  8239. }
  8240. recordDateTime := theTime.Unix()
  8241. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8242. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8243. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8244. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8245. var order models.HisOrder
  8246. order, _ = service.GetHisOrderByID(order_id)
  8247. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8248. if config.IsOpen == 1 { //对接了医保,走医保流程
  8249. var res2 ResultSix
  8250. if miConfig.MdtrtareaAdmvs == "421300" {
  8251. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8252. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8253. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8254. resp3, requestErr3 := http.Get(api3)
  8255. if requestErr3 != nil {
  8256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8257. return
  8258. }
  8259. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8260. if ioErr3 != nil {
  8261. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8262. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8263. return
  8264. }
  8265. var respJSON3 map[string]interface{}
  8266. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8267. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8269. return
  8270. }
  8271. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8272. userJSONBytes3, _ := json.Marshal(respJSON3)
  8273. fmt.Println("log")
  8274. fmt.Println(string(userJSONBytes3))
  8275. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8276. utils.ErrorLog("解析失败:%v", err)
  8277. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8278. return
  8279. }
  8280. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8281. if err == nil {
  8282. c.ServeSuccessJSON(map[string]interface{}{
  8283. "msg": "撤销明细成功",
  8284. })
  8285. return
  8286. } else {
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8291. var resSix10265 ResultSix10265
  8292. var api3 string
  8293. if miConfig.MdtrtareaAdmvs == "320921" {
  8294. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8295. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8296. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8297. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8298. } else {
  8299. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8300. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8301. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8302. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8303. }
  8304. resp3, requestErr3 := http.Get(api3)
  8305. if requestErr3 != nil {
  8306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8307. return
  8308. }
  8309. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8310. if ioErr3 != nil {
  8311. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8312. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8313. return
  8314. }
  8315. var respJSON3 map[string]interface{}
  8316. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8317. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8322. userJSONBytes3, _ := json.Marshal(respJSON3)
  8323. fmt.Println("log")
  8324. fmt.Println(string(userJSONBytes3))
  8325. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8326. utils.ErrorLog("解析失败:%v", err)
  8327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8328. return
  8329. }
  8330. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8331. res2.Output = resSix10265.Output
  8332. res2.ErrMsg = resSix10265.ErrMsg
  8333. res2.Cainfo = resSix10265.Cainfo
  8334. res2.WarnMsg = resSix10265.WarnMsg
  8335. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8336. res2.Infcode = infocode
  8337. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8338. if err == nil {
  8339. c.ServeSuccessJSON(map[string]interface{}{
  8340. "msg": "撤销明细成功",
  8341. })
  8342. return
  8343. } else {
  8344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8345. return
  8346. }
  8347. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8348. 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)
  8349. var dat map[string]interface{}
  8350. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8351. fmt.Println(dat)
  8352. } else {
  8353. fmt.Println(err)
  8354. }
  8355. saveLog(result2, src_request, "2205", "撤销明细")
  8356. userJSONBytes, _ := json.Marshal(dat)
  8357. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8358. utils.ErrorLog("解析失败:%v", err)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. if res2.Infcode == 0 {
  8363. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8364. if err == nil {
  8365. c.ServeSuccessJSON(map[string]interface{}{
  8366. "msg": "撤销明细成功",
  8367. })
  8368. return
  8369. } else {
  8370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8371. return
  8372. }
  8373. } else {
  8374. c.ServeSuccessJSON(map[string]interface{}{
  8375. "code": -10,
  8376. "msg": res2.ErrMsg,
  8377. })
  8378. }
  8379. } else {
  8380. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8381. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8382. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8383. resp2, requestErr2 := http.Get(api2)
  8384. if requestErr2 != nil {
  8385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8386. return
  8387. }
  8388. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8389. if ioErr2 != nil {
  8390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8392. return
  8393. }
  8394. var respJSON2 map[string]interface{}
  8395. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8398. return
  8399. }
  8400. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8401. if err == nil {
  8402. c.ServeSuccessJSON(map[string]interface{}{
  8403. "msg": "撤销明细成功",
  8404. })
  8405. return
  8406. } else {
  8407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8408. return
  8409. }
  8410. }
  8411. } else {
  8412. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8413. if err == nil {
  8414. c.ServeSuccessJSON(map[string]interface{}{
  8415. "msg": "退费成功",
  8416. })
  8417. } else {
  8418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8419. return
  8420. }
  8421. }
  8422. }
  8423. //对账
  8424. func (c *HisApiController) GetCheckAccount() {
  8425. start_time := c.GetString("start_time")
  8426. end_time := c.GetString("end_time")
  8427. insutype := c.GetString("insutype")
  8428. clr_type := c.GetString("clr_type")
  8429. clr_org := c.GetString("clr_optins")
  8430. admin_user_id, _ := c.GetInt64("admin_user_id")
  8431. adminUser := c.GetAdminUserInfo()
  8432. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8434. if len(clr_org) == 0 {
  8435. clr_org = miConfig.MdtrtareaAdmvs
  8436. }
  8437. timeLayout := "2006-01-02"
  8438. loc, _ := time.LoadLocation("Local")
  8439. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8440. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8441. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8442. fixmedins_setl_cnt := int64(len(orders))
  8443. var medfee_sumamt float64
  8444. var acct_pay float64
  8445. var fund_pay_sumamt float64
  8446. for _, item := range orders {
  8447. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8448. acct_pay = acct_pay + item.AcctPay
  8449. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8450. }
  8451. var user_name string
  8452. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8453. if role.ID == 0 {
  8454. user_name = "xxx"
  8455. } else {
  8456. user_name = role.UserName
  8457. }
  8458. var res ResultEight
  8459. var res10188 ResultEightFor10188
  8460. if config.IsOpen == 1 {
  8461. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8462. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8463. "insutype=" + insutype +
  8464. "&clr_type=" + clr_type +
  8465. "&setl_optins=" + clr_org +
  8466. "&stmt_begndate=" + start_time +
  8467. "&stm_enddate=" + end_time +
  8468. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8469. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8470. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8471. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8472. "&fixmedins_code=" + miConfig.Code +
  8473. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8474. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8475. "&secret_key=" + miConfig.SecretKey +
  8476. "&org_name=" + miConfig.OrgName +
  8477. "&doctor=" + user_name +
  8478. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8479. fmt.Println(api)
  8480. resp, requestErr := http.Get(api)
  8481. if requestErr != nil {
  8482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8483. return
  8484. }
  8485. body, ioErr := ioutil.ReadAll(resp.Body)
  8486. fmt.Println(body)
  8487. if ioErr != nil {
  8488. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8490. return
  8491. }
  8492. var respJSON map[string]interface{}
  8493. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8494. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8495. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8496. return
  8497. }
  8498. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8499. userJSONBytes, _ := json.Marshal(respJSON)
  8500. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8501. utils.ErrorLog("解析失败:%v", err)
  8502. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8503. return
  8504. }
  8505. res.InfRefmsgid = res10188.InfRefmsgid
  8506. res.Output = res10188.Output
  8507. res.ErrMsg = res10188.ErrMsg
  8508. res.Cainfo = res10188.Cainfo
  8509. res.WarnMsg = res10188.WarnMsg
  8510. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8511. res.Infcode = infocode
  8512. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8513. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8514. "insutype=" + insutype +
  8515. "&clr_type=" + clr_type +
  8516. "&setl_optins=" + clr_org +
  8517. "&stmt_begndate=" + start_time +
  8518. "&stm_enddate=" + end_time +
  8519. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8520. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8521. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8522. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8523. "&fixmedins_code=" + miConfig.Code +
  8524. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8525. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8526. "&secret_key=" + miConfig.SecretKey +
  8527. "&org_name=" + miConfig.OrgName +
  8528. "&doctor=" + user_name
  8529. resp, requestErr := http.Get(api)
  8530. if requestErr != nil {
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. body, ioErr := ioutil.ReadAll(resp.Body)
  8535. if ioErr != nil {
  8536. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8538. return
  8539. }
  8540. var respJSON map[string]interface{}
  8541. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8542. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8543. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8544. return
  8545. }
  8546. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8547. result, _ := json.Marshal(respJSON)
  8548. fmt.Println("log")
  8549. fmt.Println(string(result))
  8550. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8551. utils.ErrorLog("解析失败:%v", err)
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8553. return
  8554. }
  8555. res.InfRefmsgid = res10188.InfRefmsgid
  8556. res.Output = res10188.Output
  8557. res.ErrMsg = res10188.ErrMsg
  8558. res.Cainfo = res10188.Cainfo
  8559. res.WarnMsg = res10188.WarnMsg
  8560. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8561. res.Infcode = infocode
  8562. } else {
  8563. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8564. "insutype=" + insutype +
  8565. "&clr_type=" + clr_type +
  8566. "&setl_optins=" + clr_org +
  8567. "&stmt_begndate=" + start_time +
  8568. "&stm_enddate=" + end_time +
  8569. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8570. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8571. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8572. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8573. "&fixmedins_code=" + miConfig.Code +
  8574. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8575. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8576. "&secret_key=" + miConfig.SecretKey +
  8577. "&org_name=" + miConfig.OrgName +
  8578. "&doctor=" + user_name
  8579. fmt.Println(api)
  8580. resp, requestErr := http.Get(api)
  8581. if requestErr != nil {
  8582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8583. return
  8584. }
  8585. body, ioErr := ioutil.ReadAll(resp.Body)
  8586. fmt.Println(body)
  8587. if ioErr != nil {
  8588. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8589. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8590. return
  8591. }
  8592. var respJSON map[string]interface{}
  8593. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8594. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8595. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8596. return
  8597. }
  8598. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8599. userJSONBytes, _ := json.Marshal(respJSON)
  8600. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8601. utils.ErrorLog("解析失败:%v", err)
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8603. return
  8604. }
  8605. }
  8606. if res.Infcode == 0 {
  8607. if res.Output.Stmtinfo.StmtRslt == "0" {
  8608. micc := &models.MedicalInsuranceCostCompare{
  8609. StartTime: startime.Unix(),
  8610. EndTime: endtime.Unix(),
  8611. Insutype: insutype,
  8612. CheckType: 1,
  8613. Num: fixmedins_setl_cnt,
  8614. Mtime: time.Now().Unix(),
  8615. Status: 1,
  8616. UserOrgId: adminUser.CurrentOrgId,
  8617. CostTotal: medfee_sumamt,
  8618. FuncTotal: fund_pay_sumamt,
  8619. PsnPay: acct_pay,
  8620. Creator: admin_user_id,
  8621. Ctime: time.Now().Unix(),
  8622. ClrType: clr_type,
  8623. }
  8624. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8625. if err == nil {
  8626. c.ServeSuccessJSON(map[string]interface{}{
  8627. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8628. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8629. })
  8630. } else {
  8631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8632. }
  8633. } else {
  8634. c.ServeSuccessJSON(map[string]interface{}{
  8635. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8636. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8637. })
  8638. }
  8639. } else {
  8640. c.ServeSuccessJSON(map[string]interface{}{
  8641. "code": -10,
  8642. "msg": res.ErrMsg,
  8643. })
  8644. }
  8645. }
  8646. }
  8647. func (c *HisApiController) Check310() {
  8648. adminUser := c.GetAdminUserInfo()
  8649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8650. var user_name string
  8651. user_name = "高慧裕"
  8652. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8653. "insutype=" + "310" +
  8654. "&clr_type=" + "" +
  8655. "&setl_optins=" + "441202" +
  8656. "&stmt_begndate=" + "2022-03-01" +
  8657. "&stm_enddate=" + "2022-03-31" +
  8658. "&medfee_sumamt=" + "194930.12" +
  8659. "&fund_pay_sumamt=" + "188741.46" +
  8660. "&acct_pay=" + "0" +
  8661. "&fixmedins_setl_cnt=" + "452" +
  8662. "&fixmedins_code=" + miConfig.Code +
  8663. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8664. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8665. "&secret_key=" + miConfig.SecretKey +
  8666. "&org_name=" + miConfig.OrgName +
  8667. "&doctor=" + user_name
  8668. fmt.Println(api)
  8669. resp, requestErr := http.Get(api)
  8670. if requestErr != nil {
  8671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8672. return
  8673. }
  8674. body, ioErr := ioutil.ReadAll(resp.Body)
  8675. fmt.Println(body)
  8676. if ioErr != nil {
  8677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8679. return
  8680. }
  8681. var respJSON map[string]interface{}
  8682. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8685. return
  8686. }
  8687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8688. userJSONBytes, _ := json.Marshal(respJSON)
  8689. var res ResultEight
  8690. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8691. utils.ErrorLog("解析失败:%v", err)
  8692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8693. return
  8694. }
  8695. }
  8696. func (c *HisApiController) Check390() {
  8697. adminUser := c.GetAdminUserInfo()
  8698. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8699. var user_name string
  8700. user_name = "高慧裕"
  8701. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8702. "insutype=" + "390" +
  8703. "&clr_type=" + "" +
  8704. "&setl_optins=" + "441202" +
  8705. "&stmt_begndate=" + "2022-03-01" +
  8706. "&stm_enddate=" + "2022-03-31" +
  8707. "&medfee_sumamt=" + "1068448.89" +
  8708. "&fund_pay_sumamt=" + "1014677.62" +
  8709. "&acct_pay=" + "0" +
  8710. "&fixmedins_setl_cnt=" + "1950" +
  8711. "&fixmedins_code=" + miConfig.Code +
  8712. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8713. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8714. "&secret_key=" + miConfig.SecretKey +
  8715. "&org_name=" + miConfig.OrgName +
  8716. "&doctor=" + user_name
  8717. fmt.Println(api)
  8718. resp, requestErr := http.Get(api)
  8719. if requestErr != nil {
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. body, ioErr := ioutil.ReadAll(resp.Body)
  8724. fmt.Println(body)
  8725. if ioErr != nil {
  8726. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8727. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8728. return
  8729. }
  8730. var respJSON map[string]interface{}
  8731. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8732. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8734. return
  8735. }
  8736. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8737. userJSONBytes, _ := json.Marshal(respJSON)
  8738. var res ResultEight
  8739. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8740. utils.ErrorLog("解析失败:%v", err)
  8741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8742. return
  8743. }
  8744. }
  8745. //对账明细
  8746. func (c *HisApiController) GetCheckDetailAccount() {
  8747. start_time := c.GetString("start_time")
  8748. end_time := c.GetString("end_time")
  8749. admin_user_id, _ := c.GetInt64("admin_user_id")
  8750. adminUser := c.GetAdminUserInfo()
  8751. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8752. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8753. timeLayout := "2006-01-02"
  8754. loc, _ := time.LoadLocation("Local")
  8755. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8756. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8757. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8758. rand.Seed(time.Now().UnixNano())
  8759. num := rand.Intn(30000)
  8760. Mkdir(miConfig.OrgName)
  8761. file := strconv.FormatInt(int64(num), 10)
  8762. file_name := file + ".txt"
  8763. zip_name := file + ".zip"
  8764. zip_path := miConfig.OrgName + "/" + zip_name
  8765. file_path := miConfig.OrgName + "/" + file_name
  8766. decimal.DivisionPrecision = 2
  8767. var medfee_sumamt float64
  8768. var psn_cash_pay float64
  8769. var fund_pay_sumamt float64
  8770. fixmedins_setl_cnt := int64(len(orders))
  8771. for _, item := range orders {
  8772. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8773. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8774. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8775. }
  8776. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8777. defer f.Close()
  8778. if err != nil {
  8779. fmt.Println(err.Error())
  8780. } else {
  8781. for _, item := range orders {
  8782. var refd_setl_flag string
  8783. if item.OrderStatus == 2 {
  8784. refd_setl_flag = "0"
  8785. var str string
  8786. str = item.SetlId + " " +
  8787. item.MdtrtId + " " +
  8788. item.PsnNo + " " +
  8789. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8790. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8791. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8792. _, err = f.Write([]byte(str))
  8793. }
  8794. if item.OrderStatus == 3 {
  8795. var str string
  8796. str = item.SetlId + " " +
  8797. item.MdtrtId + " " +
  8798. item.PsnNo + " " +
  8799. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8800. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8801. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8802. _, err = f.Write([]byte(str))
  8803. var str2 string
  8804. str2 = item.SetlId + " " +
  8805. item.MdtrtId + " " +
  8806. item.PsnNo + " " +
  8807. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8808. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8809. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8810. _, err = f.Write([]byte(str2))
  8811. }
  8812. }
  8813. }
  8814. Zip(file_path, zip_path)
  8815. fmt.Println(ReadFile(zip_path))
  8816. fmt.Println(string(ReadFile(zip_path)))
  8817. if config.IsOpen == 1 {
  8818. var user_name string
  8819. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8820. if role.ID == 0 {
  8821. user_name = "管理员"
  8822. } else {
  8823. user_name = role.UserName
  8824. }
  8825. baseParams := models.BaseParams{
  8826. SecretKey: miConfig.SecretKey,
  8827. FixmedinsCode: miConfig.Code,
  8828. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8829. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8830. OrgName: miConfig.OrgName,
  8831. Doctor: user_name,
  8832. }
  8833. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8834. var dat map[string]interface{}
  8835. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8836. fmt.Println(dat)
  8837. } else {
  8838. fmt.Println(err)
  8839. }
  8840. userJSONBytes, _ := json.Marshal(dat)
  8841. var res ResultNine
  8842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8843. utils.ErrorLog("解析失败:%v", err)
  8844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8845. return
  8846. }
  8847. if res.Infcode == 0 {
  8848. fileNo := res.Output.FileQuryNo
  8849. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8850. "file_qury_no=" + fileNo +
  8851. "&setl_optins=" + "定点医保中心" +
  8852. "&stmt_begndate=" + start_time +
  8853. "&stm_enddate=" + end_time +
  8854. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8855. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8856. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8857. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8858. "&fixmedins_code=" + miConfig.Code +
  8859. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8860. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8861. "&secret_key=" + miConfig.SecretKey +
  8862. "&org_name=" + miConfig.OrgName +
  8863. "&doctor=" + user_name
  8864. resp, requestErr := http.Get(api)
  8865. if requestErr != nil {
  8866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8867. return
  8868. }
  8869. body, ioErr := ioutil.ReadAll(resp.Body)
  8870. if ioErr != nil {
  8871. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8873. return
  8874. }
  8875. var respJSON map[string]interface{}
  8876. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8877. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8879. return
  8880. }
  8881. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8882. userJSONBytes, _ := json.Marshal(respJSON)
  8883. var res ResultTen
  8884. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8885. utils.ErrorLog("解析失败:%v", err)
  8886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8887. return
  8888. }
  8889. if res.Infcode == 0 {
  8890. service.Gdyb9102(baseParams, zip_name, fileNo)
  8891. micc := &models.MedicalInsuranceCostCompare{
  8892. StartTime: startime.Unix(),
  8893. EndTime: endtime.Unix(),
  8894. Insutype: "0",
  8895. CheckType: 2,
  8896. Num: fixmedins_setl_cnt,
  8897. Mtime: time.Now().Unix(),
  8898. Status: 1,
  8899. UserOrgId: adminUser.CurrentOrgId,
  8900. CostTotal: medfee_sumamt,
  8901. FuncTotal: fund_pay_sumamt,
  8902. PsnPay: psn_cash_pay,
  8903. Creator: admin_user_id,
  8904. Ctime: time.Now().Unix(),
  8905. }
  8906. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8907. c.ServeSuccessJSON(map[string]interface{}{
  8908. "msg": "明细对账成功",
  8909. })
  8910. }
  8911. } else {
  8912. }
  8913. }
  8914. }
  8915. type CustomOrderInfo struct {
  8916. Name string
  8917. Spec string
  8918. Unit string
  8919. Count float64
  8920. Price float64
  8921. Total float64
  8922. }
  8923. func (c *HisApiController) GetSettleAccounts() {
  8924. //id, _ := c.GetInt64("id")
  8925. //record_time := c.GetString("record_time")
  8926. order_id, _ := c.GetInt64("order_id")
  8927. admin_user_id, _ := c.GetInt64("admin_user_id")
  8928. //timeLayout := "2006-01-02"
  8929. //loc, _ := time.LoadLocation("Local")
  8930. //
  8931. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8932. //if err != nil {
  8933. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8934. // return
  8935. //}
  8936. //recordDateTime := theTime.Unix()
  8937. adminUser := c.GetAdminUserInfo()
  8938. order, _ := service.GetHisOrderByID(order_id)
  8939. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8940. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8941. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8942. orderInfos = append(orderInfos, orderInfos_two...)
  8943. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8944. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8945. var diagnosis_ids []string
  8946. if his.ID > 0 {
  8947. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8948. } else {
  8949. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8950. }
  8951. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8952. var dia_config []*models.HisXtDiagnoseConfig
  8953. var name string
  8954. for _, item := range diagnosis_ids {
  8955. id, _ := strconv.ParseInt(item, 10, 64)
  8956. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8957. dia_config = append(dia_config, &diagnosisConfig)
  8958. if len(name) == 0 {
  8959. name = diagnosisConfig.ClassName
  8960. } else {
  8961. name = name + "," + diagnosisConfig.ClassName
  8962. }
  8963. }
  8964. var bedCostTotal float64 = 0 //床位总费
  8965. var bedCostSelfTotal float64 = 0 //床位自费
  8966. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8967. var operationCostTotal float64 = 0 //手术费
  8968. var operationCostSelfTotal float64 = 0 //手术费
  8969. var operationCostPartSelfTotal float64 = 0 //手术费
  8970. var otherCostTotal float64 = 0 //其他费用
  8971. var otherCostSelfTotal float64 = 0 //其他费用
  8972. var otherCostPartSelfTotal float64 = 0 //其他费用
  8973. var materialCostTotal float64 = 0 //材料费
  8974. var materialCostSelfTotal float64 = 0 //材料费
  8975. var materialCostPartSelfTotal float64 = 0 //材料费
  8976. var westernMedicineCostTotal float64 = 0 //西药费
  8977. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8978. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8979. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8980. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8981. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8982. var checkCostTotal float64 = 0 //检查费
  8983. var checkCostSelfTotal float64 = 0 //检查费
  8984. var checkCostPartSelfTotal float64 = 0 //检查费
  8985. var laboratoryCostTotal float64 = 0 //化验费
  8986. var laboratoryCostSelfTotal float64 = 0 //化验费
  8987. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8988. var treatCostTotal float64 = 0 //治疗费用
  8989. var treatCostSelfTotal float64 = 0 //治疗费用
  8990. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8991. decimal.DivisionPrecision = 2
  8992. for _, item := range orderInfos {
  8993. if item.MedChrgitmType == "01" { //床位费
  8994. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8995. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8996. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8997. }
  8998. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8999. if item.MedChrgitmType == "03" { //检查费
  9000. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9001. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9002. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9003. }
  9004. } else {
  9005. if item.MedChrgitmType == "03" { //检查费
  9006. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9007. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9008. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9009. }
  9010. }
  9011. if item.MedChrgitmType == "04" { //化验费
  9012. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9013. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9014. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9015. }
  9016. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9017. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9018. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9019. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9020. }
  9021. if item.MedChrgitmType == "06" { //手术费
  9022. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9023. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9024. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9025. }
  9026. if item.MedChrgitmType == "08" { //材料费
  9027. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9028. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9029. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9030. }
  9031. if item.MedChrgitmType == "09" { //西药费
  9032. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9033. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9034. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9035. }
  9036. if item.MedChrgitmType == "11" { //中成费
  9037. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9038. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9039. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9040. }
  9041. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9042. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9043. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9044. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9045. }
  9046. }
  9047. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9048. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9049. var user_name string
  9050. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9051. if role.ID == 0 {
  9052. user_name = "管理员"
  9053. } else {
  9054. user_name = role.UserName
  9055. }
  9056. baseParams := models.BaseParams{
  9057. SecretKey: miConfig.SecretKey,
  9058. FixmedinsCode: miConfig.Code,
  9059. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9060. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9061. OrgName: miConfig.OrgName,
  9062. Doctor: user_name,
  9063. }
  9064. businessParams := models.BusinessParams{
  9065. PsnNo: order.PsnNo,
  9066. MdtrtId: order.MdtrtId,
  9067. SetlId: order.SetlId,
  9068. }
  9069. var res ResultEleven
  9070. var resEleven10265 ResultEleven10265
  9071. if config.IsOpen == 1 {
  9072. if miConfig.MdtrtareaAdmvs == "421300" {
  9073. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9074. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9075. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9076. resp, requestErr := http.Get(api)
  9077. if requestErr != nil {
  9078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9079. return
  9080. }
  9081. body, ioErr := ioutil.ReadAll(resp.Body)
  9082. if ioErr != nil {
  9083. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9085. return
  9086. }
  9087. var respJSON map[string]interface{}
  9088. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9089. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9091. return
  9092. }
  9093. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9094. result, _ := json.Marshal(respJSON)
  9095. fmt.Println("log")
  9096. fmt.Println(string(result))
  9097. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9098. utils.ErrorLog("解析失败:%v", err)
  9099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9100. return
  9101. }
  9102. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9103. var api string
  9104. if miConfig.MdtrtareaAdmvs == "320921" {
  9105. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9106. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9107. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9108. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9109. } else {
  9110. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9111. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9112. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9113. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9114. }
  9115. resp, requestErr := http.Get(api)
  9116. if requestErr != nil {
  9117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9118. return
  9119. }
  9120. body, ioErr := ioutil.ReadAll(resp.Body)
  9121. if ioErr != nil {
  9122. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9124. return
  9125. }
  9126. var respJSON map[string]interface{}
  9127. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9128. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9130. return
  9131. }
  9132. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9133. result, _ := json.Marshal(respJSON)
  9134. fmt.Println("log")
  9135. fmt.Println(string(result))
  9136. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9137. utils.ErrorLog("解析失败:%v", err)
  9138. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9139. return
  9140. }
  9141. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9142. res.Output = resEleven10265.Output
  9143. res.ErrMsg = resEleven10265.ErrMsg
  9144. res.Cainfo = resEleven10265.Cainfo
  9145. res.WarnMsg = resEleven10265.WarnMsg
  9146. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9147. res.Infcode = infocode
  9148. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9149. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9150. saveLog(result, requestLog, "5203", "结算单")
  9151. var dat map[string]interface{}
  9152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9153. fmt.Println(dat)
  9154. } else {
  9155. fmt.Println(err)
  9156. }
  9157. userJSONBytes, _ := json.Marshal(dat)
  9158. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9159. utils.ErrorLog("解析失败:%v", err)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9164. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9165. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9166. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9167. resp, requestErr := http.Get(api)
  9168. if requestErr != nil {
  9169. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9170. return
  9171. }
  9172. body, ioErr := ioutil.ReadAll(resp.Body)
  9173. if ioErr != nil {
  9174. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. var respJSON map[string]interface{}
  9179. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9180. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9182. return
  9183. }
  9184. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9185. result, _ := json.Marshal(respJSON)
  9186. fmt.Println("log")
  9187. fmt.Println(string(result))
  9188. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9189. utils.ErrorLog("解析失败:%v", err)
  9190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9191. return
  9192. }
  9193. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9194. res.Output = resEleven10265.Output
  9195. res.ErrMsg = resEleven10265.ErrMsg
  9196. res.Cainfo = resEleven10265.Cainfo
  9197. res.WarnMsg = resEleven10265.WarnMsg
  9198. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9199. res.Infcode = infocode
  9200. } else {
  9201. result := service.Gdyb5203(baseParams, businessParams)
  9202. //service.Gdyb5204(baseParams, businessParams)
  9203. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9204. var dat map[string]interface{}
  9205. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9206. fmt.Println(dat)
  9207. } else {
  9208. fmt.Println(err)
  9209. }
  9210. userJSONBytes, _ := json.Marshal(dat)
  9211. if miConfig.Code == "H15049901371" {
  9212. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9213. utils.ErrorLog("解析失败:%v", err)
  9214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9215. return
  9216. }
  9217. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9218. res.Output = resEleven10265.Output
  9219. res.ErrMsg = resEleven10265.ErrMsg
  9220. res.Cainfo = resEleven10265.Cainfo
  9221. res.WarnMsg = resEleven10265.WarnMsg
  9222. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9223. res.Infcode = infocode
  9224. } else {
  9225. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9226. utils.ErrorLog("解析失败:%v", err)
  9227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9228. return
  9229. }
  9230. }
  9231. }
  9232. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9233. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9234. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9235. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9236. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9237. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9238. var doctor_name string
  9239. if roles.ID == 0 {
  9240. doctor_name = "管理员"
  9241. } else {
  9242. doctor_name = roles.UserName
  9243. }
  9244. yiliao_leibie := ""
  9245. switch order.MedType {
  9246. case "11":
  9247. yiliao_leibie = "普通门诊"
  9248. break
  9249. case "12":
  9250. yiliao_leibie = "门诊挂号"
  9251. break
  9252. case "13":
  9253. yiliao_leibie = "急诊"
  9254. break
  9255. case "14":
  9256. yiliao_leibie = "门诊特殊病"
  9257. break
  9258. case "15":
  9259. yiliao_leibie = "门诊统筹"
  9260. break
  9261. case "16":
  9262. yiliao_leibie = "门诊慢性病"
  9263. break
  9264. case "21":
  9265. yiliao_leibie = "普通住院"
  9266. break
  9267. }
  9268. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9269. if res.Infcode == 0 {
  9270. c.ServeSuccessJSON(map[string]interface{}{
  9271. "diagnosis": name,
  9272. "order_infos": orderInfos,
  9273. "number": order.MdtrtId,
  9274. "date": order.SettleAccountsDate,
  9275. "charge_admin": charge_admin,
  9276. "printor_admin": printor_admin,
  9277. "info": res.Output.Setlinfo,
  9278. "order": order,
  9279. "bedCostTotal": bedCostTotal,
  9280. "bedCostSelfTotal": bedCostSelfTotal,
  9281. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9282. "operationCostTotal": operationCostTotal,
  9283. "operationCostSelfTotal": operationCostSelfTotal,
  9284. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9285. "otherCostTotal": otherCostTotal,
  9286. "otherCostSelfTotal": otherCostSelfTotal,
  9287. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9288. "materialCostTotal": materialCostTotal,
  9289. "materialCostSelfTotal": materialCostSelfTotal,
  9290. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9291. "westernMedicineCostTotal": westernMedicineCostTotal,
  9292. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9293. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9294. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9295. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9296. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9297. "checkCostTotal": checkCostTotal,
  9298. "checkCostSelfTotal": checkCostSelfTotal,
  9299. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9300. "laboratoryCostTotal": laboratoryCostTotal,
  9301. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9302. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9303. "treatCostTotal": treatCostTotal,
  9304. "treatCostSelfTotal": treatCostSelfTotal,
  9305. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9306. "doctor_info": doctor_info,
  9307. "doctor_code": adminRole_two.DoctorCode,
  9308. "doctor_name": doctor_name,
  9309. "health_card_no": order.PsnNo,
  9310. "department": departments.Name,
  9311. "yiliao_leibie": yiliao_leibie,
  9312. "after_money": order.AccountPrice,
  9313. "patient": patient,
  9314. "org_name": miConfig.OrgName,
  9315. "org_code": miConfig.Code,
  9316. "order_number": order.Number,
  9317. "his_hospital": his_hospital,
  9318. "his": his,
  9319. "dia_config": dia_config,
  9320. //"check_order_info": cus_slice,
  9321. })
  9322. }
  9323. }
  9324. }
  9325. func (c *HisApiController) CheckTreatment() {
  9326. patient_id, _ := c.GetInt64("patient_id")
  9327. id_card_no := c.GetString("id_card_no")
  9328. insutype := c.GetString("insutype")
  9329. med_type := c.GetString("med_type")
  9330. admin_user_id, _ := c.GetInt64("admin_user_id")
  9331. adminUser := c.GetAdminUserInfo()
  9332. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9333. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9334. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9335. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9336. if miConfig.MdtrtareaAdmvs == "421300" {
  9337. var res ResultTwo
  9338. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9339. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9340. "&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)
  9341. resp, requestErr := http.Get(api)
  9342. if requestErr != nil {
  9343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9344. return
  9345. }
  9346. body, ioErr := ioutil.ReadAll(resp.Body)
  9347. if ioErr != nil {
  9348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. return
  9351. }
  9352. var respJSON map[string]interface{}
  9353. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9356. return
  9357. }
  9358. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9359. result, _ := json.Marshal(respJSON)
  9360. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9361. utils.ErrorLog("解析失败:%v", err)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. if res.Infcode == 0 {
  9366. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9367. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9368. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9369. resp, requestErr := http.Get(api)
  9370. if requestErr != nil {
  9371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9372. return
  9373. }
  9374. body, ioErr := ioutil.ReadAll(resp.Body)
  9375. if ioErr != nil {
  9376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9378. return
  9379. }
  9380. var respJSON map[string]interface{}
  9381. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9384. return
  9385. }
  9386. var res Result2001
  9387. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9388. result2, _ := json.Marshal(respJSON)
  9389. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9390. utils.ErrorLog("解析失败:%v", err)
  9391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9392. return
  9393. }
  9394. if res.Infcode == 0 {
  9395. c.ServeSuccessJSON(map[string]interface{}{
  9396. "msg": res.Output.Trtinfo,
  9397. })
  9398. }
  9399. } else {
  9400. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9401. return
  9402. }
  9403. } else {
  9404. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9405. var dat map[string]interface{}
  9406. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9407. fmt.Println(dat)
  9408. } else {
  9409. fmt.Println(err)
  9410. }
  9411. userJSONBytes, _ := json.Marshal(dat)
  9412. var res ResultTwo
  9413. var res10265 ResultTwo10265
  9414. if miConfig.Code == "H15049901371" {
  9415. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9416. utils.ErrorLog("解析失败:%v", err)
  9417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9418. return
  9419. }
  9420. res.ErrMsg = res10265.ErrMsg
  9421. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9422. res.Infcode = infocode
  9423. res.Output = res10265.Output
  9424. res.InfRefmsgid = res10265.InfRefmsgid
  9425. } else {
  9426. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9427. utils.ErrorLog("解析失败:%v", err)
  9428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9429. return
  9430. }
  9431. }
  9432. var user_name string
  9433. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9434. if role.ID == 0 {
  9435. user_name = "xxx"
  9436. } else {
  9437. user_name = role.UserName
  9438. }
  9439. baseParams := models.BaseParams{
  9440. SecretKey: miConfig.SecretKey,
  9441. FixmedinsCode: miConfig.Code,
  9442. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9443. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9444. OrgName: miConfig.OrgName,
  9445. Doctor: user_name,
  9446. }
  9447. if config.IsOpen == 1 {
  9448. if miConfig.Code == "H15049901371" {
  9449. if med_type == "14" {
  9450. if insutype == "390" {
  9451. med_type = "9933"
  9452. } else if insutype == "310" {
  9453. med_type = "990502"
  9454. }
  9455. } else if med_type == "11" {
  9456. med_type = "11"
  9457. }
  9458. }
  9459. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9460. var dat map[string]interface{}
  9461. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9462. fmt.Println(dat)
  9463. } else {
  9464. fmt.Println(err)
  9465. }
  9466. var res Result2001
  9467. var res10265 Result2001Org10265
  9468. if miConfig.Code == "H15049901371" {
  9469. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9470. utils.ErrorLog("解析失败:%v", err)
  9471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9472. return
  9473. }
  9474. res.ErrMsg = res10265.ErrMsg
  9475. res.Output = res10265.Output
  9476. res.InfRefmsgid = res10265.InfRefmsgid
  9477. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9478. res.Infcode = infocode
  9479. } else {
  9480. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9481. utils.ErrorLog("解析失败:%v", err)
  9482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9483. return
  9484. }
  9485. }
  9486. if res.Infcode == 0 {
  9487. c.ServeSuccessJSON(map[string]interface{}{
  9488. "msg": res.Output.Trtinfo,
  9489. })
  9490. }
  9491. }
  9492. }
  9493. }
  9494. //func (c *HisApiController) PutRecord() {
  9495. // id, _ := c.GetInt64("id")
  9496. // record_time := c.GetString("record_time")
  9497. // timeLayout := "2006-01-02"
  9498. // loc, _ := time.LoadLocation("Local")
  9499. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9500. // if err != nil {
  9501. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9502. // return
  9503. // }
  9504. // recordDateTime := theTime.Unix()
  9505. //
  9506. // adminInfo := c.GetAdminUserInfo()
  9507. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9508. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9509. //
  9510. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9511. //
  9512. // fmt.Println(miConfig.SecretKey)
  9513. //
  9514. // if patient == nil {
  9515. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9516. // return
  9517. // }
  9518. // if len(patient.IdCardNo) == 0 {
  9519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9520. // return
  9521. // }
  9522. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9523. // if config.IsOpen == 1 {
  9524. // 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
  9525. // resp, requestErr := http.Get(api)
  9526. // if requestErr != nil {
  9527. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9528. // return
  9529. // }
  9530. // defer resp.Body.Close()
  9531. // body, ioErr := ioutil.ReadAll(resp.Body)
  9532. // if ioErr != nil {
  9533. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9534. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9535. // return
  9536. // }
  9537. // var respJSON map[string]interface{}
  9538. //
  9539. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9540. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9542. // return
  9543. // }
  9544. //
  9545. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9546. // userJSONBytes, _ := json.Marshal(userJSON)
  9547. // var res ResultTwo
  9548. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9549. // utils.ErrorLog("解析失败:%v", err)
  9550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9551. // return
  9552. // }
  9553. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9554. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9555. // infoStr := string(Iinfos)
  9556. // idetinfoStr := string(Idetinfos)
  9557. //
  9558. // if res.Infcode == 0 {
  9559. // his := models.VMHisPatient{
  9560. // Status: 1,
  9561. // Ctime: time.Now().Unix(),
  9562. // Mtime: time.Now().Unix(),
  9563. // PsnNo: res.Output.Baseinfo.PsnNo,
  9564. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9565. // Certno: res.Output.Baseinfo.Certno,
  9566. // PsnName: res.Output.Baseinfo.PsnName,
  9567. // Gend: res.Output.Baseinfo.Gend,
  9568. // Naty: res.Output.Baseinfo.Naty,
  9569. // Brdy: res.Output.Baseinfo.Brdy,
  9570. // Age: res.Output.Baseinfo.Age,
  9571. // Iinfo: infoStr,
  9572. // Idetinfo: idetinfoStr,
  9573. // PatientId: patient.ID,
  9574. // RecordDate: theTime.Unix(),
  9575. // UserOrgId: adminInfo.CurrentOrgId,
  9576. // AdminUserId: adminInfo.AdminUser.Id,
  9577. // IsReturn: 1,
  9578. // }
  9579. //
  9580. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9581. // //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")
  9582. // //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")
  9583. //
  9584. // //var dat map[string]interface{}
  9585. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9586. // // fmt.Println(dat)
  9587. // //} else {
  9588. // // fmt.Println(err)
  9589. // //}
  9590. //
  9591. // var dat2 map[string]interface{}
  9592. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9593. // fmt.Println(dat2)
  9594. // } else {
  9595. // fmt.Println(err)
  9596. // }
  9597. //
  9598. // } else {
  9599. // adminUser := c.GetAdminUserInfo()
  9600. // errlog := &models.HisOrderError{
  9601. // UserOrgId: adminUser.CurrentOrgId,
  9602. // Ctime: time.Now().Unix(),
  9603. // Mtime: time.Now().Unix(),
  9604. // ErrMsg: res.ErrMsg,
  9605. // Status: 1,
  9606. // PatientId: id,
  9607. // RecordTime: recordDateTime,
  9608. // Stage: 1,
  9609. // }
  9610. // service.CreateErrMsgLog(errlog)
  9611. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9612. // return
  9613. // }
  9614. // }
  9615. //
  9616. //}
  9617. //func (c *HisApiController) GetUploadDiag() {
  9618. // id, _ := c.GetInt64("id")
  9619. // record_time := c.GetString("record_time")
  9620. //
  9621. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9622. // sick_type, _ := c.GetInt64("sick_type")
  9623. // reg_type, _ := c.GetInt64("reg_type")
  9624. //
  9625. // timeLayout := "2006-01-02"
  9626. // loc, _ := time.LoadLocation("Local")
  9627. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9628. // if err != nil {
  9629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9630. // return
  9631. // }
  9632. //
  9633. // var patientPrescription models.HisPrescriptionInfo
  9634. // recordDateTime := theTime.Unix()
  9635. // adminInfo := c.GetAdminUserInfo()
  9636. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9637. //
  9638. // if patientPrescription.ID == 0 {
  9639. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9640. // }
  9641. //
  9642. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9643. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9644. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9645. // sickConfig, _ := service.FindSickById(sick_type)
  9646. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9647. //
  9648. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9649. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9650. // "&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 +
  9651. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9652. // resp2, requestErr2 := http.Get(api2)
  9653. // if requestErr2 != nil {
  9654. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9655. // return
  9656. // }
  9657. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9658. // if ioErr2 != nil {
  9659. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9661. // return
  9662. // }
  9663. // var respJSON2 map[string]interface{}
  9664. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9665. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9666. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9667. // return
  9668. // }
  9669. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9670. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9671. //
  9672. // var res2 ResultSix
  9673. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9674. // utils.ErrorLog("解析失败:%v", err)
  9675. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9676. // return
  9677. // }
  9678. // if res2.Infcode != 0 {
  9679. // adminUser := c.GetAdminUserInfo()
  9680. // errlog := &models.HisOrderError{
  9681. // UserOrgId: adminUser.CurrentOrgId,
  9682. // Ctime: time.Now().Unix(),
  9683. // Mtime: time.Now().Unix(),
  9684. // ErrMsg: res2.ErrMsg,
  9685. // Status: 1,
  9686. // PatientId: id,
  9687. // RecordTime: recordDateTime,
  9688. // Stage: 3,
  9689. // }
  9690. // service.CreateErrMsgLog(errlog)
  9691. //
  9692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9693. // return
  9694. // }
  9695. //
  9696. // c.ServeSuccessJSON(map[string]interface{}{
  9697. // "msg": "上传成功",
  9698. // })
  9699. //
  9700. //}
  9701. type QueryResult struct {
  9702. ID int64
  9703. Name string
  9704. Code string
  9705. List_type_code string
  9706. }
  9707. func (c *HisApiController) GetCheckCode() {
  9708. ids_str := c.GetString("ids")
  9709. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9710. ids_arr := strings.Split(ids_str, ",")
  9711. var queryResult []QueryResult
  9712. ids := make([]int64, 0)
  9713. for _, item := range ids_arr {
  9714. id, _ := strconv.ParseInt(item, 10, 64)
  9715. ids = append(ids, id)
  9716. }
  9717. if record_type == 1 {
  9718. drugs, _ := service.GetBatchDrugList(ids)
  9719. for _, item := range drugs {
  9720. result := QueryResult{
  9721. ID: item.ID,
  9722. Name: item.DrugName,
  9723. Code: item.MedicalInsuranceNumber,
  9724. List_type_code: "101",
  9725. }
  9726. queryResult = append(queryResult, result)
  9727. }
  9728. } else if record_type == 2 {
  9729. goods, _ := service.GetBatchGoodInformationList(ids)
  9730. for _, item := range goods {
  9731. result := QueryResult{
  9732. ID: item.ID,
  9733. Name: item.GoodName,
  9734. Code: item.MedicalInsuranceNumber,
  9735. List_type_code: "301",
  9736. }
  9737. queryResult = append(queryResult, result)
  9738. }
  9739. } else if record_type == 3 {
  9740. projects, _ := service.GetBathchMyPorjecgList(ids)
  9741. for _, item := range projects {
  9742. result := QueryResult{
  9743. ID: item.ID,
  9744. Name: item.ProjectName,
  9745. Code: item.MedicalCode,
  9746. List_type_code: "201",
  9747. }
  9748. queryResult = append(queryResult, result)
  9749. }
  9750. }
  9751. admin_user_id, _ := c.GetInt64("admin_user_id")
  9752. adminUser := c.GetAdminUserInfo()
  9753. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9754. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9755. var user_name string
  9756. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9757. if role.ID == 0 {
  9758. user_name = "xxx"
  9759. } else {
  9760. user_name = role.UserName
  9761. }
  9762. baseParams := &models.BaseParams{
  9763. SecretKey: miConfig.SecretKey,
  9764. FixmedinsCode: miConfig.Code,
  9765. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9766. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9767. OrgName: miConfig.OrgName,
  9768. Doctor: user_name,
  9769. }
  9770. if config.IsOpen == 1 {
  9771. for _, item := range queryResult {
  9772. var result string
  9773. if record_type == 1 {
  9774. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9775. } else if record_type == 2 {
  9776. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9777. } else if record_type == 3 {
  9778. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9779. }
  9780. var dat map[string]interface{}
  9781. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9782. fmt.Println(dat)
  9783. } else {
  9784. fmt.Println(err)
  9785. }
  9786. userJSONBytes, _ := json.Marshal(dat)
  9787. var res ResultSix
  9788. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9789. utils.ErrorLog("解析失败:%v", err)
  9790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9791. return
  9792. }
  9793. if res.Infcode == 0 {
  9794. if record_type == 1 {
  9795. service.UpdateBaseDrugById(item.ID)
  9796. } else if record_type == 2 {
  9797. service.UpdateGoodInformaitonByDetail(item.ID)
  9798. } else if record_type == 3 {
  9799. service.UpdateProjectById(item.ID)
  9800. }
  9801. c.ServeSuccessJSON(map[string]interface{}{
  9802. "failed_code": 0,
  9803. "msg": "目录对照成功",
  9804. })
  9805. } else {
  9806. c.ServeSuccessJSON(map[string]interface{}{
  9807. "failed_code": -10,
  9808. "msg": res.ErrMsg,
  9809. })
  9810. }
  9811. }
  9812. }
  9813. }
  9814. func (c *HisApiController) UnCheckCode() {
  9815. ids_str := c.GetString("ids")
  9816. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9817. admin_user_id, _ := c.GetInt64("admin_user_id")
  9818. ids_arr := strings.Split(ids_str, ",")
  9819. var queryResult []QueryResult
  9820. ids := make([]int64, 0)
  9821. for _, item := range ids_arr {
  9822. id, _ := strconv.ParseInt(item, 10, 64)
  9823. ids = append(ids, id)
  9824. }
  9825. if record_type == 1 {
  9826. drugs, _ := service.GetBatchDrugList(ids)
  9827. for _, item := range drugs {
  9828. result := QueryResult{
  9829. ID: item.ID,
  9830. Name: item.DrugName,
  9831. Code: item.MedicalInsuranceNumber,
  9832. List_type_code: "101",
  9833. }
  9834. queryResult = append(queryResult, result)
  9835. }
  9836. } else if record_type == 2 {
  9837. goods, _ := service.GetBatchGoodInformationList(ids)
  9838. for _, item := range goods {
  9839. result := QueryResult{
  9840. ID: item.ID,
  9841. Name: item.GoodName,
  9842. Code: item.MedicalInsuranceNumber,
  9843. List_type_code: "301",
  9844. }
  9845. queryResult = append(queryResult, result)
  9846. }
  9847. } else if record_type == 3 {
  9848. projects, _ := service.GetBathchMyPorjecgList(ids)
  9849. for _, item := range projects {
  9850. result := QueryResult{
  9851. ID: item.ID,
  9852. Name: item.ProjectName,
  9853. Code: item.MedicalCode,
  9854. List_type_code: "201",
  9855. }
  9856. queryResult = append(queryResult, result)
  9857. }
  9858. }
  9859. adminUser := c.GetAdminUserInfo()
  9860. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9861. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9862. var user_name string
  9863. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9864. if role.ID == 0 {
  9865. user_name = "xxx"
  9866. } else {
  9867. user_name = role.UserName
  9868. }
  9869. baseParams := &models.BaseParams{
  9870. SecretKey: miConfig.SecretKey,
  9871. FixmedinsCode: miConfig.Code,
  9872. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9873. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9874. OrgName: miConfig.OrgName,
  9875. Doctor: user_name,
  9876. }
  9877. if config.IsOpen == 1 {
  9878. for _, item := range queryResult {
  9879. var result string
  9880. if record_type == 1 {
  9881. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9882. } else if record_type == 2 {
  9883. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9884. } else if record_type == 3 {
  9885. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9886. }
  9887. var dat2 map[string]interface{}
  9888. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9889. fmt.Println(dat2)
  9890. } else {
  9891. fmt.Println(err)
  9892. }
  9893. userJSONBytes, _ := json.Marshal(dat2)
  9894. var res ResultSix
  9895. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9896. utils.ErrorLog("解析失败:%v", err)
  9897. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9898. return
  9899. }
  9900. if res.Infcode == 0 {
  9901. if record_type == 1 {
  9902. service.UpdateDrugByIdDetail(item.ID)
  9903. } else if record_type == 2 {
  9904. service.UpdateGoodInfoById(item.ID)
  9905. } else if record_type == 3 {
  9906. service.UpdateMyProjectById(item.ID)
  9907. }
  9908. c.ServeSuccessJSON(map[string]interface{}{
  9909. "failed_code": 0,
  9910. "msg": "撤销目录对照成功",
  9911. })
  9912. } else {
  9913. c.ServeSuccessJSON(map[string]interface{}{
  9914. "failed_code": -10,
  9915. "msg": res.ErrMsg,
  9916. })
  9917. }
  9918. }
  9919. }
  9920. }
  9921. func (c *HisApiController) GetPatientInfo() {
  9922. id_card_no := c.GetString("id_card_no")
  9923. admin_user_id, _ := c.GetInt64("admin_user_id")
  9924. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9925. if patient.ID == 0 {
  9926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9927. return
  9928. }
  9929. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9930. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9931. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9932. if config.IsOpen == 1 {
  9933. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9934. var dat map[string]interface{}
  9935. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9936. fmt.Println(dat)
  9937. } else {
  9938. fmt.Println(err)
  9939. }
  9940. userJSONBytes, _ := json.Marshal(dat)
  9941. var res ResultTwo
  9942. var res10265 ResultTwo10265
  9943. if miConfig.Code == "H15049901371" {
  9944. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9945. utils.ErrorLog("解析失败:%v", err)
  9946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9947. return
  9948. }
  9949. res.ErrMsg = res10265.ErrMsg
  9950. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9951. res.Infcode = infocode
  9952. res.Output = res10265.Output
  9953. res.InfRefmsgid = res10265.InfRefmsgid
  9954. } else {
  9955. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9956. utils.ErrorLog("解析失败:%v", err)
  9957. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9958. return
  9959. }
  9960. }
  9961. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9962. // utils.ErrorLog("解析失败:%v", err)
  9963. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9964. // return
  9965. //}
  9966. if res.Infcode != 0 {
  9967. c.ServeSuccessJSON(map[string]interface{}{
  9968. "failed_code": -10,
  9969. "msg": res.ErrMsg,
  9970. })
  9971. } else {
  9972. c.ServeSuccessJSON(map[string]interface{}{
  9973. "failed_code": 0,
  9974. "info": res,
  9975. })
  9976. }
  9977. }
  9978. }
  9979. func (c *HisApiController) PsnPutOnRecord() {
  9980. record_type, _ := c.GetInt64("type")
  9981. patient_id, _ := c.GetInt64("patient_id")
  9982. admin_user_id, _ := c.GetInt64("admin_user_id")
  9983. start_time := c.GetString("start_time")
  9984. end_time := c.GetString("end_time")
  9985. adminUser := c.GetAdminUserInfo()
  9986. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9987. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9988. var patients []*models.Patients
  9989. if record_type == 1 { //全部备案
  9990. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9991. patients = append(patients, patient...)
  9992. } else { //单个备案
  9993. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9994. patients = append(patients, patient)
  9995. }
  9996. var user_name string
  9997. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9998. if role.ID == 0 {
  9999. user_name = "xxx"
  10000. } else {
  10001. user_name = role.UserName
  10002. }
  10003. if config.IsOpen == 1 {
  10004. for _, item := range patients {
  10005. 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
  10006. resp, requestErr := http.Get(api)
  10007. if requestErr != nil {
  10008. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10009. return
  10010. }
  10011. defer resp.Body.Close()
  10012. body, ioErr := ioutil.ReadAll(resp.Body)
  10013. if ioErr != nil {
  10014. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. return
  10017. }
  10018. var respJSON map[string]interface{}
  10019. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10020. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10021. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10022. return
  10023. }
  10024. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10025. userJSONBytes, _ := json.Marshal(userJSON)
  10026. var res ResultTwo
  10027. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10028. utils.ErrorLog("解析失败:%v", err)
  10029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10030. return
  10031. }
  10032. if res.Infcode == 0 {
  10033. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10034. var dat map[string]interface{}
  10035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10036. fmt.Println(dat)
  10037. } else {
  10038. fmt.Println(err)
  10039. }
  10040. userJSONBytes, _ := json.Marshal(dat)
  10041. var res2 ResultThirteen
  10042. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10043. utils.ErrorLog("解析失败:%v", err)
  10044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10045. return
  10046. }
  10047. if res2.Infcode == 0 {
  10048. psnResult := &models.GdybPsnRecord{
  10049. UserOrgId: adminUser.CurrentOrgId,
  10050. PatientId: item.ID,
  10051. PsnNo: res.Output.Baseinfo.PsnNo,
  10052. Ctime: time.Now().Unix(),
  10053. Mtime: time.Now().Unix(),
  10054. Status: 1,
  10055. IsCancel: 1,
  10056. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10057. }
  10058. service.CreatePsnRecord(psnResult)
  10059. } else {
  10060. c.ServeSuccessJSON(map[string]interface{}{
  10061. "failed_code": -10,
  10062. "msg": res2.ErrMsg,
  10063. })
  10064. return
  10065. }
  10066. }
  10067. }
  10068. }
  10069. }
  10070. func (c *HisApiController) PsnUnPutOnRecord() {
  10071. id, _ := c.GetInt64("id")
  10072. //record_type, _ := c.GetInt64("type")
  10073. admin_user_id, _ := c.GetInt64("admin_user_id")
  10074. adminUser := c.GetAdminUserInfo()
  10075. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10076. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10077. var user_name string
  10078. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10079. if role.ID == 0 {
  10080. user_name = "xxx"
  10081. } else {
  10082. user_name = role.UserName
  10083. }
  10084. psn_record, _ := service.GetPsnRecordById(id)
  10085. if psn_record.ID == 0 {
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10087. return
  10088. }
  10089. if config.IsOpen == 1 {
  10090. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10091. var dat map[string]interface{}
  10092. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10093. fmt.Println(dat)
  10094. } else {
  10095. fmt.Println(err)
  10096. }
  10097. userJSONBytes, _ := json.Marshal(dat)
  10098. var res ResultFourteen
  10099. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10100. utils.ErrorLog("解析失败:%v", err)
  10101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10102. return
  10103. }
  10104. if res.Infcode == 0 {
  10105. psn_record.IsCancel = 2
  10106. service.CreatePsnRecord(&psn_record)
  10107. } else {
  10108. c.ServeSuccessJSON(map[string]interface{}{
  10109. "failed_code": -10,
  10110. "msg": res.ErrMsg,
  10111. })
  10112. return
  10113. }
  10114. }
  10115. }
  10116. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10117. patient_id, _ := c.GetInt64("patient_id")
  10118. insutype_two := c.GetString("insutype")
  10119. psn_no := c.GetString("psn_no")
  10120. doctor_id, _ := c.GetInt64("doctor_id")
  10121. sick_id, _ := c.GetInt64("sick_id")
  10122. department_id, _ := c.GetInt64("department_id")
  10123. start_time := c.GetString("start_time")
  10124. end_time := c.GetString("end_time")
  10125. check_time := c.GetString("check_time")
  10126. adminUser := c.GetAdminUserInfo()
  10127. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10128. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10129. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10130. sick, _ := service.FindSickById(sick_id)
  10131. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10132. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10133. var res ResultTwo
  10134. var res10265 ResultTwo10265
  10135. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10136. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10137. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10138. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10139. "&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
  10140. resp, requestErr := http.Get(api)
  10141. if requestErr != nil {
  10142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10143. return
  10144. }
  10145. body, ioErr := ioutil.ReadAll(resp.Body)
  10146. if ioErr != nil {
  10147. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10149. return
  10150. }
  10151. var respJSON map[string]interface{}
  10152. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10153. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10155. return
  10156. }
  10157. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10158. result, _ := json.Marshal(respJSON)
  10159. fmt.Println("log")
  10160. fmt.Println(string(result))
  10161. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10162. utils.ErrorLog("解析失败:%v", err)
  10163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10164. return
  10165. }
  10166. res.ErrMsg = res10265.ErrMsg
  10167. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10168. res.Infcode = infocode
  10169. res.Output = res10265.Output
  10170. res.InfRefmsgid = res10265.InfRefmsgid
  10171. } else {
  10172. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10173. if miConfig.Code == "H15049901371" {
  10174. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10175. utils.ErrorLog("解析失败:%v", err)
  10176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10177. return
  10178. }
  10179. res.ErrMsg = res10265.ErrMsg
  10180. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10181. res.Infcode = infocode
  10182. res.Output = res10265.Output
  10183. res.InfRefmsgid = res10265.InfRefmsgid
  10184. } else {
  10185. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10186. utils.ErrorLog("解析失败:%v", err)
  10187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10188. return
  10189. }
  10190. }
  10191. }
  10192. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10193. infoStr := string(Iinfos)
  10194. var rf []*ResultFive
  10195. json.Unmarshal([]byte(infoStr), &rf)
  10196. var insuplc_admdvs string
  10197. var insutype string
  10198. var is390 int = 0
  10199. var is310 int = 0
  10200. var insutypes []*ResultFive
  10201. for _, item := range rf {
  10202. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10203. insutypes = append(insutypes, item)
  10204. }
  10205. }
  10206. if len(insutypes) == 1 {
  10207. insutype = insutypes[0].Insutype
  10208. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10209. } else {
  10210. for _, i := range insutypes {
  10211. if i.Insutype == "390" {
  10212. is390 = 1
  10213. }
  10214. if i.Insutype == "310" {
  10215. is310 = 1
  10216. }
  10217. }
  10218. }
  10219. if is390 == 1 {
  10220. insutype = "390"
  10221. }
  10222. if is310 == 1 {
  10223. insutype = "310"
  10224. }
  10225. if len(insutypes) == 2 {
  10226. insutype = insutype_two
  10227. }
  10228. if len(insutypes) == 0 {
  10229. insutype = "310"
  10230. }
  10231. insutype = insutype_two
  10232. fmt.Println(insutype)
  10233. for _, item := range rf {
  10234. fmt.Println(item.Insutype)
  10235. fmt.Println(insutype)
  10236. if item.Insutype == insutype {
  10237. fmt.Println(item.Insutype)
  10238. fmt.Println(insutype)
  10239. insuplc_admdvs = item.InsuplcAdmdvs
  10240. }
  10241. }
  10242. fmt.Println(insuplc_admdvs)
  10243. var res2 ResultThirteen
  10244. var res10265_2 ResultThirteen10265
  10245. if config.IsOpen == 1 {
  10246. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10247. } else {
  10248. 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)
  10249. var dat map[string]interface{}
  10250. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10251. fmt.Println(dat)
  10252. } else {
  10253. fmt.Println(err)
  10254. }
  10255. userJSONBytes, _ := json.Marshal(dat)
  10256. if miConfig.Code == "H15049901371" {
  10257. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10258. utils.ErrorLog("解析失败:%v", err)
  10259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10260. return
  10261. }
  10262. res2.ErrMsg = res10265_2.ErrMsg
  10263. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10264. res2.Infcode = infocode
  10265. res2.Output = res10265_2.Output
  10266. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10267. } else {
  10268. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10269. utils.ErrorLog("解析失败:%v", err)
  10270. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10271. return
  10272. }
  10273. }
  10274. }
  10275. if res2.Infcode == 0 {
  10276. psnResult := &models.GdybPsnNcdsRecord{
  10277. UserOrgId: adminUser.CurrentOrgId,
  10278. PatientId: patient.ID,
  10279. PsnNo: psn_no,
  10280. DoctorId: doctor.AdminUserId,
  10281. DepartmentId: department_id,
  10282. SickType: sick_id,
  10283. Insutype: insutype,
  10284. Ctime: time.Now().Unix(),
  10285. Mtime: time.Now().Unix(),
  10286. Status: 1,
  10287. IsCancel: 1,
  10288. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10289. }
  10290. service.CreatePsnNCDSRecord(psnResult)
  10291. c.ServeSuccessJSON(map[string]interface{}{
  10292. "failed_code": 0,
  10293. "msg": "备案成功",
  10294. "result": psnResult,
  10295. })
  10296. } else {
  10297. c.ServeSuccessJSON(map[string]interface{}{
  10298. "failed_code": -10,
  10299. "msg": res2.ErrMsg,
  10300. })
  10301. return
  10302. }
  10303. }
  10304. }
  10305. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10306. id, _ := c.GetInt64("id")
  10307. admin_user_id, _ := c.GetInt64("admin_user_id")
  10308. adminUser := c.GetAdminUserInfo()
  10309. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10310. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10311. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10312. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10313. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10314. //var user_name string
  10315. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10316. //if role.ID == 0 {
  10317. // user_name = "xxx"
  10318. //} else {
  10319. // user_name = role.UserName
  10320. //}
  10321. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10322. if psn_record.ID == 0 {
  10323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10324. return
  10325. }
  10326. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10327. var res ResultTwo
  10328. var res10265 ResultTwo10265
  10329. if miConfig.Code == "H15049901371" {
  10330. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10331. utils.ErrorLog("解析失败:%v", err)
  10332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10333. return
  10334. }
  10335. res.ErrMsg = res10265.ErrMsg
  10336. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10337. res.Infcode = infocode
  10338. res.Output = res10265.Output
  10339. res.InfRefmsgid = res10265.InfRefmsgid
  10340. } else {
  10341. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10342. utils.ErrorLog("解析失败:%v", err)
  10343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10344. return
  10345. }
  10346. }
  10347. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10348. infoStr := string(Iinfos)
  10349. var rf []*ResultFive
  10350. json.Unmarshal([]byte(infoStr), &rf)
  10351. var insuplc_admdvs string
  10352. var insutype string
  10353. var is390 int = 0
  10354. var is310 int = 0
  10355. var insutypes []*ResultFive
  10356. for _, item := range rf {
  10357. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10358. insutypes = append(insutypes, item)
  10359. }
  10360. }
  10361. if len(insutypes) == 1 {
  10362. insutype = insutypes[0].Insutype
  10363. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10364. } else {
  10365. for _, i := range insutypes {
  10366. if i.Insutype == "390" {
  10367. is390 = 1
  10368. }
  10369. if i.Insutype == "310" {
  10370. is310 = 1
  10371. }
  10372. }
  10373. }
  10374. if is390 == 1 {
  10375. insutype = "390"
  10376. }
  10377. if is310 == 1 {
  10378. insutype = "310"
  10379. }
  10380. if len(insutypes) == 0 {
  10381. insutype = "310"
  10382. }
  10383. insutype = psn_record.Insutype
  10384. for _, item := range rf {
  10385. if item.Insutype == insutype {
  10386. insuplc_admdvs = item.InsuplcAdmdvs
  10387. }
  10388. }
  10389. if config.IsOpen == 1 {
  10390. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10391. var dat map[string]interface{}
  10392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10393. fmt.Println(dat)
  10394. } else {
  10395. fmt.Println(err)
  10396. }
  10397. userJSONBytes, _ := json.Marshal(dat)
  10398. var res ResultFourteen
  10399. var res10265 ResultFourteen10265
  10400. if miConfig.Code == "H15049901371" {
  10401. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10402. utils.ErrorLog("解析失败:%v", err)
  10403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10404. return
  10405. }
  10406. res.ErrMsg = res10265.ErrMsg
  10407. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10408. res.Infcode = infocode
  10409. res.Output = res10265.Output
  10410. res.InfRefmsgid = res10265.InfRefmsgid
  10411. } else {
  10412. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10413. utils.ErrorLog("解析失败:%v", err)
  10414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10415. return
  10416. }
  10417. }
  10418. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10419. // utils.ErrorLog("解析失败:%v", err)
  10420. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10421. // return
  10422. //}
  10423. if res.Infcode == 0 {
  10424. psn_record.IsCancel = 2
  10425. service.CreatePsnNCDSRecord(&psn_record)
  10426. c.ServeSuccessJSON(map[string]interface{}{
  10427. "failed_code": 0,
  10428. "msg": "撤销备案成功",
  10429. })
  10430. } else {
  10431. c.ServeSuccessJSON(map[string]interface{}{
  10432. "failed_code": -10,
  10433. "msg": res.ErrMsg,
  10434. })
  10435. return
  10436. }
  10437. }
  10438. }
  10439. func (c *HisApiController) TestTest() {
  10440. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10441. fmt.Println(patient.Iinfo)
  10442. }
  10443. type CustomData struct {
  10444. MsgId string
  10445. PsnNo string
  10446. Info string
  10447. }
  10448. func (c *HisApiController) ReversalData() {
  10449. var customData []*CustomData
  10450. custom := &CustomData{
  10451. MsgId: "H44022900158202103301714472004",
  10452. PsnNo: "44020000001101329945",
  10453. Info: "2207",
  10454. }
  10455. customData = append(customData, custom)
  10456. custom1 := &CustomData{
  10457. MsgId: "H4402290015820210330172057803",
  10458. PsnNo: "44020000001101161813",
  10459. Info: "2207",
  10460. }
  10461. customData = append(customData, custom1)
  10462. custom2 := &CustomData{
  10463. MsgId: "H44022900158202103301705198813",
  10464. PsnNo: "44190000133097375417",
  10465. Info: "2207",
  10466. }
  10467. customData = append(customData, custom2)
  10468. custom3 := &CustomData{
  10469. MsgId: "H44022900158202103301715524756",
  10470. PsnNo: "44020000001100187221",
  10471. Info: "2207",
  10472. }
  10473. customData = append(customData, custom3)
  10474. custom4 := &CustomData{
  10475. MsgId: "H44022900158202103301730376224",
  10476. PsnNo: "44020000001101959155",
  10477. Info: "2207",
  10478. }
  10479. customData = append(customData, custom4)
  10480. custom5 := &CustomData{
  10481. MsgId: "H44022900158202103301748008725",
  10482. PsnNo: "44020000001104246641",
  10483. Info: "2207",
  10484. }
  10485. customData = append(customData, custom5)
  10486. custom6 := &CustomData{
  10487. MsgId: "H44022900158202103301718096755",
  10488. PsnNo: "44020000001102211860",
  10489. Info: "2207",
  10490. }
  10491. customData = append(customData, custom6)
  10492. custom7 := &CustomData{
  10493. MsgId: "H44022900158202103301736551640",
  10494. PsnNo: "44020000001102687718",
  10495. Info: "2207",
  10496. }
  10497. customData = append(customData, custom7)
  10498. custom8 := &CustomData{
  10499. MsgId: "H44022900158202103301743097676",
  10500. PsnNo: "44020000001102127785",
  10501. Info: "2207",
  10502. }
  10503. customData = append(customData, custom8)
  10504. custom9 := &CustomData{
  10505. MsgId: "H44022900158202103301712304203",
  10506. PsnNo: "44020000001101518097",
  10507. Info: "2207",
  10508. }
  10509. customData = append(customData, custom9)
  10510. custom10 := &CustomData{
  10511. MsgId: "H44022900158202103301738448785",
  10512. PsnNo: "44020000001100500813",
  10513. Info: "2207",
  10514. }
  10515. customData = append(customData, custom10)
  10516. custom11 := &CustomData{
  10517. MsgId: "H44022900158202103301732455843",
  10518. PsnNo: "44020000001102690557",
  10519. Info: "2207",
  10520. }
  10521. customData = append(customData, custom11)
  10522. custom12 := &CustomData{
  10523. MsgId: "H44022900158202103301745421708",
  10524. PsnNo: "44020000001102211928",
  10525. Info: "2207",
  10526. }
  10527. customData = append(customData, custom12)
  10528. custom1212 := &CustomData{
  10529. MsgId: "H440229001582021033017351627",
  10530. PsnNo: "44020000001102481733",
  10531. Info: "2207",
  10532. }
  10533. customData = append(customData, custom1212)
  10534. custom13 := &CustomData{
  10535. MsgId: "H44022900158202103301740327951",
  10536. PsnNo: "44020000001103174866",
  10537. Info: "2207",
  10538. }
  10539. customData = append(customData, custom13)
  10540. custom14 := &CustomData{
  10541. MsgId: "H4402290015820210330174922668",
  10542. PsnNo: "44020000001102927272",
  10543. Info: "2207",
  10544. }
  10545. customData = append(customData, custom14)
  10546. custom15 := &CustomData{
  10547. MsgId: "H44022900158202103301752362273",
  10548. PsnNo: "44020000001102942890",
  10549. Info: "2207",
  10550. }
  10551. customData = append(customData, custom15)
  10552. custom16 := &CustomData{
  10553. MsgId: "H44022900158202103301751082917",
  10554. PsnNo: "44020000001101662162",
  10555. Info: "2207",
  10556. }
  10557. customData = append(customData, custom16)
  10558. custom17 := &CustomData{
  10559. MsgId: "H44022900158202103301754147728",
  10560. PsnNo: "44020000000229014511",
  10561. Info: "2207",
  10562. }
  10563. customData = append(customData, custom17)
  10564. adminUser := c.GetAdminUserInfo()
  10565. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10566. for _, item := range customData {
  10567. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10568. fmt.Println(result)
  10569. }
  10570. }
  10571. //func (c *HisApiController) GetAllopatry() {
  10572. // year := c.GetString("year")
  10573. // month := c.GetString("month")
  10574. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10575. // adminUser := c.GetAdminUserInfo()
  10576. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10577. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10578. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10579. //
  10580. // var dat map[string]interface{}
  10581. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10582. // fmt.Println(dat)
  10583. // } else {
  10584. // fmt.Println(err)
  10585. // }
  10586. // userJSONBytes, _ := json.Marshal(dat)
  10587. // var res models.Result9001
  10588. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10589. // utils.ErrorLog("解析失败:%v", err)
  10590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10591. // return
  10592. // }
  10593. //
  10594. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10595. // var dat2 map[string]interface{}
  10596. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10597. // fmt.Println(dat)
  10598. // } else {
  10599. // fmt.Println(err)
  10600. // }
  10601. // userJSONBytes2, _ := json.Marshal(dat2)
  10602. // var res2 models.Result3260
  10603. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10604. // utils.ErrorLog("解析失败:%v", err)
  10605. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10606. // return
  10607. // }
  10608. // if res2.Infcode == 0 {
  10609. // c.ServeSuccessJSON(map[string]interface{}{
  10610. // "list": res2.Output.Data,
  10611. // })
  10612. // return
  10613. // } else {
  10614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10615. // return
  10616. // }
  10617. //
  10618. //}
  10619. //func (c *HisApiController) ComfirmAllopatry() {
  10620. // year := c.GetString("year")
  10621. // month := c.GetString("month")
  10622. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10623. // adminUser := c.GetAdminUserInfo()
  10624. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10625. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10626. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10627. // var dat map[string]interface{}
  10628. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10629. // fmt.Println(dat)
  10630. // } else {
  10631. // fmt.Println(err)
  10632. // }
  10633. // userJSONBytes, _ := json.Marshal(dat)
  10634. // var res models.Result9001
  10635. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10636. // utils.ErrorLog("解析失败:%v", err)
  10637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10638. // return
  10639. // }
  10640. //
  10641. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10642. // var dat2 map[string]interface{}
  10643. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10644. // fmt.Println(dat)
  10645. // } else {
  10646. // fmt.Println(err)
  10647. // }
  10648. // userJSONBytes2, _ := json.Marshal(dat2)
  10649. // var res2 models.Result3260
  10650. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10651. // utils.ErrorLog("解析失败:%v", err)
  10652. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10653. // return
  10654. // }
  10655. //
  10656. // if res2.Infcode == 0 {
  10657. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10658. // var dat map[string]interface{}
  10659. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10660. // fmt.Println(dat)
  10661. // } else {
  10662. // fmt.Println(err)
  10663. // }
  10664. // userJSONBytes, _ := json.Marshal(dat)
  10665. // var res3 models.Result3261
  10666. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10667. // utils.ErrorLog("解析失败:%v", err)
  10668. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10669. // return
  10670. // }
  10671. //
  10672. // if res3.Infcode == 0 {
  10673. // record := &models.HisYidiClearRecord{
  10674. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10675. // Ctime: time.Now().Unix(),
  10676. // Mtime: time.Now().Unix(),
  10677. // Status: 1,
  10678. // MsgId: msgId,
  10679. // }
  10680. // service.SaveClearRecord(record)
  10681. // c.ServeSuccessJSON(map[string]interface{}{
  10682. // "msg": "提取成功",
  10683. // })
  10684. // }
  10685. // }
  10686. //}
  10687. func (c *HisApiController) RefundAllopatry() {
  10688. year := c.GetString("year")
  10689. month := c.GetString("month")
  10690. id, _ := c.GetInt64("id")
  10691. admin_user_id, _ := c.GetInt64("admin_user_id")
  10692. adminUser := c.GetAdminUserInfo()
  10693. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10694. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10695. record, _ := service.GetClearRecordById(id)
  10696. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10697. var dat map[string]interface{}
  10698. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10699. fmt.Println(dat)
  10700. } else {
  10701. fmt.Println(err)
  10702. }
  10703. userJSONBytes, _ := json.Marshal(dat)
  10704. var empty ResultFourteen
  10705. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10706. utils.ErrorLog("解析失败:%v", err)
  10707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10708. return
  10709. }
  10710. if empty.Infcode == 0 {
  10711. c.ServeSuccessJSON(map[string]interface{}{
  10712. "msg": "撤销成功",
  10713. })
  10714. return
  10715. }
  10716. }
  10717. func (c *HisApiController) ReversalOtherData() {
  10718. var customData []*CustomData
  10719. custom := &CustomData{
  10720. MsgId: "H44022900158202103301714472004",
  10721. PsnNo: "44020000001101329945",
  10722. Info: "2208",
  10723. }
  10724. customData = append(customData, custom)
  10725. custom1 := &CustomData{
  10726. MsgId: "H4402290015820210330172057803",
  10727. PsnNo: "44020000001101161813",
  10728. Info: "2208",
  10729. }
  10730. customData = append(customData, custom1)
  10731. custom2 := &CustomData{
  10732. MsgId: "H44022900158202103301705198813",
  10733. PsnNo: "44190000133097375417",
  10734. Info: "2208",
  10735. }
  10736. customData = append(customData, custom2)
  10737. custom3 := &CustomData{
  10738. MsgId: "H44022900158202103301715524756",
  10739. PsnNo: "44020000001100187221",
  10740. Info: "2208",
  10741. }
  10742. customData = append(customData, custom3)
  10743. custom4 := &CustomData{
  10744. MsgId: "H44022900158202103301730376224",
  10745. PsnNo: "44020000001101959155",
  10746. Info: "2208",
  10747. }
  10748. customData = append(customData, custom4)
  10749. custom5 := &CustomData{
  10750. MsgId: "H44022900158202103301748008725",
  10751. PsnNo: "44020000001104246641",
  10752. Info: "2208",
  10753. }
  10754. customData = append(customData, custom5)
  10755. custom6 := &CustomData{
  10756. MsgId: "H44022900158202103301718096755",
  10757. PsnNo: "44020000001102211860",
  10758. Info: "2208",
  10759. }
  10760. customData = append(customData, custom6)
  10761. custom7 := &CustomData{
  10762. MsgId: "H44022900158202103301736551640",
  10763. PsnNo: "44020000001102687718",
  10764. Info: "2208",
  10765. }
  10766. customData = append(customData, custom7)
  10767. custom8 := &CustomData{
  10768. MsgId: "H44022900158202103301743097676",
  10769. PsnNo: "44020000001102127785",
  10770. Info: "2208",
  10771. }
  10772. customData = append(customData, custom8)
  10773. custom9 := &CustomData{
  10774. MsgId: "H44022900158202103301712304203",
  10775. PsnNo: "44020000001101518097",
  10776. Info: "2208",
  10777. }
  10778. customData = append(customData, custom9)
  10779. custom10 := &CustomData{
  10780. MsgId: "H44022900158202103301738448785",
  10781. PsnNo: "44020000001100500813",
  10782. Info: "2208",
  10783. }
  10784. customData = append(customData, custom10)
  10785. custom11 := &CustomData{
  10786. MsgId: "H44022900158202103301732455843",
  10787. PsnNo: "44020000001102690557",
  10788. Info: "2208",
  10789. }
  10790. customData = append(customData, custom11)
  10791. custom12 := &CustomData{
  10792. MsgId: "H44022900158202103301745421708",
  10793. PsnNo: "44020000001102211928",
  10794. Info: "2208",
  10795. }
  10796. customData = append(customData, custom12)
  10797. custom1212 := &CustomData{
  10798. MsgId: "H440229001582021033017351627",
  10799. PsnNo: "44020000001102481733",
  10800. Info: "2208",
  10801. }
  10802. customData = append(customData, custom1212)
  10803. custom13 := &CustomData{
  10804. MsgId: "H44022900158202103301740327951",
  10805. PsnNo: "44020000001103174866",
  10806. Info: "2208",
  10807. }
  10808. customData = append(customData, custom13)
  10809. custom14 := &CustomData{
  10810. MsgId: "H4402290015820210330174922668",
  10811. PsnNo: "44020000001102927272",
  10812. Info: "2208",
  10813. }
  10814. customData = append(customData, custom14)
  10815. custom15 := &CustomData{
  10816. MsgId: "H44022900158202103301752362273",
  10817. PsnNo: "44020000001102942890",
  10818. Info: "2208",
  10819. }
  10820. customData = append(customData, custom15)
  10821. custom16 := &CustomData{
  10822. MsgId: "H44022900158202103301751082917",
  10823. PsnNo: "44020000001101662162",
  10824. Info: "2208",
  10825. }
  10826. customData = append(customData, custom16)
  10827. custom17 := &CustomData{
  10828. MsgId: "H44022900158202103301754147728",
  10829. PsnNo: "44020000000229014511",
  10830. Info: "2208",
  10831. }
  10832. customData = append(customData, custom17)
  10833. adminUser := c.GetAdminUserInfo()
  10834. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10835. for _, item := range customData {
  10836. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10837. fmt.Println(result)
  10838. }
  10839. }
  10840. func PathExists(path string) (bool, error) {
  10841. _, err := os.Stat(path)
  10842. if err == nil {
  10843. return true, nil
  10844. }
  10845. if os.IsNotExist(err) {
  10846. return false, nil
  10847. }
  10848. return false, err
  10849. }
  10850. //创建文件夹
  10851. func Mkdir(dir string) {
  10852. // 创建文件夹
  10853. exist, err := PathExists(dir)
  10854. if err != nil {
  10855. fmt.Println(err.Error())
  10856. } else {
  10857. if exist {
  10858. fmt.Println(dir + "文件夹已存在!")
  10859. } else {
  10860. // 文件夹名称,权限
  10861. err := os.Mkdir(dir, os.ModePerm)
  10862. if err != nil {
  10863. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10864. } else {
  10865. fmt.Println(dir + "文件夹创建成功!")
  10866. }
  10867. }
  10868. }
  10869. }
  10870. //压缩文件
  10871. func Zip(srcFile string, destZip string) error {
  10872. zipfile, err := os.Create(destZip)
  10873. if err != nil {
  10874. return err
  10875. }
  10876. defer zipfile.Close()
  10877. archive := zip.NewWriter(zipfile)
  10878. defer archive.Close()
  10879. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10880. if err != nil {
  10881. return err
  10882. }
  10883. header, err := zip.FileInfoHeader(info)
  10884. if err != nil {
  10885. return err
  10886. }
  10887. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10888. // header.Name = path
  10889. if info.IsDir() {
  10890. header.Name += "/"
  10891. } else {
  10892. header.Method = zip.Deflate
  10893. }
  10894. writer, err := archive.CreateHeader(header)
  10895. if err != nil {
  10896. return err
  10897. }
  10898. if !info.IsDir() {
  10899. file, err := os.Open(path)
  10900. if err != nil {
  10901. return err
  10902. }
  10903. defer file.Close()
  10904. _, err = io.Copy(writer, file)
  10905. }
  10906. return err
  10907. })
  10908. return err
  10909. }
  10910. func ReadFile(filePath string) []byte {
  10911. f, err := os.Open(filePath)
  10912. if err != nil {
  10913. fmt.Println("read file fail", err)
  10914. return nil
  10915. }
  10916. defer f.Close()
  10917. fd, err := ioutil.ReadAll(f)
  10918. if err != nil {
  10919. fmt.Println("read to fd fail", err)
  10920. return nil
  10921. }
  10922. return fd
  10923. }
  10924. func saveLog(result string, request string, infno string, desc string) {
  10925. org_id, _ := beego.AppConfig.Int64("org_id")
  10926. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10927. dir := miConfig.OrgName + "日志"
  10928. utils.Mkdir(dir)
  10929. month := time.Unix(1557042972, 0).Format("1")
  10930. year := time.Now().Format("2006")
  10931. month = time.Now().Format("01")
  10932. day := time.Now().Format("02")
  10933. hour := time.Now().Format("15")
  10934. min := time.Now().Format("04")
  10935. sec := time.Now().Format("05")
  10936. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10937. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10938. file_name := file + ".txt"
  10939. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10940. exist, _ := utils.PathExists(file_path)
  10941. if exist { //存在
  10942. fmt.Println("存在")
  10943. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10944. if err != nil {
  10945. fmt.Println("read fail")
  10946. }
  10947. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10948. n, _ := f.Seek(0, 2)
  10949. _, err = f.WriteAt([]byte(content), n)
  10950. } else { //不存在
  10951. fmt.Println("文件不存在,创建文件")
  10952. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10953. defer f.Close()
  10954. if err != nil {
  10955. } else {
  10956. _, err = f.Write([]byte("记录日志"))
  10957. }
  10958. }
  10959. }
  10960. type Charset string
  10961. const (
  10962. UTF8 = Charset("UTF-8")
  10963. GB18030 = Charset("GB18030")
  10964. )
  10965. func ConvertToString(src string, srcCode string, tagCode string) string {
  10966. srcCoder := mahonia.NewDecoder(srcCode)
  10967. srcResult := srcCoder.ConvertString(src)
  10968. tagCoder := mahonia.NewDecoder(tagCode)
  10969. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10970. result := string(cdata)
  10971. return result
  10972. }
  10973. func (c *HisApiController) ReadEleCard() {
  10974. id_card_type, _ := c.GetInt64("id_card_type")
  10975. admin_user_id, _ := c.GetInt64("admin_user_id")
  10976. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10977. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10978. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10979. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10980. var api string
  10981. if miConfig.MdtrtareaAdmvs == "320921" {
  10982. 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 +
  10983. "&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
  10984. fmt.Println(api)
  10985. } else {
  10986. 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 +
  10987. "&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)
  10988. }
  10989. resp, requestErr := http.Get(api)
  10990. if requestErr != nil {
  10991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10992. return
  10993. }
  10994. body, ioErr := ioutil.ReadAll(resp.Body)
  10995. if ioErr != nil {
  10996. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10998. return
  10999. }
  11000. var respJSON map[string]interface{}
  11001. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11002. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11004. return
  11005. }
  11006. var status string
  11007. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11008. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11009. var token string
  11010. var res ResultTwo //1101结果
  11011. var res10265 ResultTwo10265 //1101结果
  11012. if status == "0" { //读卡成功
  11013. var card_info string //卡信息
  11014. var busi_card_info string
  11015. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11016. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11017. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11018. fmt.Println(card_info)
  11019. fmt.Println(busi_card_info)
  11020. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11021. result, _ := json.Marshal(respJSON)
  11022. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11023. utils.ErrorLog("解析失败:%v", err)
  11024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11025. return
  11026. }
  11027. res.ErrMsg = res10265.ErrMsg
  11028. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11029. res.Infcode = infocode
  11030. res.Output = res10265.Output
  11031. res.InfRefmsgid = res10265.InfRefmsgid
  11032. if res.Infcode == 0 {
  11033. c.ServeSuccessJSON(map[string]interface{}{
  11034. "number": token,
  11035. })
  11036. }
  11037. } else {
  11038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11039. return
  11040. }
  11041. } else { //读卡失败
  11042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11043. return
  11044. }
  11045. }
  11046. func DeleteExtraSpaceTwo(s string) string {
  11047. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11048. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11049. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11050. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11051. s2 := make([]byte, len(s1)) //定义字符数组切片
  11052. copy(s2, s1) //将字符串复制到切片
  11053. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11054. for len(spc_index) > 0 { //找到适配项
  11055. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11056. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11057. }
  11058. return string(s2)
  11059. }
  11060. func Remove0000(s string) string {
  11061. str := make([]rune, 0, len(s))
  11062. for _, v := range []rune(s) {
  11063. if v == 0 {
  11064. continue
  11065. }
  11066. str = append(str, v)
  11067. }
  11068. return string(str)
  11069. }
  11070. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11071. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11072. readCard := DllDef.MustFindProc("EcQuery")
  11073. pCardInfo := make([]byte, 8192)
  11074. pBusiCardInfo := make([]byte, 8192)
  11075. data := make(map[string]interface{})
  11076. //pData := make(map[string]interface{})
  11077. inputData := make(map[string]interface{})
  11078. inputData["orgId"] = code
  11079. inputData["businessType"] = "01101"
  11080. inputData["operatorId"] = operator_id
  11081. inputData["operatorName"] = operator_name
  11082. inputData["officeId"] = "001"
  11083. inputData["officeName"] = "血透室"
  11084. //
  11085. data["data"] = inputData
  11086. data["transType"] = "ec.query"
  11087. data["orgId"] = code
  11088. bytesData, _ := json.Marshal(data)
  11089. pCardInfo = bytesData
  11090. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11091. fmt.Println(ret2)
  11092. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11093. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11094. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11095. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11096. if ret2 != 0 {
  11097. return "", ""
  11098. }
  11099. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11100. }
  11101. func DeleteExtraSpace(s string) string {
  11102. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11103. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11104. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11105. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11106. s2 := make([]byte, len(s1)) //定义字符数组切片
  11107. copy(s2, s1) //将字符串复制到切片
  11108. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11109. for len(spc_index) > 0 { //找到适配项
  11110. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11111. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11112. }
  11113. return string(s2)
  11114. }