his_api_controller.go 469KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772
  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. type Result3101 struct {
  80. Infcode string `json:"infcode"`
  81. InfRefmsgid string `json:"inf_refmsgid"`
  82. RefmsgTime string `json:"refmsg_time"`
  83. RespondTime string `json:"respond_time"`
  84. Enctype string `json:"enctype"`
  85. Signtype string `json:"signtype"`
  86. ErrMsg interface{} `json:"err_msg"`
  87. Output struct {
  88. Result []struct {
  89. JudgeResultDetailDtos []struct {
  90. VolaItemType string `json:"vola_item_type"`
  91. MdtrtID string `json:"mdtrt_id"`
  92. JrdID string `json:"jrd_id"`
  93. PatnID string `json:"patn_id"`
  94. RxID string `json:"rx_id"`
  95. VolaAmt interface{} `json:"vola_amt"`
  96. } `json:"judge_result_detail_dtos"`
  97. RuleID string `json:"rule_id"`
  98. VolaEvid string `json:"vola_evid"`
  99. MdtrtID string `json:"mdtrt_id"`
  100. RuleName string `json:"rule_name"`
  101. VolaAmtStas string `json:"vola_amt_stas"`
  102. JrID string `json:"jr_id"`
  103. PatnID string `json:"patn_id"`
  104. SevDeg string `json:"sev_deg"`
  105. VolaAmt float64 `json:"vola_amt"`
  106. VolaBhvrType string `json:"vola_bhvr_type"`
  107. VolaCont string `json:"vola_cont"`
  108. } `json:"result"`
  109. } `json:"output"`
  110. }
  111. func (c *HisApiController) Get9001() {
  112. adminUser := c.GetAdminUserInfo()
  113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  114. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  115. if miConfig.MdtrtareaAdmvs == "350500" {
  116. service.GetFjAuthorizationInfo(miConfig.Code)
  117. } else {
  118. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  119. var dat map[string]interface{}
  120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  121. fmt.Println(dat)
  122. } else {
  123. fmt.Println(err)
  124. }
  125. userJSONBytes, _ := json.Marshal(dat)
  126. var res models.Result9001
  127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  128. utils.ErrorLog("解析失败:%v", err)
  129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  130. return
  131. }
  132. }
  133. }
  134. func Check3101(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, record_time string, prescriptions []*models.HisPrescription) (res Result3101) {
  135. adminUser := c.GetAdminUserInfo()
  136. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  137. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  138. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  139. //record_time := c.GetString("record_time")
  140. //trig_scen := c.GetString("trig_scen")
  141. timeLayout := "2006-01-02"
  142. loc, _ := time.LoadLocation("Local")
  143. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  144. if err != nil {
  145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  146. return res
  147. }
  148. recordDateTime := theTime.Unix()
  149. var patientPrescription models.HisPrescriptionInfo
  150. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  151. if patientPrescription.ID == 0 {
  152. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  153. }
  154. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  155. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  156. //
  157. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  158. //prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  159. var pp models.PublicParams
  160. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  161. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  162. pp.FixmedinsName = miConfig.OrgName
  163. pp.FixmedinsCode = miConfig.Code
  164. pp.RequestUrl = miConfig.Url
  165. pp.Cainfo = miConfig.Cainfo
  166. pp.SecretKey = miConfig.SecretKey
  167. pp.AccessKey = miConfig.AccessKey
  168. pp.OpterName = roles.UserName
  169. var config []*models.HisXtDiagnoseConfig
  170. for _, item := range diagnosis_ids {
  171. id, _ := strconv.ParseInt(item, 10, 64)
  172. diagnosisConfig, _ := service.FindDiagnoseById(id)
  173. config = append(config, &diagnosisConfig)
  174. }
  175. var pd models.PatientDtos
  176. pd.PatnID = his.PsnNo
  177. pd.PatnName = his.Name
  178. pd.Gend = his.Gend
  179. pd.Brdy = his.Brdy
  180. pd.Poolarea = his.InsuplcAdmdvs
  181. pd.CurrMdtrtID = his.Number
  182. var fed models.FsiEncounterDtos
  183. fed.MdtrtID = his.Number
  184. fed.MedinsID = miConfig.Code
  185. fed.MedinsName = miConfig.OrgName
  186. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  187. fed.MedMdtrtType = "1"
  188. fed.MedinsType = "1"
  189. fed.MedinsLv = "11"
  190. tm := time.Unix(his.RecordDate, 0)
  191. s_tm := tm.Format("2006-01-02 15:04:05")
  192. fed.AdmDate = s_tm
  193. fed.DscgDate = s_tm
  194. fed.DscgMainDiseCodg = config[0].CountryCode
  195. fed.DscgMainDiseName = config[0].CountryContentName
  196. //诊断信息
  197. var fdds []*models.FsiDiagnoseDtos
  198. for index, item := range config {
  199. if index == 0 {
  200. var fdd models.FsiDiagnoseDtos
  201. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  202. fdd.InoutDiseType = "1"
  203. fdd.MaindiseFlag = "1"
  204. fdd.DiseDate = s_tm
  205. fdd.DiasSrtNo = "1"
  206. fdd.DiseName = item.CountryContentName
  207. fdd.DiseCodg = item.CountryCode
  208. fdds = append(fdds, &fdd)
  209. } else {
  210. var fdd models.FsiDiagnoseDtos
  211. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  212. fdd.InoutDiseType = "1"
  213. fdd.MaindiseFlag = "1"
  214. fdd.DiseDate = s_tm
  215. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  216. fdd.DiseName = item.CountryContentName
  217. fdd.DiseCodg = item.CountryCode
  218. fdds = append(fdds, &fdd)
  219. }
  220. }
  221. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  222. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  223. fed.AdmDeptName = department.Name
  224. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  225. fed.DscgDeptName = department.Name
  226. fed.MedMdtrtType = "1"
  227. fed.MedType = "11"
  228. //if his.Insutype == "390" {
  229. // fed.MedType = "1402"
  230. //} else {
  231. // fed.MedType = "9933"
  232. //}
  233. var orders []*models.FsiOrderDtos
  234. if trig_scen == "2" {
  235. //处方医嘱信息
  236. for _, item := range prescriptions {
  237. for _, subItem := range item.HisDoctorAdviceInfo {
  238. var order models.FsiOrderDtos
  239. order.RxID = strconv.FormatInt(item.ID, 10)
  240. order.Rxno = strconv.FormatInt(item.ID, 10)
  241. order.LongDrordFlag = "0"
  242. order.HilistType = "1"
  243. order.ChrgType = "1"
  244. order.DrordBhvr = "-"
  245. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  246. order.HosplistName = subItem.BaseDrugLib.DrugName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  250. order.HosplistName = subItem.BaseDrugLib.DrugName
  251. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  252. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  254. order.OwnpayAmt = ""
  255. order.SelfpayAmt = ""
  256. order.Spec = ""
  257. order.SpecUnt = ""
  258. order.DrordBegnDate = s_tm
  259. order.DrordStopDate = ""
  260. order.DrordDrCodg = "1"
  261. order.DrordDeptName = department.Name
  262. order.DrordDrCodg = "1"
  263. order.DrordDrName = doctor_info.UserName
  264. order.DrordDrProfttl = ""
  265. order.CurrDrordFlag = "1"
  266. orders = append(orders, &order)
  267. }
  268. for _, subItem := range item.HisPrescriptionProject {
  269. if subItem.Type == 2 {
  270. var order models.FsiOrderDtos
  271. order.RxID = strconv.FormatInt(item.ID, 10)
  272. order.Rxno = strconv.FormatInt(item.ID, 10)
  273. order.LongDrordFlag = "0"
  274. order.HilistType = "1"
  275. order.ChrgType = "1"
  276. order.DrordBhvr = "-"
  277. order.HilistCode = subItem.HisProject.MedicalCode
  278. order.HosplistName = subItem.HisProject.ProjectName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.HisProject.MedicalCode
  282. order.HosplistName = subItem.HisProject.ProjectName
  283. order.Cnt = subItem.Count
  284. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  285. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  286. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  287. order.OwnpayAmt = ""
  288. order.SelfpayAmt = ""
  289. order.Spec = ""
  290. order.SpecUnt = ""
  291. order.DrordBegnDate = s_tm
  292. order.DrordStopDate = ""
  293. order.DrordDrCodg = "1"
  294. order.DrordDeptName = department.Name
  295. order.DrordDrCodg = "1"
  296. order.DrordDrName = doctor_info.UserName
  297. order.DrordDrProfttl = ""
  298. order.CurrDrordFlag = "1"
  299. orders = append(orders, &order)
  300. }
  301. if subItem.Type == 3 {
  302. var order models.FsiOrderDtos
  303. order.RxID = strconv.FormatInt(item.ID, 10)
  304. order.Rxno = strconv.FormatInt(item.ID, 10)
  305. order.LongDrordFlag = "0"
  306. order.HilistType = "1"
  307. order.ChrgType = "1"
  308. order.DrordBhvr = "-"
  309. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  310. order.HosplistName = subItem.GoodInfo.GoodName
  311. order.HilistLv = "1"
  312. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  313. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  314. order.HosplistName = subItem.GoodInfo.GoodName
  315. order.Cnt = subItem.Count
  316. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  317. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  318. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  319. order.OwnpayAmt = ""
  320. order.SelfpayAmt = ""
  321. order.Spec = ""
  322. order.SpecUnt = ""
  323. order.DrordBegnDate = s_tm
  324. order.DrordStopDate = ""
  325. order.DrordDrCodg = "1"
  326. order.DrordDeptName = department.Name
  327. order.DrordDrCodg = "1"
  328. order.DrordDrName = doctor_info.UserName
  329. order.DrordDrProfttl = ""
  330. order.CurrDrordFlag = "1"
  331. orders = append(orders, &order)
  332. }
  333. }
  334. }
  335. //处方医嘱信息
  336. }
  337. fed.MatnStas = "0"
  338. fed.MedfeeSumamt = "0"
  339. fed.OwnpayAmt = "0"
  340. fed.SelfpayAmt = "0"
  341. fed.AcctPayamt = "0"
  342. fed.MaAmt = "0"
  343. fed.HifpPayamt = "0"
  344. fed.SetlTotlnum = "1"
  345. fed.Insutype = his.Insutype
  346. fed.ReimFlag = "0"
  347. fed.OutSetlFlag = "0"
  348. var fopd []*models.FsiOperationDtosData
  349. data := make(map[string]interface{})
  350. data["fed"] = fed
  351. data["fdd"] = fdds
  352. data["fod"] = orders
  353. data["pd"] = pd
  354. data["pp"] = pp
  355. data["fopd"] = fopd
  356. data["trig_scen"] = trig_scen
  357. fmt.Println(data)
  358. fmt.Println(fed)
  359. fmt.Println(fdds)
  360. fmt.Println(orders)
  361. fmt.Println(pd)
  362. fmt.Println(pp)
  363. fmt.Println(fopd)
  364. client := &http.Client{}
  365. bytesData, _ := json.Marshal(data)
  366. var req *http.Request
  367. if miConfig.MdtrtareaAdmvs == "320921" {
  368. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  369. } else {
  370. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  371. }
  372. resp, _ := client.Do(req)
  373. defer resp.Body.Close()
  374. body, ioErr := ioutil.ReadAll(resp.Body)
  375. if ioErr != nil {
  376. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  378. return res
  379. }
  380. var respJSON map[string]interface{}
  381. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  382. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  383. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  384. return res
  385. }
  386. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  387. result, _ := json.Marshal(respJSON)
  388. if err := json.Unmarshal([]byte(result), &res); err != nil {
  389. utils.ErrorLog("解析失败:%v", err)
  390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  391. return res
  392. }
  393. return res
  394. }
  395. func Check3102(c *HisApiController, patient_id int64, his_patient_id int64, admin_user_id int64, trig_scen string, order_id int64) (res Result3101) {
  396. ////patient_id, _ := c.GetInt64("patient_id")
  397. //order_id, _ := c.GetInt64("order_id")
  398. ////his_patient_id, _ := c.GetInt64("his_patient_id")
  399. ////admin_user_id, _ := c.GetInt64("admin_user_id")
  400. //trig_scen := c.GetString("trig_scen")
  401. adminUser := c.GetAdminUserInfo()
  402. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  403. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  404. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  405. record_time := c.GetString("record_time")
  406. order, _ := service.GetHisOrderByID(order_id)
  407. timeLayout := "2006-01-02"
  408. loc, _ := time.LoadLocation("Local")
  409. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  410. if err != nil {
  411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  412. return
  413. }
  414. recordDateTime := theTime.Unix()
  415. var patientPrescription models.HisPrescriptionInfo
  416. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  417. if patientPrescription.ID == 0 {
  418. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  419. }
  420. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  421. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  422. //
  423. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  424. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  425. var pp models.PublicParams
  426. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  427. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  428. pp.FixmedinsName = miConfig.OrgName
  429. pp.FixmedinsCode = miConfig.Code
  430. pp.RequestUrl = miConfig.Url
  431. pp.Cainfo = miConfig.Cainfo
  432. pp.SecretKey = miConfig.SecretKey
  433. pp.AccessKey = miConfig.AccessKey
  434. pp.OpterName = roles.UserName
  435. var config []*models.HisXtDiagnoseConfig
  436. for _, item := range diagnosis_ids {
  437. id, _ := strconv.ParseInt(item, 10, 64)
  438. diagnosisConfig, _ := service.FindDiagnoseById(id)
  439. config = append(config, &diagnosisConfig)
  440. }
  441. var pd models.PatientDtos
  442. pd.PatnID = his.PsnNo
  443. pd.PatnName = his.Name
  444. pd.Gend = his.Gend
  445. pd.Brdy = his.Brdy
  446. pd.Poolarea = his.InsuplcAdmdvs
  447. pd.CurrMdtrtID = his.Number
  448. var fed models.FsiEncounterDtos
  449. fed.MdtrtID = his.Number
  450. fed.MedinsID = miConfig.Code
  451. fed.MedinsName = miConfig.OrgName
  452. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  453. fed.MedMdtrtType = "1"
  454. fed.MedinsType = "1"
  455. fed.MedinsLv = "11"
  456. tm := time.Unix(his.RecordDate, 0)
  457. s_tm := tm.Format("2006-01-02 15:04:05")
  458. fed.AdmDate = s_tm
  459. fed.DscgDate = s_tm
  460. fed.DscgMainDiseCodg = config[0].CountryCode
  461. fed.DscgMainDiseName = config[0].CountryContentName
  462. //诊断信息
  463. var fdds []*models.FsiDiagnoseDtos
  464. for index, item := range config {
  465. if index == 0 {
  466. var fdd models.FsiDiagnoseDtos
  467. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  468. fdd.InoutDiseType = "1"
  469. fdd.MaindiseFlag = "1"
  470. fdd.DiseDate = s_tm
  471. fdd.DiasSrtNo = "1"
  472. fdd.DiseName = item.CountryContentName
  473. fdd.DiseCodg = item.CountryCode
  474. fdds = append(fdds, &fdd)
  475. } else {
  476. var fdd models.FsiDiagnoseDtos
  477. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  478. fdd.InoutDiseType = "1"
  479. fdd.MaindiseFlag = "1"
  480. fdd.DiseDate = s_tm
  481. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  482. fdd.DiseName = item.CountryContentName
  483. fdd.DiseCodg = item.CountryCode
  484. fdds = append(fdds, &fdd)
  485. }
  486. }
  487. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  488. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  489. fed.AdmDeptName = department.Name
  490. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  491. fed.DscgDeptName = department.Name
  492. fed.MedType = order.MedType
  493. //处方医嘱信息
  494. var orders []*models.FsiOrderDtos
  495. //for _, item := range prescriptions {
  496. // for _, subItem := range item.HisDoctorAdviceInfo {
  497. // var order models.FsiOrderDtos
  498. // order.RxID = strconv.FormatInt(item.ID, 10)
  499. // order.Rxno = strconv.FormatInt(item.ID, 10)
  500. // order.LongDrordFlag = "0"
  501. // order.HilistType = "1"
  502. // order.ChrgType = "1"
  503. // order.DrordBhvr = "-"
  504. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  505. // order.HosplistName = subItem.BaseDrugLib.DrugName
  506. // order.HilistLv = "1"
  507. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  509. // order.HosplistName = subItem.BaseDrugLib.DrugName
  510. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), '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. // for _, subItem := range item.HisPrescriptionProject {
  528. // if subItem.Type == 2 {
  529. // var order models.FsiOrderDtos
  530. // order.RxID = strconv.FormatInt(item.ID, 10)
  531. // order.Rxno = strconv.FormatInt(item.ID, 10)
  532. // order.LongDrordFlag = "0"
  533. // order.HilistType = "1"
  534. // order.ChrgType = "1"
  535. // order.DrordBhvr = "-"
  536. // order.HilistCode = subItem.HisProject.MedicalCode
  537. // order.HosplistName = subItem.HisProject.ProjectName
  538. // order.HilistLv = "1"
  539. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.HosplistCode = subItem.HisProject.MedicalCode
  541. // order.HosplistName = subItem.HisProject.ProjectName
  542. // order.Cnt = subItem.Count
  543. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  544. //
  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. // if subItem.Type == 3 {
  563. //
  564. // var order models.FsiOrderDtos
  565. // order.RxID = strconv.FormatInt(item.ID, 10)
  566. // order.Rxno = strconv.FormatInt(item.ID, 10)
  567. // order.LongDrordFlag = "0"
  568. // order.HilistType = "1"
  569. // order.ChrgType = "1"
  570. // order.DrordBhvr = "-"
  571. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  572. // order.HosplistName = subItem.GoodInfo.GoodName
  573. // order.HilistLv = "1"
  574. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  575. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  576. // order.HosplistName = subItem.GoodInfo.GoodName
  577. // order.Cnt = subItem.Count
  578. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  579. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  580. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  581. // order.OwnpayAmt = ""
  582. // order.SelfpayAmt = ""
  583. // order.Spec = ""
  584. // order.SpecUnt = ""
  585. // order.DrordBegnDate = s_tm
  586. // order.DrordStopDate = ""
  587. // order.DrordDrCodg = "1"
  588. // order.DrordDeptName = department.Name
  589. // order.DrordDrCodg = "1"
  590. // order.DrordDrName = doctor_info.UserName
  591. // order.DrordDrProfttl = ""
  592. // order.CurrDrordFlag = "1"
  593. // orders = append(orders, &order)
  594. //
  595. // }
  596. // }
  597. //}
  598. for _, item := range prescriptions {
  599. for _, subItem := range item.HisDoctorAdviceInfo {
  600. var order models.FsiOrderDtos
  601. order.RxID = strconv.FormatInt(item.ID, 10)
  602. order.Rxno = strconv.FormatInt(item.ID, 10)
  603. order.LongDrordFlag = "0"
  604. order.HilistType = "1"
  605. order.ChrgType = "1"
  606. order.DrordBhvr = "-"
  607. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  608. order.HosplistName = subItem.BaseDrugLib.DrugName
  609. order.HilistLv = "1"
  610. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  611. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  612. order.HosplistName = subItem.BaseDrugLib.DrugName
  613. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  614. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  615. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  616. order.OwnpayAmt = ""
  617. order.SelfpayAmt = ""
  618. order.Spec = ""
  619. order.SpecUnt = ""
  620. order.DrordBegnDate = s_tm
  621. order.DrordStopDate = ""
  622. order.DrordDrCodg = "1"
  623. order.DrordDeptName = department.Name
  624. order.DrordDrCodg = "1"
  625. order.DrordDrName = doctor_info.UserName
  626. order.DrordDrProfttl = ""
  627. order.CurrDrordFlag = "1"
  628. orders = append(orders, &order)
  629. }
  630. for _, subItem := range item.HisPrescriptionProject {
  631. if subItem.Type == 2 {
  632. var order models.FsiOrderDtos
  633. order.RxID = strconv.FormatInt(item.ID, 10)
  634. order.Rxno = strconv.FormatInt(item.ID, 10)
  635. order.LongDrordFlag = "0"
  636. order.HilistType = "1"
  637. order.ChrgType = "1"
  638. order.DrordBhvr = "-"
  639. order.HilistCode = subItem.HisProject.MedicalCode
  640. order.HosplistName = subItem.HisProject.ProjectName
  641. order.HilistLv = "1"
  642. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  643. order.HosplistCode = subItem.HisProject.MedicalCode
  644. order.HosplistName = subItem.HisProject.ProjectName
  645. order.Cnt = subItem.Count
  646. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  647. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  648. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  649. order.OwnpayAmt = ""
  650. order.SelfpayAmt = ""
  651. order.Spec = ""
  652. order.SpecUnt = ""
  653. order.DrordBegnDate = s_tm
  654. order.DrordStopDate = ""
  655. order.DrordDrCodg = "1"
  656. order.DrordDeptName = department.Name
  657. order.DrordDrCodg = "1"
  658. order.DrordDrName = doctor_info.UserName
  659. order.DrordDrProfttl = ""
  660. order.CurrDrordFlag = "1"
  661. orders = append(orders, &order)
  662. }
  663. if subItem.Type == 3 {
  664. var order models.FsiOrderDtos
  665. order.RxID = strconv.FormatInt(item.ID, 10)
  666. order.Rxno = strconv.FormatInt(item.ID, 10)
  667. order.LongDrordFlag = "0"
  668. order.HilistType = "1"
  669. order.ChrgType = "1"
  670. order.DrordBhvr = "-"
  671. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  672. order.HosplistName = subItem.GoodInfo.GoodName
  673. order.HilistLv = "1"
  674. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  675. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  676. order.HosplistName = subItem.GoodInfo.GoodName
  677. order.Cnt = subItem.Count
  678. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  679. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  680. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  681. order.OwnpayAmt = ""
  682. order.SelfpayAmt = ""
  683. order.Spec = ""
  684. order.SpecUnt = ""
  685. order.DrordBegnDate = s_tm
  686. order.DrordStopDate = ""
  687. order.DrordDrCodg = "1"
  688. order.DrordDeptName = department.Name
  689. order.DrordDrCodg = "1"
  690. order.DrordDrName = doctor_info.UserName
  691. order.DrordDrProfttl = ""
  692. order.CurrDrordFlag = "1"
  693. orders = append(orders, &order)
  694. }
  695. }
  696. }
  697. //处方医嘱信息
  698. fed.MatnStas = "0"
  699. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  700. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  701. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  702. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  703. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  704. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  705. fed.SetlTotlnum = "1"
  706. fed.Insutype = his.Insutype
  707. fed.ReimFlag = "0"
  708. fed.OutSetlFlag = "0"
  709. var fopd []*models.FsiOperationDtosData
  710. data := make(map[string]interface{})
  711. data["fed"] = fed
  712. data["fdd"] = fdds
  713. data["fod"] = orders
  714. data["pd"] = pd
  715. data["pp"] = pp
  716. data["fopd"] = fopd
  717. data["trig_scen"] = trig_scen
  718. client := &http.Client{}
  719. bytesData, _ := json.Marshal(data)
  720. var req *http.Request
  721. if miConfig.MdtrtareaAdmvs == "320921" {
  722. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  723. } else {
  724. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  725. }
  726. resp, _ := client.Do(req)
  727. defer resp.Body.Close()
  728. body, ioErr := ioutil.ReadAll(resp.Body)
  729. if ioErr != nil {
  730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  732. return res
  733. }
  734. var respJSON map[string]interface{}
  735. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  738. return res
  739. }
  740. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  741. result, _ := json.Marshal(respJSON)
  742. if err := json.Unmarshal([]byte(result), &res); err != nil {
  743. utils.ErrorLog("解析失败:%v", err)
  744. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  745. return res
  746. }
  747. return res
  748. //手术操作集合
  749. //手术操作集合
  750. }
  751. func (c *HisApiController) Check() {
  752. psn_no := c.GetString("psn_no")
  753. in := c.GetString("in")
  754. mt := c.GetString("mt")
  755. baseParams := models.BaseParams{
  756. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  757. FixmedinsCode: "H15049901371",
  758. InsuplcAdmdvs: "150499",
  759. MdtrtareaAdmvs: "150499",
  760. OrgName: "赤峰费森血液透析中心",
  761. Doctor: "1111",
  762. }
  763. service.Gdyb2001(baseParams, psn_no, in, mt)
  764. }
  765. func (c *HisApiController) GetPsnNcdsInfo() {
  766. admin_user_id, _ := c.GetInt64("admin_user_id")
  767. patient_id, _ := c.GetInt64("patient_id")
  768. id, _ := c.GetInt64("id")
  769. adminUser := c.GetAdminUserInfo()
  770. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  771. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  772. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  774. psn_record, _ := service.GetPsnNCDSRecordById(id)
  775. //
  776. //if psn_record.ID == 0 {
  777. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  778. // return
  779. //}
  780. var res Result5301
  781. var res10265 Result5301For10265
  782. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  783. psn_info, _ := service.GetPsnByPatientId(patient_id)
  784. var api string
  785. if miConfig.MdtrtareaAdmvs == "320921" {
  786. 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 +
  787. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  788. } else {
  789. 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 +
  790. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  791. }
  792. resp, requestErr := http.Get(api)
  793. if requestErr != nil {
  794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  795. return
  796. }
  797. body, ioErr := ioutil.ReadAll(resp.Body)
  798. if ioErr != nil {
  799. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  800. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  801. return
  802. }
  803. var respJSON map[string]interface{}
  804. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  805. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  807. return
  808. }
  809. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  810. result, _ := json.Marshal(respJSON)
  811. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  812. utils.ErrorLog("解析失败:%v", err)
  813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  814. return
  815. }
  816. res.ErrMsg = res10265.ErrMsg
  817. res.Output = res10265.Output
  818. res.InfRefmsgid = res10265.InfRefmsgid
  819. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  820. res.Infcode = infocode
  821. } else {
  822. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  823. var dat map[string]interface{}
  824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  825. fmt.Println(dat)
  826. } else {
  827. fmt.Println(err)
  828. }
  829. userJSONBytes, _ := json.Marshal(dat)
  830. if miConfig.Code == "H15049901371" {
  831. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  832. utils.ErrorLog("解析失败:%v", err)
  833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  834. return
  835. }
  836. res.InfRefmsgid = res10265.InfRefmsgid
  837. res.Output = res10265.Output
  838. res.ErrMsg = res10265.ErrMsg
  839. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  840. res.Infcode = infocode
  841. } else {
  842. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  843. utils.ErrorLog("解析失败:%v", err)
  844. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  845. return
  846. }
  847. }
  848. }
  849. if res.Infcode == 0 {
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "result": res.Output.Result,
  852. })
  853. }
  854. }
  855. func (c *HisApiController) CheckInsutype() {
  856. his_patient_id, _ := c.GetInt64("his_patient_id")
  857. admin_user_id, _ := c.GetInt64("admin_user_id")
  858. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  859. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  860. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  861. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  862. var dat map[string]interface{}
  863. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  864. fmt.Println(dat)
  865. } else {
  866. fmt.Println(err)
  867. }
  868. userJSONBytes, _ := json.Marshal(dat)
  869. var res Result90100
  870. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  871. utils.ErrorLog("解析失败:%v", err)
  872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  873. return
  874. }
  875. if res.Infcode != 0 {
  876. c.ServeSuccessJSON(map[string]interface{}{
  877. "failed_code": -10,
  878. "msg": res.ErrMsg,
  879. })
  880. return
  881. } else {
  882. fmt.Println(res)
  883. }
  884. }
  885. func (c *HisApiController) CheckCardPWD() {
  886. card_pwd := c.GetString("card_pwd")
  887. his_patient_id, _ := c.GetInt64("his_patient_id")
  888. admin_user_id, _ := c.GetInt64("admin_user_id")
  889. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  890. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  891. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  892. psn, _ := service.GetPsnByPatientId(his.PatientId)
  893. bas := strings.Split(psn.CardInfo, "|")
  894. basNumber := bas[2]
  895. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  896. var dat map[string]interface{}
  897. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  898. fmt.Println(dat)
  899. } else {
  900. fmt.Println(err)
  901. }
  902. userJSONBytes, _ := json.Marshal(dat)
  903. var res Result90991
  904. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  905. utils.ErrorLog("解析失败:%v", err)
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  907. return
  908. }
  909. if res.Infcode != 0 {
  910. c.ServeSuccessJSON(map[string]interface{}{
  911. "failed_code": -10,
  912. "msg": res.ErrMsg,
  913. })
  914. return
  915. } else {
  916. if res.Output.Result.SscnoCheckStat == "0" {
  917. var msg string
  918. switch res.Output.Result.CardStat {
  919. case "00":
  920. msg = "未激活"
  921. break
  922. case "10":
  923. msg = "激活"
  924. break
  925. case "20":
  926. msg = "窗口挂失"
  927. break
  928. case "21":
  929. msg = "电话挂失"
  930. break
  931. case "22":
  932. msg = "单位网上申报挂失"
  933. break
  934. case "23":
  935. msg = "保健办挂失"
  936. break
  937. case "24":
  938. msg = "个人网上挂失"
  939. break
  940. case "25":
  941. msg = "网上服务大厅挂失"
  942. break
  943. case "30":
  944. msg = "注销"
  945. break
  946. case "40":
  947. msg = "回收"
  948. break
  949. case "99":
  950. msg = "制卡中(无效卡)"
  951. break
  952. }
  953. c.ServeSuccessJSON(map[string]interface{}{
  954. "failed_code": -10,
  955. "msg": msg,
  956. })
  957. return
  958. } else {
  959. c.ServeSuccessJSON(map[string]interface{}{
  960. "msg": "校验成功",
  961. })
  962. return
  963. }
  964. }
  965. }
  966. func (c *HisApiController) CheckCardPWDTwo() {
  967. //card_pwd := c.GetString("card_pwd")
  968. //his_patient_id, _ := c.GetInt64("his_patient_id")
  969. admin_user_id, _ := c.GetInt64("admin_user_id")
  970. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  971. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  972. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  973. var dat map[string]interface{}
  974. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  975. fmt.Println(dat)
  976. } else {
  977. fmt.Println(err)
  978. }
  979. userJSONBytes, _ := json.Marshal(dat)
  980. var res Result90991
  981. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  982. utils.ErrorLog("解析失败:%v", err)
  983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  984. return
  985. }
  986. if res.Infcode != 0 {
  987. c.ServeSuccessJSON(map[string]interface{}{
  988. "failed_code": -10,
  989. "msg": res.ErrMsg,
  990. })
  991. return
  992. } else {
  993. if res.Output.Result.SscnoCheckStat == "0" {
  994. var msg string
  995. switch res.Output.Result.CardStat {
  996. case "00":
  997. msg = "未激活"
  998. break
  999. case "10":
  1000. msg = "激活"
  1001. break
  1002. case "20":
  1003. msg = "窗口挂失"
  1004. break
  1005. case "21":
  1006. msg = "电话挂失"
  1007. break
  1008. case "22":
  1009. msg = "单位网上申报挂失"
  1010. break
  1011. case "23":
  1012. msg = "保健办挂失"
  1013. break
  1014. case "24":
  1015. msg = "个人网上挂失"
  1016. break
  1017. case "25":
  1018. msg = "网上服务大厅挂失"
  1019. break
  1020. case "30":
  1021. msg = "注销"
  1022. break
  1023. case "40":
  1024. msg = "回收"
  1025. break
  1026. case "99":
  1027. msg = "制卡中(无效卡)"
  1028. break
  1029. }
  1030. c.ServeSuccessJSON(map[string]interface{}{
  1031. "failed_code": -10,
  1032. "msg": msg,
  1033. })
  1034. return
  1035. } else {
  1036. c.ServeSuccessJSON(map[string]interface{}{
  1037. "msg": "校验成功",
  1038. })
  1039. return
  1040. }
  1041. }
  1042. }
  1043. type ELeCertData struct {
  1044. Data struct {
  1045. Extra string `json:"extra"`
  1046. IDNo string `json:"idNo"`
  1047. IDType string `json:"idType"`
  1048. EcToken string `json:"ecToken"`
  1049. InsuOrg string `json:"insuOrg"`
  1050. UserName string `json:"userName"`
  1051. EcIndexNo string `json:"ecIndexNo"`
  1052. Gender string `json:"gender"`
  1053. Birthday string `json:"birthday"`
  1054. Nationality string `json:"nationality"`
  1055. Email string `json:"email"`
  1056. } `json:"OutData"`
  1057. }
  1058. func (c *HisApiController) ReadCard() {
  1059. id_card_type, _ := c.GetInt64("id_card_type")
  1060. admin_user_id, _ := c.GetInt64("admin_user_id")
  1061. certificates, _ := c.GetInt64("certificates")
  1062. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1063. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1064. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1065. switch id_card_type {
  1066. case 1:
  1067. if miConfig.MdtrtareaAdmvs == "421300" {
  1068. var res ResultTwo
  1069. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1070. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1071. "&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)
  1072. resp, requestErr := http.Get(api)
  1073. if requestErr != nil {
  1074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1075. return
  1076. }
  1077. body, ioErr := ioutil.ReadAll(resp.Body)
  1078. if ioErr != nil {
  1079. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1081. return
  1082. }
  1083. var respJSON map[string]interface{}
  1084. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1085. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1090. result, _ := json.Marshal(respJSON)
  1091. fmt.Println("log")
  1092. fmt.Println(string(result))
  1093. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1094. utils.ErrorLog("解析失败:%v", err)
  1095. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1096. return
  1097. }
  1098. if res.Infcode == 0 {
  1099. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1100. if err == gorm.ErrRecordNotFound {
  1101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1102. return
  1103. } else if err != nil {
  1104. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1105. return
  1106. } else {
  1107. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1108. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1109. infoStr := string(Iinfos)
  1110. idetinfoStr := string(Idetinfos)
  1111. psn := &models.HisPsn{
  1112. PsnNo: res.Output.Baseinfo.PsnNo,
  1113. Age: res.Output.Baseinfo.Age,
  1114. PatientId: patient.ID,
  1115. Certno: res.Output.Baseinfo.Certno,
  1116. Brdy: res.Output.Baseinfo.Brdy,
  1117. Gend: res.Output.Baseinfo.Gend,
  1118. Naty: res.Output.Baseinfo.Naty,
  1119. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1120. PsnName: res.Output.Baseinfo.PsnName,
  1121. Idetinfo: idetinfoStr,
  1122. Insuinfo: infoStr,
  1123. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1124. }
  1125. service.CreateHisPsn(psn)
  1126. c.ServeSuccessJSON(map[string]interface{}{
  1127. "patient": patient,
  1128. "number": res.Output.Baseinfo.Certno,
  1129. })
  1130. }
  1131. } else {
  1132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1133. return
  1134. }
  1135. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1136. var api string
  1137. if miConfig.MdtrtareaAdmvs == "320921" {
  1138. 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 +
  1139. "&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
  1140. fmt.Println(api)
  1141. } else {
  1142. 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 +
  1143. "&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)
  1144. }
  1145. resp, requestErr := http.Get(api)
  1146. if requestErr != nil {
  1147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1148. return
  1149. }
  1150. body, ioErr := ioutil.ReadAll(resp.Body)
  1151. if ioErr != nil {
  1152. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1154. return
  1155. }
  1156. var respJSON map[string]interface{}
  1157. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1158. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return
  1161. }
  1162. var status string
  1163. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1164. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1165. //console.log()
  1166. fmt.Println("type===")
  1167. fmt.Println(card_type)
  1168. var token string
  1169. var res ResultTwo //1101结果
  1170. var res10265 ResultTwo10265 //1101结果
  1171. var card_info string //卡信息
  1172. var busi_card_info string
  1173. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1174. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1175. if status == "0" { //读卡成功
  1176. if card_type == "1" {
  1177. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1178. result, _ := json.Marshal(respJSON)
  1179. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1180. utils.ErrorLog("解析失败:%v", err)
  1181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1182. return
  1183. }
  1184. res.ErrMsg = res10265.ErrMsg
  1185. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1186. res.Infcode = infocode
  1187. res.Output = res10265.Output
  1188. res.InfRefmsgid = res10265.InfRefmsgid
  1189. } else {
  1190. //var card_info string //卡信息
  1191. //var busi_card_info string
  1192. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1193. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1194. //fmt.Println(card_info)
  1195. //fmt.Println(busi_card_info)
  1196. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1197. result, _ := json.Marshal(respJSON)
  1198. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1199. utils.ErrorLog("解析失败:%v", err)
  1200. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1201. return
  1202. }
  1203. res.ErrMsg = res10265.ErrMsg
  1204. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1205. res.Infcode = infocode
  1206. res.Output = res10265.Output
  1207. res.InfRefmsgid = res10265.InfRefmsgid
  1208. }
  1209. if res.Infcode == 0 {
  1210. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1211. if err == gorm.ErrRecordNotFound {
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1213. return
  1214. } else if err != nil {
  1215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1216. return
  1217. } else {
  1218. if card_type == "1" {
  1219. bas := strings.Split(card_info, "|")
  1220. basNumber := bas[2]
  1221. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1222. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1223. infoStr := string(Iinfos)
  1224. idetinfoStr := string(Idetinfos)
  1225. psn := &models.HisPsn{
  1226. PsnNo: res.Output.Baseinfo.PsnNo,
  1227. Age: res.Output.Baseinfo.Age,
  1228. PatientId: patient.ID,
  1229. Certno: res.Output.Baseinfo.Certno,
  1230. Brdy: res.Output.Baseinfo.Brdy,
  1231. Gend: res.Output.Baseinfo.Gend,
  1232. Naty: res.Output.Baseinfo.Naty,
  1233. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1234. PsnName: res.Output.Baseinfo.PsnName,
  1235. Idetinfo: idetinfoStr,
  1236. Insuinfo: infoStr,
  1237. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1238. CardInfo: card_info,
  1239. VerifyNumber: busi_card_info,
  1240. }
  1241. service.CreateHisPsn(psn)
  1242. var rf []*ResultFive
  1243. json.Unmarshal([]byte(infoStr), &rf)
  1244. var insutypes []*ResultFive
  1245. var insutype string
  1246. var is390 int = 0
  1247. var is310 int = 0
  1248. for _, item := range rf {
  1249. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1250. insutypes = append(insutypes, item)
  1251. }
  1252. }
  1253. if len(insutypes) == 1 {
  1254. insutype = insutypes[0].Insutype
  1255. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1256. } else {
  1257. for _, i := range insutypes {
  1258. if i.Insutype == "390" {
  1259. is390 = 1
  1260. }
  1261. if i.Insutype == "310" {
  1262. is310 = 1
  1263. }
  1264. }
  1265. }
  1266. if is390 == 1 {
  1267. insutype = "390"
  1268. }
  1269. if is310 == 1 {
  1270. insutype = "310"
  1271. }
  1272. if len(insutypes) == 0 {
  1273. insutype = "310"
  1274. }
  1275. c.ServeSuccessJSON(map[string]interface{}{
  1276. "patient": patient,
  1277. "number": basNumber,
  1278. "insutype": insutype,
  1279. })
  1280. } else {
  1281. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1282. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1283. infoStr := string(Iinfos)
  1284. idetinfoStr := string(Idetinfos)
  1285. psn := &models.HisPsn{
  1286. PsnNo: res.Output.Baseinfo.PsnNo,
  1287. Age: res.Output.Baseinfo.Age,
  1288. PatientId: patient.ID,
  1289. Certno: res.Output.Baseinfo.Certno,
  1290. Brdy: res.Output.Baseinfo.Brdy,
  1291. Gend: res.Output.Baseinfo.Gend,
  1292. Naty: res.Output.Baseinfo.Naty,
  1293. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1294. PsnName: res.Output.Baseinfo.PsnName,
  1295. Idetinfo: idetinfoStr,
  1296. Insuinfo: infoStr,
  1297. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1298. CardInfo: card_info,
  1299. VerifyNumber: token,
  1300. }
  1301. service.CreateHisPsn(psn)
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "patient": patient,
  1304. "number": token,
  1305. })
  1306. }
  1307. }
  1308. } else {
  1309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1310. return
  1311. }
  1312. } else { //读卡失败
  1313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1314. return
  1315. }
  1316. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1317. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1318. cardnum = DeleteExtraSpaceTwo(cardnum)
  1319. cardCode = DeleteExtraSpaceTwo(cardCode)
  1320. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1321. name = DeleteExtraSpaceTwo(name)
  1322. errmsg = DeleteExtraSpaceTwo(errmsg)
  1323. cardnum = Remove0000(cardnum)
  1324. cardCode = Remove0000(cardCode)
  1325. id_card_no = Remove0000(id_card_no)
  1326. name = Remove0000(name)
  1327. errmsg = Remove0000(errmsg)
  1328. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1329. 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)
  1330. saveLog(result, requestLog, "1101", "获取人员信息")
  1331. fmt.Println(errMsgLog)
  1332. if len(errMsgLog) > 0 {
  1333. } else {
  1334. var dat map[string]interface{}
  1335. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1336. fmt.Println(dat)
  1337. } else {
  1338. fmt.Println(err)
  1339. }
  1340. userJSONBytes, _ := json.Marshal(dat)
  1341. var res ResultTwo
  1342. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1343. utils.ErrorLog("解析失败:%v", err)
  1344. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1345. return
  1346. }
  1347. res.ErrMsg = errMsgLog
  1348. if res.Infcode == 0 {
  1349. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1350. if err == gorm.ErrRecordNotFound {
  1351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1352. return
  1353. } else if err != nil {
  1354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1355. return
  1356. } else {
  1357. fmt.Println(res)
  1358. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1359. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1360. infoStr := string(Iinfos)
  1361. idetinfoStr := string(Idetinfos)
  1362. psn := &models.HisPsn{
  1363. PsnNo: res.Output.Baseinfo.PsnNo,
  1364. Age: res.Output.Baseinfo.Age,
  1365. PatientId: patient.ID,
  1366. Certno: res.Output.Baseinfo.Certno,
  1367. Brdy: res.Output.Baseinfo.Brdy,
  1368. Gend: res.Output.Baseinfo.Gend,
  1369. Naty: res.Output.Baseinfo.Naty,
  1370. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1371. PsnName: res.Output.Baseinfo.PsnName,
  1372. Idetinfo: idetinfoStr,
  1373. Insuinfo: infoStr,
  1374. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1375. CardInfo: basStr,
  1376. VerifyNumber: "",
  1377. }
  1378. service.CreateHisPsn(psn)
  1379. var rf []*ResultFive
  1380. json.Unmarshal([]byte(infoStr), &rf)
  1381. var insutypes []*ResultFive
  1382. var insutype string
  1383. var is390 int = 0
  1384. var is310 int = 0
  1385. for _, item := range rf {
  1386. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1387. insutypes = append(insutypes, item)
  1388. }
  1389. }
  1390. if len(insutypes) == 1 {
  1391. insutype = insutypes[0].Insutype
  1392. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1393. } else {
  1394. for _, i := range insutypes {
  1395. if i.Insutype == "390" {
  1396. is390 = 1
  1397. }
  1398. if i.Insutype == "310" {
  1399. is310 = 1
  1400. }
  1401. }
  1402. }
  1403. if is390 == 1 {
  1404. insutype = "390"
  1405. }
  1406. if is310 == 1 {
  1407. insutype = "310"
  1408. }
  1409. if len(insutypes) == 0 {
  1410. insutype = "310"
  1411. }
  1412. c.ServeSuccessJSON(map[string]interface{}{
  1413. "patient": patient,
  1414. "number": cardnum,
  1415. "insutype": insutype,
  1416. })
  1417. }
  1418. } else {
  1419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1420. return
  1421. }
  1422. }
  1423. } else {
  1424. if initFlag == 0 {
  1425. c.TestGetBasBaseInit()
  1426. }
  1427. basStr := c.GetBasBaseInfo()
  1428. if len(basStr) == 0 {
  1429. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1430. return
  1431. }
  1432. fmt.Println(basStr)
  1433. bas := strings.Split(basStr, "|")
  1434. basNumber := bas[1]
  1435. fmt.Println(basNumber)
  1436. card_sn := bas[3]
  1437. fmt.Println(card_sn)
  1438. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1462. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1463. infoStr := string(Iinfos)
  1464. idetinfoStr := string(Idetinfos)
  1465. psn := &models.HisPsn{
  1466. PsnNo: res.Output.Baseinfo.PsnNo,
  1467. Age: res.Output.Baseinfo.Age,
  1468. PatientId: patient.ID,
  1469. Certno: res.Output.Baseinfo.Certno,
  1470. Brdy: res.Output.Baseinfo.Brdy,
  1471. Gend: res.Output.Baseinfo.Gend,
  1472. Naty: res.Output.Baseinfo.Naty,
  1473. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1474. PsnName: res.Output.Baseinfo.PsnName,
  1475. Idetinfo: idetinfoStr,
  1476. Insuinfo: infoStr,
  1477. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1478. CardInfo: basStr,
  1479. VerifyNumber: "",
  1480. }
  1481. service.CreateHisPsn(psn)
  1482. c.ServeSuccessJSON(map[string]interface{}{
  1483. "patient": patient,
  1484. "number": basNumber,
  1485. })
  1486. }
  1487. } else {
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1489. return
  1490. }
  1491. break
  1492. }
  1493. case 2:
  1494. SFZStr := c.GetSFZBaseInfo()
  1495. id_card_str := strings.Split(SFZStr, "^")
  1496. id_card_number := id_card_str[0]
  1497. card_sn := ""
  1498. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1499. var dat map[string]interface{}
  1500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1501. fmt.Println(dat)
  1502. } else {
  1503. fmt.Println(err)
  1504. }
  1505. userJSONBytes, _ := json.Marshal(dat)
  1506. var res ResultTwo
  1507. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1508. utils.ErrorLog("解析失败:%v", err)
  1509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1510. return
  1511. }
  1512. if res.Infcode == 0 {
  1513. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1514. if err == gorm.ErrRecordNotFound {
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1516. return
  1517. } else if err != nil {
  1518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1519. return
  1520. } else {
  1521. c.ServeSuccessJSON(map[string]interface{}{
  1522. "patient": patient,
  1523. "number": id_card_number,
  1524. })
  1525. }
  1526. } else {
  1527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1528. return
  1529. }
  1530. break
  1531. case 3:
  1532. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1533. var api string
  1534. if miConfig.MdtrtareaAdmvs == "320921" {
  1535. 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 +
  1536. "&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
  1537. fmt.Println(api)
  1538. } else {
  1539. 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 +
  1540. "&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)
  1541. }
  1542. resp, requestErr := http.Get(api)
  1543. if requestErr != nil {
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. return
  1546. }
  1547. body, ioErr := ioutil.ReadAll(resp.Body)
  1548. if ioErr != nil {
  1549. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1551. return
  1552. }
  1553. var respJSON map[string]interface{}
  1554. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1555. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1557. return
  1558. }
  1559. var status string
  1560. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1561. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1562. var token string
  1563. var res ResultTwo //1101结果
  1564. var res10265 ResultTwo10265 //1101结果
  1565. var card_info string //卡信息
  1566. var busi_card_info string
  1567. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1568. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1569. if status == "0" { //读卡成功
  1570. if card_type == "1" {
  1571. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1572. result, _ := json.Marshal(respJSON)
  1573. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1574. utils.ErrorLog("解析失败:%v", err)
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1576. return
  1577. }
  1578. res.ErrMsg = res10265.ErrMsg
  1579. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1580. res.Infcode = infocode
  1581. res.Output = res10265.Output
  1582. res.InfRefmsgid = res10265.InfRefmsgid
  1583. } else {
  1584. //var card_info string //卡信息
  1585. //var busi_card_info string
  1586. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1587. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1588. //fmt.Println(card_info)
  1589. //fmt.Println(busi_card_info)
  1590. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1591. result, _ := json.Marshal(respJSON)
  1592. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1593. utils.ErrorLog("解析失败:%v", err)
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1595. return
  1596. }
  1597. res.ErrMsg = res10265.ErrMsg
  1598. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1599. res.Infcode = infocode
  1600. res.Output = res10265.Output
  1601. res.InfRefmsgid = res10265.InfRefmsgid
  1602. }
  1603. if res.Infcode == 0 {
  1604. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1605. if err == gorm.ErrRecordNotFound {
  1606. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1607. return
  1608. } else if err != nil {
  1609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1610. return
  1611. } else {
  1612. if card_type == "1" {
  1613. bas := strings.Split(card_info, "|")
  1614. basNumber := bas[2]
  1615. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1616. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1617. infoStr := string(Iinfos)
  1618. idetinfoStr := string(Idetinfos)
  1619. psn := &models.HisPsn{
  1620. PsnNo: res.Output.Baseinfo.PsnNo,
  1621. Age: res.Output.Baseinfo.Age,
  1622. PatientId: patient.ID,
  1623. Certno: res.Output.Baseinfo.Certno,
  1624. Brdy: res.Output.Baseinfo.Brdy,
  1625. Gend: res.Output.Baseinfo.Gend,
  1626. Naty: res.Output.Baseinfo.Naty,
  1627. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1628. PsnName: res.Output.Baseinfo.PsnName,
  1629. Idetinfo: idetinfoStr,
  1630. Insuinfo: infoStr,
  1631. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1632. CardInfo: card_info,
  1633. VerifyNumber: busi_card_info,
  1634. }
  1635. service.CreateHisPsn(psn)
  1636. c.ServeSuccessJSON(map[string]interface{}{
  1637. "patient": patient,
  1638. "number": basNumber,
  1639. })
  1640. } else {
  1641. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1642. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1643. infoStr := string(Iinfos)
  1644. idetinfoStr := string(Idetinfos)
  1645. psn := &models.HisPsn{
  1646. PsnNo: res.Output.Baseinfo.PsnNo,
  1647. Age: res.Output.Baseinfo.Age,
  1648. PatientId: patient.ID,
  1649. Certno: res.Output.Baseinfo.Certno,
  1650. Brdy: res.Output.Baseinfo.Brdy,
  1651. Gend: res.Output.Baseinfo.Gend,
  1652. Naty: res.Output.Baseinfo.Naty,
  1653. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1654. PsnName: res.Output.Baseinfo.PsnName,
  1655. Idetinfo: idetinfoStr,
  1656. Insuinfo: infoStr,
  1657. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1658. CardInfo: card_info,
  1659. VerifyNumber: token,
  1660. }
  1661. service.CreateHisPsn(psn)
  1662. var rf []*ResultFive
  1663. json.Unmarshal([]byte(infoStr), &rf)
  1664. var insutypes []*ResultFive
  1665. var insutype string
  1666. var is390 int = 0
  1667. var is310 int = 0
  1668. for _, item := range rf {
  1669. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1670. insutypes = append(insutypes, item)
  1671. }
  1672. }
  1673. if len(insutypes) == 1 {
  1674. insutype = insutypes[0].Insutype
  1675. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1676. } else {
  1677. for _, i := range insutypes {
  1678. if i.Insutype == "390" {
  1679. is390 = 1
  1680. }
  1681. if i.Insutype == "310" {
  1682. is310 = 1
  1683. }
  1684. }
  1685. }
  1686. if is390 == 1 {
  1687. insutype = "390"
  1688. }
  1689. if is310 == 1 {
  1690. insutype = "310"
  1691. }
  1692. if len(insutypes) == 0 {
  1693. insutype = "310"
  1694. }
  1695. c.ServeSuccessJSON(map[string]interface{}{
  1696. "patient": patient,
  1697. "number": token,
  1698. "insutype": insutype,
  1699. })
  1700. }
  1701. }
  1702. } else {
  1703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1704. return
  1705. }
  1706. } else { //读卡失败
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1708. return
  1709. }
  1710. }
  1711. break
  1712. case 4:
  1713. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1714. var api string
  1715. if miConfig.MdtrtareaAdmvs == "320921" {
  1716. 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 +
  1717. "&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
  1718. fmt.Println(api)
  1719. } else {
  1720. 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 +
  1721. "&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)
  1722. }
  1723. resp, requestErr := http.Get(api)
  1724. if requestErr != nil {
  1725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1726. return
  1727. }
  1728. body, ioErr := ioutil.ReadAll(resp.Body)
  1729. if ioErr != nil {
  1730. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1732. return
  1733. }
  1734. var respJSON map[string]interface{}
  1735. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1736. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1737. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1738. return
  1739. }
  1740. var status string
  1741. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1742. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1743. var token string
  1744. var res ResultTwo //1101结果
  1745. var res10265 ResultTwo10265 //1101结果
  1746. if status == "0" { //读卡成功
  1747. var card_info string //卡信息
  1748. var busi_card_info string
  1749. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1750. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1751. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1752. fmt.Println(card_info)
  1753. fmt.Println(busi_card_info)
  1754. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1755. result, _ := json.Marshal(respJSON)
  1756. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1757. utils.ErrorLog("解析失败:%v", err)
  1758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1759. return
  1760. }
  1761. res.ErrMsg = res10265.ErrMsg
  1762. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1763. res.Infcode = infocode
  1764. res.Output = res10265.Output
  1765. res.InfRefmsgid = res10265.InfRefmsgid
  1766. if res.Infcode == 0 {
  1767. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1768. if err == gorm.ErrRecordNotFound {
  1769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1770. return
  1771. } else if err != nil {
  1772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1773. return
  1774. } else {
  1775. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1776. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1777. infoStr := string(Iinfos)
  1778. idetinfoStr := string(Idetinfos)
  1779. psn := &models.HisPsn{
  1780. PsnNo: res.Output.Baseinfo.PsnNo,
  1781. Age: res.Output.Baseinfo.Age,
  1782. PatientId: patient.ID,
  1783. Certno: res.Output.Baseinfo.Certno,
  1784. Brdy: res.Output.Baseinfo.Brdy,
  1785. Gend: res.Output.Baseinfo.Gend,
  1786. Naty: res.Output.Baseinfo.Naty,
  1787. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1788. PsnName: res.Output.Baseinfo.PsnName,
  1789. Idetinfo: idetinfoStr,
  1790. Insuinfo: infoStr,
  1791. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1792. CardInfo: card_info,
  1793. VerifyNumber: token,
  1794. }
  1795. service.CreateHisPsn(psn)
  1796. c.ServeSuccessJSON(map[string]interface{}{
  1797. "patient": patient,
  1798. "number": token,
  1799. })
  1800. }
  1801. } else {
  1802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1803. return
  1804. }
  1805. } else { //读卡失败
  1806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1807. return
  1808. }
  1809. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1810. result, requestLog := service.Gdyb6101(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  1811. saveLog(result, requestLog, "6101", "电子凭证")
  1812. var ele ELeCertData
  1813. err := json.Unmarshal([]byte(result), &ele)
  1814. if err != nil {
  1815. utils.ErrorLog("解析失败:%v", err)
  1816. }
  1817. result2, requestLog2 := service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, ele.Data.EcToken)
  1818. saveLog(result2, requestLog2, "1101", "获取人员信息")
  1819. var res ResultTwo
  1820. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  1821. utils.ErrorLog("解析失败:%v", err)
  1822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. return
  1824. }
  1825. if res.Infcode == 0 {
  1826. patient, err := service.GetPatientByNumber(ele.Data.IDNo, c.GetAdminUserInfo().CurrentOrgId)
  1827. if err == gorm.ErrRecordNotFound {
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1829. return
  1830. } else if err != nil {
  1831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1832. return
  1833. } else {
  1834. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1835. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1836. infoStr := string(Iinfos)
  1837. idetinfoStr := string(Idetinfos)
  1838. psn := &models.HisPsn{
  1839. PsnNo: res.Output.Baseinfo.PsnNo,
  1840. Age: res.Output.Baseinfo.Age,
  1841. PatientId: patient.ID,
  1842. Certno: res.Output.Baseinfo.Certno,
  1843. Brdy: res.Output.Baseinfo.Brdy,
  1844. Gend: res.Output.Baseinfo.Gend,
  1845. Naty: res.Output.Baseinfo.Naty,
  1846. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1847. PsnName: res.Output.Baseinfo.PsnName,
  1848. Idetinfo: idetinfoStr,
  1849. Insuinfo: infoStr,
  1850. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1851. CardInfo: "",
  1852. VerifyNumber: ele.Data.EcToken,
  1853. }
  1854. service.CreateHisPsn(psn)
  1855. c.ServeSuccessJSON(map[string]interface{}{
  1856. "patient": patient,
  1857. "number": ele.Data.EcToken,
  1858. })
  1859. }
  1860. } else {
  1861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1862. return
  1863. }
  1864. }
  1865. break
  1866. }
  1867. }
  1868. var initFlag int64 = 0
  1869. func (c *HisApiController) TestGetBasBaseInit() {
  1870. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1871. Iinit := DllDef.MustFindProc("Init")
  1872. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1873. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1874. if ret != 0 {
  1875. fmt.Println("SSCard的报错原因:", err)
  1876. fmt.Println("SSCard的运算结果为:", ret)
  1877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1878. return
  1879. }
  1880. result := int(ret)
  1881. fmt.Println("SSCard的运算结果为1:", result)
  1882. initFlag = 1
  1883. return
  1884. }
  1885. func (c *HisApiController) GetSFZBaseInfo() string {
  1886. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1887. readCard := DllDef.MustFindProc("ReadSFZ")
  1888. if readCard == nil {
  1889. fmt.Println("readcard is nil")
  1890. readCard = DllDef.MustFindProc("ReadSFZ")
  1891. }
  1892. str := make([]byte, 256)
  1893. str1 := make([]byte, 256)
  1894. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1895. fmt.Println(r)
  1896. return string(str)
  1897. }
  1898. func (c *HisApiController) GetBasBaseInfo() string {
  1899. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1900. readCard := DllDef.MustFindProc("ReadCardBas")
  1901. if readCard == nil {
  1902. fmt.Println("readcard is nil")
  1903. readCard = DllDef.MustFindProc("ReadCardBas")
  1904. }
  1905. str := make([]byte, 1024)
  1906. str1 := make([]byte, 1024)
  1907. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1908. fmt.Println(string(str1))
  1909. fmt.Println(string(str))
  1910. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1911. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1912. if ret2 != 0 {
  1913. return ""
  1914. }
  1915. return string(str)
  1916. }
  1917. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1918. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1919. readCard := DllDef.MustFindProc("read_cardinfo")
  1920. if readCard == nil {
  1921. fmt.Println("readcard is nil")
  1922. readCard = DllDef.MustFindProc("read_cardinfo")
  1923. }
  1924. str := make([]byte, 1024) //卡号
  1925. str1 := make([]byte, 1024) //卡识别码
  1926. str2 := make([]byte, 1024) //身份证号
  1927. str3 := make([]byte, 1024) //姓名
  1928. str4 := make([]byte, 1024) //错误信息
  1929. 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])))
  1930. fmt.Println(string(str1))
  1931. fmt.Println(string(str))
  1932. fmt.Println(string(str2))
  1933. fmt.Println(string(str3))
  1934. fmt.Println(string(str4))
  1935. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1936. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1937. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1938. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1939. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1940. if ret2 != 0 {
  1941. return "", "", "", "", ""
  1942. }
  1943. return string(str), string(str1), string(str2), string(str3), string(str4)
  1944. }
  1945. type CustomFundPay struct {
  1946. FundPayType string `json:"fund_pay_type"`
  1947. FundPayamt float64 `json:"fund_payamt"`
  1948. }
  1949. func (c *HisApiController) GetSettleList() {
  1950. order_id, _ := c.GetInt64("order_id")
  1951. admin_user_id, _ := c.GetInt64("admin_user_id")
  1952. order, _ := service.GetHisOrderByIDTwo(order_id)
  1953. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1954. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1955. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1956. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1957. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1958. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1959. if order.ID == 0 {
  1960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1961. return
  1962. }
  1963. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1964. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1965. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1966. fmt.Println(count)
  1967. var zero string
  1968. number := count + 1
  1969. if number >= 1000 {
  1970. zero = "0000" + strconv.FormatInt(number, 10)
  1971. } else if number >= 10000 {
  1972. zero = "000" + strconv.FormatInt(number, 10)
  1973. } else if number >= 100000 {
  1974. zero = "00" + strconv.FormatInt(number, 10)
  1975. } else if number >= 1000000 {
  1976. zero = "0" + strconv.FormatInt(number, 10)
  1977. } else {
  1978. zero = strconv.FormatInt(number, 10)
  1979. }
  1980. fmt.Println(zero)
  1981. struct4101 := service.Struct4101{
  1982. PsnNo: order.PsnNo,
  1983. MdtrtId: order.MdtrtId,
  1984. SetlId: order.SetlId,
  1985. PsnName: order.PsnName,
  1986. Gend: order.Gend,
  1987. Brdy: his.Brdy,
  1988. Age: his.Age,
  1989. Naty: order.Naty,
  1990. PatnCertType: "01",
  1991. Certno: order.Certno,
  1992. Prfs: "90",
  1993. ConerName: roles[0].UserName,
  1994. PatnRlts: "99",
  1995. ConerAddr: miConfig.OrgName,
  1996. ConerTel: admin.Mobile,
  1997. HiType: order.Insutype,
  1998. Insuplc: miConfig.InsuplcAdmdvs,
  1999. MaindiagFlag: "1",
  2000. BillCode: last_order.FaPiaoCode,
  2001. BillNo: zero,
  2002. BizSn: order.Number,
  2003. PsnSelfPay: order.PsnPartAmt,
  2004. PsnOwnPay: order.PsnPartAmt,
  2005. AcctPay: order.AcctPay,
  2006. PsnCashpay: order.PsnCashPay,
  2007. HiPaymtd: "1",
  2008. Hsorg: miConfig.InsuplcAdmdvs,
  2009. HsorgOpter: miConfig.InsuplcAdmdvs,
  2010. MedinsFillPsn: curRoles.UserName,
  2011. MedinsFillDept: depart.Name,
  2012. IptMedType: "2",
  2013. }
  2014. struct4101.SetlBegnDate = order.SetlTime
  2015. struct4101.SetlEndDate = order.SetlTime
  2016. time_arr := strings.Split(order.SetlTime, " ")
  2017. struct4101.AdmTime = time_arr[0]
  2018. struct4101.AdmEndTime = time_arr[0]
  2019. var rf []CustomFundPay
  2020. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2021. var tempFunPays []service.CustomStruct
  2022. for _, item := range rf {
  2023. var tempFunPay service.CustomStruct
  2024. tempFunPay.FundPayamt = item.FundPayamt
  2025. tempFunPay.FundPayType = item.FundPayType
  2026. tempFunPays = append(tempFunPays, tempFunPay)
  2027. }
  2028. struct4101.CustomStruct = tempFunPays
  2029. var tempDiaginfos []service.DiaginfoStructTwo
  2030. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2031. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2032. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  2033. var config []*models.HisXtDiagnoseConfig
  2034. for _, item := range diagnosis_ids {
  2035. id, _ := strconv.ParseInt(item, 10, 64)
  2036. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2037. config = append(config, &diagnosisConfig)
  2038. }
  2039. for index, item := range config {
  2040. if index == 0 {
  2041. var tempDiaginfo service.DiaginfoStructTwo
  2042. tempDiaginfo.DiagCode = item.CountryCode
  2043. tempDiaginfo.DiagName = item.CountryContentName
  2044. tempDiaginfo.DiagType = "1"
  2045. tempDiaginfo.MaindiagFlag = "1"
  2046. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2047. } else {
  2048. var tempDiaginfo service.DiaginfoStructTwo
  2049. tempDiaginfo.DiagCode = item.CountryCode
  2050. tempDiaginfo.DiagName = item.CountryContentName
  2051. tempDiaginfo.DiagType = "2"
  2052. tempDiaginfo.MaindiagFlag = "0"
  2053. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2054. }
  2055. }
  2056. struct4101.Diseinfo = tempDiaginfos
  2057. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2058. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2059. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2060. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  2061. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  2062. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2063. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2064. var iteminfo service.IteminfoStruct
  2065. var bedCostTotal float64 = 0 //床位总费
  2066. var bedCostSelfTotal float64 = 0 //床位自费
  2067. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2068. var operationCostTotal float64 = 0 //手术费
  2069. var operationCostSelfTotal float64 = 0 //手术费
  2070. var operationCostPartSelfTotal float64 = 0 //手术费
  2071. var otherCostTotal float64 = 0 //其他费用
  2072. var otherCostSelfTotal float64 = 0 //其他费用
  2073. var otherCostPartSelfTotal float64 = 0 //其他费用
  2074. var materialCostTotal float64 = 0 //材料费
  2075. var materialCostSelfTotal float64 = 0 //材料费
  2076. var materialCostPartSelfTotal float64 = 0 //材料费
  2077. var westernMedicineCostTotal float64 = 0 //西药费
  2078. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2079. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2080. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2081. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2082. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2083. var checkCostTotal float64 = 0 //检查费
  2084. var checkCostSelfTotal float64 = 0 //检查费
  2085. var checkCostPartSelfTotal float64 = 0 //检查费
  2086. var laboratoryCostTotal float64 = 0 //化验费
  2087. var laboratoryCostSelfTotal float64 = 0 //化验费
  2088. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2089. var treatCostTotal float64 = 0 //治疗费用
  2090. var treatCostSelfTotal float64 = 0 //治疗费用
  2091. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2092. decimal.DivisionPrecision = 2
  2093. var bed_fulamt_ownpay_amt float64 = 0
  2094. var operation_fulamt_ownpay_amt float64 = 0
  2095. var other_fulamt_ownpay_amt float64 = 0
  2096. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2097. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2098. var check_fulamt_ownpay_amt float64 = 0
  2099. var material_fulamt_ownpay_amt float64 = 0
  2100. var laboratory_fulamt_ownpay_amt float64 = 0
  2101. var treat_fulamt_ownpay_amt float64 = 0
  2102. var bed_claa_sunmfee float64 = 0
  2103. var bed_clab_amt float64 = 0
  2104. var bed_other_amt float64 = 0
  2105. var operation_claa_sunmfee float64 = 0
  2106. var operation_clab_amt float64 = 0
  2107. var operation_other_amt float64 = 0
  2108. var other_claa_sunmfee float64 = 0
  2109. var other_clab_amt float64 = 0
  2110. var other_other_amt float64 = 0
  2111. var westernMedicine_claa_sunmfee float64 = 0
  2112. var westernMedicine_clab_amt float64 = 0
  2113. var westernMedicine_other_amt float64 = 0
  2114. var chineseTraditional_claa_sunmfee float64 = 0
  2115. var chineseTraditional_clab_amt float64 = 0
  2116. var chineseTraditional_other_amt float64 = 0
  2117. var check_claa_sunmfee float64 = 0
  2118. var check_clab_amt float64 = 0
  2119. var check_other_amt float64 = 0
  2120. var material_claa_sunmfee float64 = 0
  2121. var material_clab_amt float64 = 0
  2122. var material_other_amt float64 = 0
  2123. var laboratory_claa_sunmfee float64 = 0
  2124. var laboratory_clab_amt float64 = 0
  2125. var laboratory_other_amt float64 = 0
  2126. var treat_claa_sunmfee float64 = 0
  2127. var treat_clab_amt float64 = 0
  2128. var treat_other_amt float64 = 0
  2129. for _, item := range order.HisOrderInfo {
  2130. if item.MedChrgitmType == "01" { //床位费
  2131. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2132. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2133. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2134. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2135. if item.ChrgitmLv == "1" {
  2136. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2137. }
  2138. if item.ChrgitmLv == "2" {
  2139. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. }
  2141. if item.ChrgitmLv == "3" {
  2142. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2143. }
  2144. }
  2145. if item.MedChrgitmType == "03" { //检查费
  2146. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2147. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2148. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2149. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2150. if item.ChrgitmLv == "1" {
  2151. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2152. }
  2153. if item.ChrgitmLv == "2" {
  2154. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2155. }
  2156. if item.ChrgitmLv == "3" {
  2157. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2158. }
  2159. }
  2160. if item.MedChrgitmType == "04" { //化验费
  2161. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2162. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2163. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2164. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2165. if item.ChrgitmLv == "1" {
  2166. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2167. }
  2168. if item.ChrgitmLv == "2" {
  2169. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2170. }
  2171. if item.ChrgitmLv == "3" {
  2172. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2173. }
  2174. }
  2175. if item.MedChrgitmType == "05" { //治疗费
  2176. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2177. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2178. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2179. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2180. if item.ChrgitmLv == "1" {
  2181. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2182. }
  2183. if item.ChrgitmLv == "2" {
  2184. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2185. }
  2186. if item.ChrgitmLv == "3" {
  2187. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2188. }
  2189. }
  2190. if item.MedChrgitmType == "06" { //手术费
  2191. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2192. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2193. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2194. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2195. if item.ChrgitmLv == "1" {
  2196. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2197. }
  2198. if item.ChrgitmLv == "2" {
  2199. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2200. }
  2201. if item.ChrgitmLv == "3" {
  2202. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2203. }
  2204. }
  2205. if item.MedChrgitmType == "08" { //材料费
  2206. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2207. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2208. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2209. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2210. if item.ChrgitmLv == "1" {
  2211. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2212. }
  2213. if item.ChrgitmLv == "2" {
  2214. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2215. }
  2216. if item.ChrgitmLv == "3" {
  2217. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2218. }
  2219. }
  2220. if item.MedChrgitmType == "09" { //西药费
  2221. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2222. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2223. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2224. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2225. if item.ChrgitmLv == "1" {
  2226. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2227. }
  2228. if item.ChrgitmLv == "2" {
  2229. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2230. }
  2231. if item.ChrgitmLv == "3" {
  2232. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2233. }
  2234. }
  2235. if item.MedChrgitmType == "11" { //中成费
  2236. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2237. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2238. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2239. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2240. if item.ChrgitmLv == "1" {
  2241. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2242. }
  2243. if item.ChrgitmLv == "2" {
  2244. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2245. }
  2246. if item.ChrgitmLv == "3" {
  2247. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2248. }
  2249. }
  2250. if item.MedChrgitmType == "14" { //其他费
  2251. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2252. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2253. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2254. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2255. if item.ChrgitmLv == "1" {
  2256. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2257. }
  2258. if item.ChrgitmLv == "2" {
  2259. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2260. }
  2261. if item.ChrgitmLv == "3" {
  2262. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2263. }
  2264. }
  2265. }
  2266. var iteminfoStructs []service.IteminfoStruct
  2267. if bedCostTotal != 0 {
  2268. iteminfo.MedChrgitm = "01"
  2269. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2270. iteminfo.Amt = bedCostTotal
  2271. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2272. iteminfo.ClabAmt = bed_clab_amt
  2273. iteminfo.OthAmt = bed_other_amt
  2274. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2275. }
  2276. if checkCostTotal != 0 {
  2277. iteminfo.MedChrgitm = "03"
  2278. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2279. iteminfo.Amt = checkCostTotal
  2280. iteminfo.ClaaSumfee = check_claa_sunmfee
  2281. iteminfo.ClabAmt = check_clab_amt
  2282. iteminfo.OthAmt = check_other_amt
  2283. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2284. }
  2285. if laboratoryCostTotal != 0 {
  2286. iteminfo.MedChrgitm = "04"
  2287. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2288. iteminfo.Amt = laboratoryCostTotal
  2289. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2290. iteminfo.ClabAmt = laboratory_clab_amt
  2291. iteminfo.OthAmt = laboratory_other_amt
  2292. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2293. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2294. }
  2295. if treatCostTotal != 0 {
  2296. iteminfo.MedChrgitm = "05"
  2297. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2298. iteminfo.Amt = treatCostTotal
  2299. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2300. iteminfo.ClabAmt = treat_clab_amt
  2301. iteminfo.OthAmt = treat_other_amt
  2302. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2303. //(struct4101.IteminfoStruct, iteminfo)
  2304. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2305. }
  2306. if operationCostTotal != 0 {
  2307. iteminfo.MedChrgitm = "06"
  2308. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2309. iteminfo.Amt = operationCostTotal
  2310. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2311. iteminfo.ClabAmt = operation_clab_amt
  2312. iteminfo.OthAmt = operation_other_amt
  2313. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2315. }
  2316. if materialCostTotal != 0 {
  2317. iteminfo.MedChrgitm = "08"
  2318. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2319. iteminfo.Amt = materialCostTotal
  2320. iteminfo.ClaaSumfee = material_claa_sunmfee
  2321. iteminfo.ClabAmt = material_clab_amt
  2322. iteminfo.OthAmt = material_other_amt
  2323. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2324. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2325. }
  2326. if westernMedicineCostTotal != 0 {
  2327. iteminfo.MedChrgitm = "09"
  2328. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2329. iteminfo.Amt = westernMedicineCostTotal
  2330. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2331. iteminfo.ClabAmt = westernMedicine_clab_amt
  2332. iteminfo.OthAmt = westernMedicine_other_amt
  2333. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2334. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2335. }
  2336. if chineseTraditionalMedicineCostTotal != 0 {
  2337. iteminfo.MedChrgitm = "11"
  2338. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2339. iteminfo.Amt = westernMedicineCostTotal
  2340. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2341. iteminfo.ClabAmt = westernMedicine_clab_amt
  2342. iteminfo.OthAmt = westernMedicine_other_amt
  2343. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2344. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2345. }
  2346. if otherCostTotal != 0 {
  2347. iteminfo.MedChrgitm = "14"
  2348. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2349. iteminfo.Amt = otherCostTotal
  2350. iteminfo.ClaaSumfee = other_claa_sunmfee
  2351. iteminfo.ClabAmt = other_clab_amt
  2352. iteminfo.OthAmt = other_other_amt
  2353. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2354. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2355. }
  2356. struct4101.IteminfoStruct = iteminfoStructs
  2357. struct4101.Ntly = "中国"
  2358. struct4101.AdmCaty = "A03.06"
  2359. var res ResultSeventeen
  2360. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2361. var resOther ResultSeventeenOther
  2362. var pp models.PublicParams
  2363. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2364. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2365. pp.FixmedinsName = miConfig.OrgName
  2366. pp.FixmedinsCode = miConfig.Code
  2367. pp.RequestUrl = miConfig.Url
  2368. pp.Cainfo = miConfig.Cainfo
  2369. pp.SecretKey = miConfig.SecretKey
  2370. pp.AccessKey = miConfig.AccessKey
  2371. pp.OpterName = curRoles.UserName
  2372. client := &http.Client{}
  2373. var req *http.Request
  2374. data := make(map[string]interface{})
  2375. data["struct4101"] = struct4101
  2376. data["pp"] = pp
  2377. bytesData, _ := json.Marshal(data)
  2378. if miConfig.MdtrtareaAdmvs == "320921" {
  2379. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2380. } else {
  2381. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2382. }
  2383. resp, _ := client.Do(req)
  2384. defer resp.Body.Close()
  2385. body, ioErr := ioutil.ReadAll(resp.Body)
  2386. if ioErr != nil {
  2387. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2389. return
  2390. }
  2391. var respJSON map[string]interface{}
  2392. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2393. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2394. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2395. return
  2396. }
  2397. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2398. userJSONBytes, _ := json.Marshal(respJSON)
  2399. fmt.Println("log")
  2400. fmt.Println(string(userJSONBytes))
  2401. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2402. utils.ErrorLog("解析失败:%v", err)
  2403. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2404. return
  2405. }
  2406. res.InfRefmsgid = resOther.InfRefmsgid
  2407. res.Output = resOther.Output
  2408. res.ErrMsg = resOther.ErrMsg
  2409. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2410. res.Infcode = infocode
  2411. } else {
  2412. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2413. var dat map[string]interface{}
  2414. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2415. fmt.Println(dat)
  2416. } else {
  2417. fmt.Println(err)
  2418. }
  2419. userJSONBytes, _ := json.Marshal(dat)
  2420. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2421. utils.ErrorLog("解析失败:%v", err)
  2422. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2423. return
  2424. }
  2425. }
  2426. if res.Infcode != 0 {
  2427. c.ServeSuccessJSON(map[string]interface{}{
  2428. "failed_code": -10,
  2429. "msg": res.ErrMsg,
  2430. })
  2431. return
  2432. } else {
  2433. order.FaPiaoNumber = zero
  2434. order.FaPiaoCode = last_order.FaPiaoCode
  2435. service.UpdateOrder(order)
  2436. hisFundSettleListResult := &models.HisFundSettleListResult{
  2437. Number: res.Output.SetlListId,
  2438. Status: 1,
  2439. Ctime: time.Now().Unix(),
  2440. Mtime: time.Now().Unix(),
  2441. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2442. IsUpload: 1,
  2443. OrderId: order_id,
  2444. }
  2445. service.CreateUploadRecord(hisFundSettleListResult)
  2446. c.ServeSuccessJSON(map[string]interface{}{
  2447. "msg": "上传成功",
  2448. "result": hisFundSettleListResult,
  2449. })
  2450. return
  2451. }
  2452. }
  2453. func (c *HisApiController) GetSettleListHospital() {
  2454. order_id, _ := c.GetInt64("order_id")
  2455. admin_user_id, _ := c.GetInt64("admin_user_id")
  2456. order, _ := service.GetHisOrderByIDTwo(order_id)
  2457. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2458. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2459. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2460. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2461. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2462. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2463. if order.ID == 0 {
  2464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2465. return
  2466. }
  2467. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2468. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2469. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2470. fmt.Println(count)
  2471. var zero string
  2472. number := count + 1
  2473. if number >= 1000 {
  2474. zero = "0000" + strconv.FormatInt(number, 10)
  2475. } else if number >= 10000 {
  2476. zero = "000" + strconv.FormatInt(number, 10)
  2477. } else if number >= 100000 {
  2478. zero = "00" + strconv.FormatInt(number, 10)
  2479. } else if number >= 1000000 {
  2480. zero = "0" + strconv.FormatInt(number, 10)
  2481. } else {
  2482. zero = strconv.FormatInt(number, 10)
  2483. }
  2484. fmt.Println(zero)
  2485. struct4101 := service.Struct4101{
  2486. PsnNo: order.PsnNo,
  2487. MdtrtId: order.MdtrtId,
  2488. SetlId: order.SetlId,
  2489. PsnName: order.PsnName,
  2490. Gend: order.Gend,
  2491. Brdy: his.Brdy,
  2492. Age: int64(order.Age),
  2493. Naty: order.Naty,
  2494. PatnCertType: "01",
  2495. Certno: order.Certno,
  2496. Prfs: "90",
  2497. ConerName: roles[0].UserName,
  2498. PatnRlts: "99",
  2499. ConerAddr: miConfig.OrgName,
  2500. ConerTel: admin.Mobile,
  2501. HiType: order.Insutype,
  2502. Insuplc: miConfig.InsuplcAdmdvs,
  2503. MaindiagFlag: "1",
  2504. BillCode: last_order.FaPiaoCode,
  2505. BillNo: zero,
  2506. BizSn: order.Number,
  2507. PsnSelfPay: order.PsnPartAmt,
  2508. PsnOwnPay: order.PsnPartAmt,
  2509. AcctPay: order.AcctPay,
  2510. PsnCashpay: order.PsnCashPay,
  2511. HiPaymtd: "1",
  2512. Hsorg: miConfig.InsuplcAdmdvs,
  2513. HsorgOpter: miConfig.InsuplcAdmdvs,
  2514. MedinsFillPsn: curRoles.UserName,
  2515. MedinsFillDept: depart.Name,
  2516. IptMedType: "2",
  2517. AdmTime: his.InHosptialTime,
  2518. AdmEndTime: his.OutHosptialTime,
  2519. }
  2520. struct4101.SetlBegnDate = order.SetlTime
  2521. struct4101.SetlEndDate = order.SetlTime
  2522. var rf []CustomFundPay
  2523. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2524. var tempFunPays []service.CustomStruct
  2525. for _, item := range rf {
  2526. var tempFunPay service.CustomStruct
  2527. tempFunPay.FundPayamt = item.FundPayamt
  2528. tempFunPay.FundPayType = item.FundPayType
  2529. tempFunPays = append(tempFunPays, tempFunPay)
  2530. }
  2531. struct4101.CustomStruct = tempFunPays
  2532. var tempDiaginfos []service.DiaginfoStructTwo
  2533. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2534. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2535. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2536. var config []*models.HisXtDiagnoseConfig
  2537. for _, item := range diagnosis_ids {
  2538. id, _ := strconv.ParseInt(item, 10, 64)
  2539. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2540. config = append(config, &diagnosisConfig)
  2541. }
  2542. for index, item := range config {
  2543. if index == 0 {
  2544. var tempDiaginfo service.DiaginfoStructTwo
  2545. tempDiaginfo.DiagCode = item.CountryCode
  2546. tempDiaginfo.DiagName = item.CountryContentName
  2547. tempDiaginfo.DiagType = "1"
  2548. tempDiaginfo.MaindiagFlag = "1"
  2549. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2550. } else {
  2551. var tempDiaginfo service.DiaginfoStructTwo
  2552. tempDiaginfo.DiagCode = item.CountryCode
  2553. tempDiaginfo.DiagName = item.CountryContentName
  2554. tempDiaginfo.DiagType = "2"
  2555. tempDiaginfo.MaindiagFlag = "0"
  2556. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2557. }
  2558. }
  2559. struct4101.Diseinfo = tempDiaginfos
  2560. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2561. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2562. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2563. tempOpspdiseinfo2.OprnOprtCode = ""
  2564. tempOpspdiseinfo2.OprnOprtName = ""
  2565. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2566. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2567. var iteminfo service.IteminfoStruct
  2568. var bedCostTotal float64 = 0 //床位总费
  2569. var bedCostSelfTotal float64 = 0 //床位自费
  2570. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2571. var operationCostTotal float64 = 0 //手术费
  2572. var operationCostSelfTotal float64 = 0 //手术费
  2573. var operationCostPartSelfTotal float64 = 0 //手术费
  2574. var otherCostTotal float64 = 0 //其他费用
  2575. var otherCostSelfTotal float64 = 0 //其他费用
  2576. var otherCostPartSelfTotal float64 = 0 //其他费用
  2577. var materialCostTotal float64 = 0 //材料费
  2578. var materialCostSelfTotal float64 = 0 //材料费
  2579. var materialCostPartSelfTotal float64 = 0 //材料费
  2580. var westernMedicineCostTotal float64 = 0 //西药费
  2581. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2582. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2583. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2584. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2585. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2586. var checkCostTotal float64 = 0 //检查费
  2587. var checkCostSelfTotal float64 = 0 //检查费
  2588. var checkCostPartSelfTotal float64 = 0 //检查费
  2589. var laboratoryCostTotal float64 = 0 //化验费
  2590. var laboratoryCostSelfTotal float64 = 0 //化验费
  2591. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2592. var treatCostTotal float64 = 0 //治疗费用
  2593. var treatCostSelfTotal float64 = 0 //治疗费用
  2594. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2595. decimal.DivisionPrecision = 2
  2596. var bed_fulamt_ownpay_amt float64 = 0
  2597. var operation_fulamt_ownpay_amt float64 = 0
  2598. var other_fulamt_ownpay_amt float64 = 0
  2599. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2600. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2601. var check_fulamt_ownpay_amt float64 = 0
  2602. var material_fulamt_ownpay_amt float64 = 0
  2603. var laboratory_fulamt_ownpay_amt float64 = 0
  2604. var treat_fulamt_ownpay_amt float64 = 0
  2605. var bed_claa_sunmfee float64 = 0
  2606. var bed_clab_amt float64 = 0
  2607. var bed_other_amt float64 = 0
  2608. var operation_claa_sunmfee float64 = 0
  2609. var operation_clab_amt float64 = 0
  2610. var operation_other_amt float64 = 0
  2611. var other_claa_sunmfee float64 = 0
  2612. var other_clab_amt float64 = 0
  2613. var other_other_amt float64 = 0
  2614. var westernMedicine_claa_sunmfee float64 = 0
  2615. var westernMedicine_clab_amt float64 = 0
  2616. var westernMedicine_other_amt float64 = 0
  2617. var chineseTraditional_claa_sunmfee float64 = 0
  2618. var chineseTraditional_clab_amt float64 = 0
  2619. var chineseTraditional_other_amt float64 = 0
  2620. var check_claa_sunmfee float64 = 0
  2621. var check_clab_amt float64 = 0
  2622. var check_other_amt float64 = 0
  2623. var material_claa_sunmfee float64 = 0
  2624. var material_clab_amt float64 = 0
  2625. var material_other_amt float64 = 0
  2626. var laboratory_claa_sunmfee float64 = 0
  2627. var laboratory_clab_amt float64 = 0
  2628. var laboratory_other_amt float64 = 0
  2629. var treat_claa_sunmfee float64 = 0
  2630. var treat_clab_amt float64 = 0
  2631. var treat_other_amt float64 = 0
  2632. for _, item := range order.HisOrderInfo {
  2633. if item.MedChrgitmType == "01" { //床位费
  2634. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2635. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2636. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2637. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2638. if item.ChrgitmLv == "1" {
  2639. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2640. }
  2641. if item.ChrgitmLv == "2" {
  2642. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. }
  2644. if item.ChrgitmLv == "3" {
  2645. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2646. }
  2647. }
  2648. if item.MedChrgitmType == "03" { //检查费
  2649. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2650. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2651. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2652. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2653. if item.ChrgitmLv == "1" {
  2654. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2655. }
  2656. if item.ChrgitmLv == "2" {
  2657. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2658. }
  2659. if item.ChrgitmLv == "3" {
  2660. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2661. }
  2662. }
  2663. if item.MedChrgitmType == "04" { //化验费
  2664. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2665. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2666. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2667. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2668. if item.ChrgitmLv == "1" {
  2669. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2670. }
  2671. if item.ChrgitmLv == "2" {
  2672. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2673. }
  2674. if item.ChrgitmLv == "3" {
  2675. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2676. }
  2677. }
  2678. if item.MedChrgitmType == "05" { //治疗费
  2679. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2680. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2681. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2682. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2683. if item.ChrgitmLv == "1" {
  2684. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2685. }
  2686. if item.ChrgitmLv == "2" {
  2687. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2688. }
  2689. if item.ChrgitmLv == "3" {
  2690. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2691. }
  2692. }
  2693. if item.MedChrgitmType == "06" { //手术费
  2694. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2695. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2696. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2697. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2698. if item.ChrgitmLv == "1" {
  2699. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2700. }
  2701. if item.ChrgitmLv == "2" {
  2702. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2703. }
  2704. if item.ChrgitmLv == "3" {
  2705. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2706. }
  2707. }
  2708. if item.MedChrgitmType == "08" { //材料费
  2709. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2710. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2711. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2712. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2713. if item.ChrgitmLv == "1" {
  2714. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2715. }
  2716. if item.ChrgitmLv == "2" {
  2717. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2718. }
  2719. if item.ChrgitmLv == "3" {
  2720. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2721. }
  2722. }
  2723. if item.MedChrgitmType == "09" { //西药费
  2724. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2725. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2726. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2727. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2728. if item.ChrgitmLv == "1" {
  2729. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2730. }
  2731. if item.ChrgitmLv == "2" {
  2732. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2733. }
  2734. if item.ChrgitmLv == "3" {
  2735. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2736. }
  2737. }
  2738. if item.MedChrgitmType == "11" { //中成费
  2739. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2740. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2741. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2742. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2743. if item.ChrgitmLv == "1" {
  2744. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2745. }
  2746. if item.ChrgitmLv == "2" {
  2747. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2748. }
  2749. if item.ChrgitmLv == "3" {
  2750. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2751. }
  2752. }
  2753. if item.MedChrgitmType == "14" { //其他费
  2754. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2755. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2756. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2757. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2758. if item.ChrgitmLv == "1" {
  2759. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2760. }
  2761. if item.ChrgitmLv == "2" {
  2762. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2763. }
  2764. if item.ChrgitmLv == "3" {
  2765. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2766. }
  2767. }
  2768. }
  2769. var iteminfoStructs []service.IteminfoStruct
  2770. if bedCostTotal != 0 {
  2771. iteminfo.MedChrgitm = "01"
  2772. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2773. iteminfo.Amt = bedCostTotal
  2774. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2775. iteminfo.ClabAmt = bed_clab_amt
  2776. iteminfo.OthAmt = bed_other_amt
  2777. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2778. }
  2779. if checkCostTotal != 0 {
  2780. iteminfo.MedChrgitm = "03"
  2781. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2782. iteminfo.Amt = checkCostTotal
  2783. iteminfo.ClaaSumfee = check_claa_sunmfee
  2784. iteminfo.ClabAmt = check_clab_amt
  2785. iteminfo.OthAmt = check_other_amt
  2786. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2787. }
  2788. if laboratoryCostTotal != 0 {
  2789. iteminfo.MedChrgitm = "04"
  2790. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2791. iteminfo.Amt = laboratoryCostTotal
  2792. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2793. iteminfo.ClabAmt = laboratory_clab_amt
  2794. iteminfo.OthAmt = laboratory_other_amt
  2795. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2796. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2797. }
  2798. if treatCostTotal != 0 {
  2799. iteminfo.MedChrgitm = "05"
  2800. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2801. iteminfo.Amt = treatCostTotal
  2802. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2803. iteminfo.ClabAmt = treat_clab_amt
  2804. iteminfo.OthAmt = treat_other_amt
  2805. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2806. //(struct4101.IteminfoStruct, iteminfo)
  2807. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2808. }
  2809. if operationCostTotal != 0 {
  2810. iteminfo.MedChrgitm = "06"
  2811. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2812. iteminfo.Amt = operationCostTotal
  2813. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2814. iteminfo.ClabAmt = operation_clab_amt
  2815. iteminfo.OthAmt = operation_other_amt
  2816. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2817. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2818. }
  2819. if materialCostTotal != 0 {
  2820. iteminfo.MedChrgitm = "08"
  2821. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2822. iteminfo.Amt = materialCostTotal
  2823. iteminfo.ClaaSumfee = material_claa_sunmfee
  2824. iteminfo.ClabAmt = material_clab_amt
  2825. iteminfo.OthAmt = material_other_amt
  2826. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2827. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2828. }
  2829. if westernMedicineCostTotal != 0 {
  2830. iteminfo.MedChrgitm = "09"
  2831. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2832. iteminfo.Amt = westernMedicineCostTotal
  2833. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2834. iteminfo.ClabAmt = westernMedicine_clab_amt
  2835. iteminfo.OthAmt = westernMedicine_other_amt
  2836. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2837. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2838. }
  2839. if chineseTraditionalMedicineCostTotal != 0 {
  2840. iteminfo.MedChrgitm = "11"
  2841. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2842. iteminfo.Amt = westernMedicineCostTotal
  2843. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2844. iteminfo.ClabAmt = westernMedicine_clab_amt
  2845. iteminfo.OthAmt = westernMedicine_other_amt
  2846. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2847. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2848. }
  2849. if otherCostTotal != 0 {
  2850. iteminfo.MedChrgitm = "14"
  2851. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2852. iteminfo.Amt = otherCostTotal
  2853. iteminfo.ClaaSumfee = other_claa_sunmfee
  2854. iteminfo.ClabAmt = other_clab_amt
  2855. iteminfo.OthAmt = other_other_amt
  2856. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2857. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2858. }
  2859. struct4101.IteminfoStruct = iteminfoStructs
  2860. struct4101.Ntly = "中国"
  2861. struct4101.AdmCaty = "A03.06"
  2862. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2863. fmt.Println(result)
  2864. var dat map[string]interface{}
  2865. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2866. fmt.Println(dat)
  2867. } else {
  2868. fmt.Println(err)
  2869. }
  2870. userJSONBytes, _ := json.Marshal(dat)
  2871. var res ResultSeventeen
  2872. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2873. utils.ErrorLog("解析失败:%v", err)
  2874. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2875. return
  2876. }
  2877. if res.Infcode != 0 {
  2878. c.ServeSuccessJSON(map[string]interface{}{
  2879. "failed_code": -10,
  2880. "msg": res.ErrMsg,
  2881. })
  2882. return
  2883. } else {
  2884. order.FaPiaoNumber = zero
  2885. order.FaPiaoCode = last_order.FaPiaoCode
  2886. service.UpdateOrder(order)
  2887. hisFundSettleListResult := &models.HisFundSettleListResult{
  2888. Number: res.Output.SetlListId,
  2889. Status: 1,
  2890. Ctime: time.Now().Unix(),
  2891. Mtime: time.Now().Unix(),
  2892. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2893. IsUpload: 1,
  2894. OrderId: order_id,
  2895. }
  2896. service.CreateUploadRecord(hisFundSettleListResult)
  2897. c.ServeSuccessJSON(map[string]interface{}{
  2898. "msg": "上传成功",
  2899. "result": hisFundSettleListResult,
  2900. })
  2901. return
  2902. }
  2903. }
  2904. func (c *HisApiController) GetBatchSettleList() {
  2905. orders, _ := service.GetAllHisOrder(10106)
  2906. for _, item := range orders {
  2907. order_id := item.ID
  2908. order, _ := service.GetHisOrderByIDTwo(order_id)
  2909. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2910. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2911. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2912. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2913. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2914. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2915. if order.ID == 0 {
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2917. return
  2918. }
  2919. if his.BalanceAccountsType == 2 {
  2920. continue
  2921. }
  2922. struct4101 := service.Struct4101{
  2923. PsnNo: order.PsnNo,
  2924. MdtrtId: order.MdtrtId,
  2925. SetlId: order.SetlId,
  2926. PsnName: order.PsnName,
  2927. Gend: order.Gend,
  2928. Brdy: his.Brdy,
  2929. Age: his.Age,
  2930. Naty: order.Naty,
  2931. PatnCertType: "01",
  2932. Certno: order.Certno,
  2933. Prfs: "90",
  2934. ConerName: roles[0].UserName,
  2935. PatnRlts: "99",
  2936. ConerAddr: miConfig.OrgName,
  2937. ConerTel: admin.Mobile,
  2938. HiType: order.Insutype,
  2939. Insuplc: his.InsuplcAdmdvs,
  2940. MaindiagFlag: "1",
  2941. BillCode: order.FaPiaoCode,
  2942. BillNo: order.FaPiaoNumber,
  2943. BizSn: order.Number,
  2944. PsnSelfPay: order.PsnPartAmt,
  2945. PsnOwnPay: order.PsnPartAmt,
  2946. AcctPay: order.AcctPay,
  2947. PsnCashpay: order.PsnCashPay,
  2948. HiPaymtd: "1",
  2949. Hsorg: his.InsuplcAdmdvs,
  2950. HsorgOpter: his.InsuplcAdmdvs,
  2951. MedinsFillPsn: curRoles.UserName,
  2952. MedinsFillDept: depart.Name,
  2953. IptMedType: "2",
  2954. }
  2955. struct4101.SetlBegnDate = order.SetlTime
  2956. struct4101.SetlEndDate = order.SetlTime
  2957. //if order.SettleType == 1 {
  2958. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2959. // dateStr := t.Format("2006-01-02")
  2960. // struct4101.SetlBegnDate = dateStr
  2961. // struct4101.SetlEndDate = dateStr
  2962. //} else {
  2963. // t := time.Unix(int64(order.SettleStartTime), 0)
  2964. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2965. // dateStartStr := t.Format("2006-01-02")
  2966. // dateEndStr := t2.Format("2006-01-02")
  2967. // struct4101.SetlBegnDate = dateStartStr
  2968. // struct4101.SetlEndDate = dateEndStr
  2969. //}
  2970. var rf []CustomFundPay
  2971. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2972. var tempFunPays []service.CustomStruct
  2973. var tempFunPay610100 service.CustomStruct
  2974. for _, item := range rf {
  2975. if item.FundPayType == "610100" {
  2976. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2977. tempFunPay610100.FundPayType = item.FundPayType
  2978. } else {
  2979. var tempFunPay service.CustomStruct
  2980. tempFunPay.FundPayamt = item.FundPayamt
  2981. tempFunPay.FundPayType = item.FundPayType
  2982. tempFunPays = append(tempFunPays, tempFunPay)
  2983. }
  2984. }
  2985. tempFunPays = append(tempFunPays, tempFunPay610100)
  2986. struct4101.CustomStruct = tempFunPays
  2987. var tempDiaginfos []service.DiaginfoStructTwo
  2988. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2989. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2990. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2991. var config []*models.HisXtDiagnoseConfig
  2992. for _, item := range diagnosis_ids {
  2993. id, _ := strconv.ParseInt(item, 10, 64)
  2994. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2995. config = append(config, &diagnosisConfig)
  2996. }
  2997. for index, item := range config {
  2998. if index == 0 {
  2999. var tempDiaginfo service.DiaginfoStructTwo
  3000. tempDiaginfo.DiagCode = item.CountryCode
  3001. tempDiaginfo.DiagName = item.CountryContentName
  3002. tempDiaginfo.DiagType = "1"
  3003. tempDiaginfo.MaindiagFlag = "1"
  3004. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3005. } else {
  3006. var tempDiaginfo service.DiaginfoStructTwo
  3007. tempDiaginfo.DiagCode = item.CountryCode
  3008. tempDiaginfo.DiagName = item.CountryContentName
  3009. tempDiaginfo.DiagType = "2"
  3010. tempDiaginfo.MaindiagFlag = "0"
  3011. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  3012. }
  3013. }
  3014. struct4101.Diseinfo = tempDiaginfos
  3015. sickConfigTwo, _ := service.FindSickById(his.SickType)
  3016. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  3017. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  3018. tempOpspdiseinfo2.OprnOprtCode = ""
  3019. tempOpspdiseinfo2.OprnOprtName = ""
  3020. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  3021. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  3022. var iteminfo service.IteminfoStruct
  3023. var bedCostTotal float64 = 0 //床位总费
  3024. var bedCostSelfTotal float64 = 0 //床位自费
  3025. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  3026. var examineCostTotal float64 = 0 //诊查总费
  3027. var examineCostSelfTotal float64 = 0 //诊查自费
  3028. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  3029. var nursingCostTotal float64 = 0 //护理总费
  3030. var nursingCostSelfTotal float64 = 0 //护理自费
  3031. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  3032. var chineseMedicineCostTotal float64 = 0 //中成药
  3033. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  3034. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  3035. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  3036. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  3037. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  3038. var registerCostTotal float64 = 0 //一般诊疗费
  3039. var registerCostSelfTotal float64 = 0 //一般诊疗费
  3040. var registerPartSelfTotal float64 = 0 //一般诊疗费
  3041. var operationCostTotal float64 = 0 //手术费
  3042. var operationCostSelfTotal float64 = 0 //手术费
  3043. var operationCostPartSelfTotal float64 = 0 //手术费
  3044. var otherCostTotal float64 = 0 //其他费用
  3045. var otherCostSelfTotal float64 = 0 //其他费用
  3046. var otherCostPartSelfTotal float64 = 0 //其他费用
  3047. var materialCostTotal float64 = 0 //材料费
  3048. var materialCostSelfTotal float64 = 0 //材料费
  3049. var materialCostPartSelfTotal float64 = 0 //材料费
  3050. var westernMedicineCostTotal float64 = 0 //西药费
  3051. var westernMedicineCostSelfTotal float64 = 0 //西药费
  3052. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  3053. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  3054. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  3055. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  3056. var checkCostTotal float64 = 0 //检查费
  3057. var checkCostSelfTotal float64 = 0 //检查费
  3058. var checkCostPartSelfTotal float64 = 0 //检查费
  3059. var laboratoryCostTotal float64 = 0 //化验费
  3060. var laboratoryCostSelfTotal float64 = 0 //化验费
  3061. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  3062. var treatCostTotal float64 = 0 //治疗费用
  3063. var treatCostSelfTotal float64 = 0 //治疗费用
  3064. var treatCostPartSelfTotal float64 = 0 //治疗费用
  3065. decimal.DivisionPrecision = 2
  3066. var bed_fulamt_ownpay_amt float64 = 0
  3067. var examine_fulamt_ownpay_amt float64 = 0
  3068. var nursing_fulamt_ownpay_amt float64 = 0
  3069. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  3070. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  3071. var register_fulamt_ownpay_amt float64 = 0
  3072. var operation_fulamt_ownpay_amt float64 = 0
  3073. var other_fulamt_ownpay_amt float64 = 0
  3074. var westernMedicine_fulamt_ownpay_amt float64 = 0
  3075. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  3076. var check_fulamt_ownpay_amt float64 = 0
  3077. var material_fulamt_ownpay_amt float64 = 0
  3078. var laboratory_fulamt_ownpay_amt float64 = 0
  3079. var treat_fulamt_ownpay_amt float64 = 0
  3080. var bed_claa_sunmfee float64 = 0
  3081. var bed_clab_amt float64 = 0
  3082. var bed_other_amt float64 = 0
  3083. var examine_claa_sunmfee float64 = 0
  3084. var examine_clab_amt float64 = 0
  3085. var examine_other_amt float64 = 0
  3086. var nursing_claa_sunmfee float64 = 0
  3087. var nursing_clab_amt float64 = 0
  3088. var nursing_other_amt float64 = 0
  3089. var chinese_medicine_claa_sunmfee float64 = 0
  3090. var chinese_medicine_clab_amt float64 = 0
  3091. var chinese_medicine_other_amt float64 = 0
  3092. var commonly_treatment_claa_sunmfee float64 = 0
  3093. var commonly_treatment_clab_amt float64 = 0
  3094. var commonly_treatment_other_amt float64 = 0
  3095. var operation_claa_sunmfee float64 = 0
  3096. var operation_clab_amt float64 = 0
  3097. var operation_other_amt float64 = 0
  3098. var other_claa_sunmfee float64 = 0
  3099. var other_clab_amt float64 = 0
  3100. var other_other_amt float64 = 0
  3101. var westernMedicine_claa_sunmfee float64 = 0
  3102. var westernMedicine_clab_amt float64 = 0
  3103. var westernMedicine_other_amt float64 = 0
  3104. var chineseTraditional_claa_sunmfee float64 = 0
  3105. var chineseTraditional_clab_amt float64 = 0
  3106. var chineseTraditional_other_amt float64 = 0
  3107. var check_claa_sunmfee float64 = 0
  3108. var check_clab_amt float64 = 0
  3109. var check_other_amt float64 = 0
  3110. var material_claa_sunmfee float64 = 0
  3111. var material_clab_amt float64 = 0
  3112. var material_other_amt float64 = 0
  3113. var laboratory_claa_sunmfee float64 = 0
  3114. var laboratory_clab_amt float64 = 0
  3115. var laboratory_other_amt float64 = 0
  3116. var treat_claa_sunmfee float64 = 0
  3117. var treat_clab_amt float64 = 0
  3118. var treat_other_amt float64 = 0
  3119. var register_claa_sunmfee float64 = 0
  3120. var register_clab_amt float64 = 0
  3121. var register_other_amt float64 = 0
  3122. for _, item := range order.HisOrderInfo {
  3123. if item.MedChrgitmType == "01" { //床位费
  3124. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3125. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3126. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3127. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3128. if item.ChrgitmLv == "1" {
  3129. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3130. }
  3131. if item.ChrgitmLv == "2" {
  3132. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. }
  3134. if item.ChrgitmLv == "3" {
  3135. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3136. }
  3137. }
  3138. if item.MedChrgitmType == "02" { //诊查
  3139. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3140. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3141. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3142. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3143. if item.ChrgitmLv == "1" {
  3144. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3145. }
  3146. if item.ChrgitmLv == "2" {
  3147. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. }
  3149. if item.ChrgitmLv == "3" {
  3150. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3151. }
  3152. }
  3153. if item.MedChrgitmType == "03" { //检查费
  3154. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3155. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3156. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3157. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3158. if item.ChrgitmLv == "1" {
  3159. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3160. }
  3161. if item.ChrgitmLv == "2" {
  3162. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. }
  3164. if item.ChrgitmLv == "3" {
  3165. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3166. }
  3167. }
  3168. if item.MedChrgitmType == "04" { //化验费
  3169. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3170. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3171. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3172. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3173. if item.ChrgitmLv == "1" {
  3174. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3175. }
  3176. if item.ChrgitmLv == "2" {
  3177. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. }
  3179. if item.ChrgitmLv == "3" {
  3180. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3181. }
  3182. }
  3183. if item.MedChrgitmType == "05" { //治疗费
  3184. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3185. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3186. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3187. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3188. if item.ChrgitmLv == "1" {
  3189. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3190. }
  3191. if item.ChrgitmLv == "2" {
  3192. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. }
  3194. if item.ChrgitmLv == "3" {
  3195. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3196. }
  3197. }
  3198. if item.MedChrgitmType == "06" { //手术费
  3199. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3200. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3201. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3202. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3203. if item.ChrgitmLv == "1" {
  3204. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3205. }
  3206. if item.ChrgitmLv == "2" {
  3207. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. }
  3209. if item.ChrgitmLv == "3" {
  3210. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3211. }
  3212. }
  3213. if item.MedChrgitmType == "07" { //手术费
  3214. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3215. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3216. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3217. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3218. if item.ChrgitmLv == "1" {
  3219. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3220. }
  3221. if item.ChrgitmLv == "2" {
  3222. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3223. }
  3224. if item.ChrgitmLv == "3" {
  3225. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3226. }
  3227. }
  3228. if item.MedChrgitmType == "08" { //材料费
  3229. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3230. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3231. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3232. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3233. if item.ChrgitmLv == "1" {
  3234. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3235. }
  3236. if item.ChrgitmLv == "2" {
  3237. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3238. }
  3239. if item.ChrgitmLv == "3" {
  3240. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3241. }
  3242. }
  3243. if item.MedChrgitmType == "09" { //西药费
  3244. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3245. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3246. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3247. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3248. if item.ChrgitmLv == "1" {
  3249. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3250. }
  3251. if item.ChrgitmLv == "2" {
  3252. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3253. }
  3254. if item.ChrgitmLv == "3" {
  3255. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3256. }
  3257. }
  3258. if item.MedChrgitmType == "10" { //中药饮片
  3259. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3260. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3261. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3262. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3263. if item.ChrgitmLv == "1" {
  3264. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3265. }
  3266. if item.ChrgitmLv == "2" {
  3267. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3268. }
  3269. if item.ChrgitmLv == "3" {
  3270. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3271. }
  3272. }
  3273. if item.MedChrgitmType == "11" { //中成费
  3274. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3275. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3276. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3277. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3278. if item.ChrgitmLv == "1" {
  3279. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3280. }
  3281. if item.ChrgitmLv == "2" {
  3282. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3283. }
  3284. if item.ChrgitmLv == "3" {
  3285. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3286. }
  3287. }
  3288. if item.MedChrgitmType == "12" { //中成费
  3289. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3290. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3291. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3292. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3293. if item.ChrgitmLv == "1" {
  3294. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3295. }
  3296. if item.ChrgitmLv == "2" {
  3297. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3298. }
  3299. if item.ChrgitmLv == "3" {
  3300. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3301. }
  3302. }
  3303. if item.MedChrgitmType == "13" { //中成费
  3304. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3305. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3306. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3307. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3308. if item.ChrgitmLv == "1" {
  3309. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3310. }
  3311. if item.ChrgitmLv == "2" {
  3312. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3313. }
  3314. if item.ChrgitmLv == "3" {
  3315. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3316. }
  3317. }
  3318. if item.MedChrgitmType == "14" { //其他费
  3319. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3320. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3321. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3322. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3323. if item.ChrgitmLv == "1" {
  3324. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3325. }
  3326. if item.ChrgitmLv == "2" {
  3327. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3328. }
  3329. if item.ChrgitmLv == "3" {
  3330. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3331. }
  3332. }
  3333. }
  3334. var iteminfoStructs []service.IteminfoStruct
  3335. if bedCostTotal != 0 {
  3336. iteminfo.MedChrgitm = "01"
  3337. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3338. iteminfo.Amt = bedCostTotal
  3339. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3340. iteminfo.ClabAmt = bed_clab_amt
  3341. iteminfo.OthAmt = bed_other_amt
  3342. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3343. }
  3344. if examineCostTotal != 0 {
  3345. iteminfo.MedChrgitm = "02"
  3346. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3347. iteminfo.Amt = examineCostTotal
  3348. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3349. iteminfo.ClabAmt = examine_clab_amt
  3350. iteminfo.OthAmt = examine_other_amt
  3351. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3352. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3353. }
  3354. if checkCostTotal != 0 {
  3355. iteminfo.MedChrgitm = "03"
  3356. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3357. iteminfo.Amt = checkCostTotal
  3358. iteminfo.ClaaSumfee = check_claa_sunmfee
  3359. iteminfo.ClabAmt = check_clab_amt
  3360. iteminfo.OthAmt = check_other_amt
  3361. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3362. }
  3363. if laboratoryCostTotal != 0 {
  3364. iteminfo.MedChrgitm = "04"
  3365. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3366. iteminfo.Amt = laboratoryCostTotal
  3367. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3368. iteminfo.ClabAmt = laboratory_clab_amt
  3369. iteminfo.OthAmt = laboratory_other_amt
  3370. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3371. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3372. }
  3373. if treatCostTotal != 0 {
  3374. iteminfo.MedChrgitm = "05"
  3375. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3376. iteminfo.Amt = treatCostTotal
  3377. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3378. iteminfo.ClabAmt = treat_clab_amt
  3379. iteminfo.OthAmt = treat_other_amt
  3380. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3381. //(struct4101.IteminfoStruct, iteminfo)
  3382. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3383. }
  3384. if operationCostTotal != 0 {
  3385. iteminfo.MedChrgitm = "06"
  3386. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3387. iteminfo.Amt = operationCostTotal
  3388. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3389. iteminfo.ClabAmt = operation_clab_amt
  3390. iteminfo.OthAmt = operation_other_amt
  3391. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3392. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3393. }
  3394. if nursingCostTotal != 0 {
  3395. iteminfo.MedChrgitm = "07"
  3396. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3397. iteminfo.Amt = nursingCostTotal
  3398. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3399. iteminfo.ClabAmt = nursing_clab_amt
  3400. iteminfo.OthAmt = nursing_other_amt
  3401. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3402. }
  3403. if materialCostTotal != 0 {
  3404. iteminfo.MedChrgitm = "08"
  3405. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3406. iteminfo.Amt = materialCostTotal
  3407. iteminfo.ClaaSumfee = material_claa_sunmfee
  3408. iteminfo.ClabAmt = material_clab_amt
  3409. iteminfo.OthAmt = material_other_amt
  3410. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3411. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3412. }
  3413. if westernMedicineCostTotal != 0 {
  3414. iteminfo.MedChrgitm = "09"
  3415. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3416. iteminfo.Amt = westernMedicineCostTotal
  3417. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3418. iteminfo.ClabAmt = westernMedicine_clab_amt
  3419. iteminfo.OthAmt = westernMedicine_other_amt
  3420. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3421. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3422. }
  3423. if chineseMedicineCostTotal != 0 {
  3424. iteminfo.MedChrgitm = "10"
  3425. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3426. iteminfo.Amt = chineseMedicineCostTotal
  3427. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3428. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3429. iteminfo.OthAmt = chinese_medicine_other_amt
  3430. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3431. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3432. }
  3433. if chineseTraditionalMedicineCostTotal != 0 {
  3434. iteminfo.MedChrgitm = "11"
  3435. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3436. iteminfo.Amt = westernMedicineCostTotal
  3437. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3438. iteminfo.ClabAmt = westernMedicine_clab_amt
  3439. iteminfo.OthAmt = westernMedicine_other_amt
  3440. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3441. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3442. }
  3443. if commonlyTreatmentCostTotal != 0 {
  3444. iteminfo.MedChrgitm = "12"
  3445. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3446. iteminfo.Amt = commonlyTreatmentCostTotal
  3447. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3448. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3449. iteminfo.OthAmt = commonly_treatment_other_amt
  3450. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3451. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3452. }
  3453. if registerCostTotal != 0 {
  3454. iteminfo.MedChrgitm = "13"
  3455. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3456. iteminfo.Amt = registerCostTotal
  3457. iteminfo.ClaaSumfee = register_claa_sunmfee
  3458. iteminfo.ClabAmt = register_clab_amt
  3459. iteminfo.OthAmt = register_other_amt
  3460. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3461. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3462. }
  3463. if otherCostTotal != 0 {
  3464. iteminfo.MedChrgitm = "14"
  3465. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3466. iteminfo.Amt = otherCostTotal
  3467. iteminfo.ClaaSumfee = other_claa_sunmfee
  3468. iteminfo.ClabAmt = other_clab_amt
  3469. iteminfo.OthAmt = other_other_amt
  3470. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3471. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3472. }
  3473. struct4101.IteminfoStruct = iteminfoStructs
  3474. struct4101.Ntly = "中国"
  3475. struct4101.AdmCaty = "A03.06"
  3476. var res ResultSeventeen
  3477. if miConfig.MdtrtareaAdmvs == "421300" {
  3478. data := make(map[string]interface{})
  3479. data["struct4101"] = struct4101
  3480. data["secret_key"] = miConfig.SecretKey
  3481. data["org_name"] = miConfig.OrgName
  3482. data["opera"] = curRoles.UserName
  3483. data["code"] = miConfig.Code
  3484. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3485. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3486. client := &http.Client{}
  3487. bytesData, _ := json.Marshal(data)
  3488. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/4101", bytes.NewReader(bytesData))
  3489. resp, _ := client.Do(req)
  3490. defer resp.Body.Close()
  3491. body, ioErr := ioutil.ReadAll(resp.Body)
  3492. if ioErr != nil {
  3493. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3495. return
  3496. }
  3497. var respJSON map[string]interface{}
  3498. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3499. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3501. return
  3502. }
  3503. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3504. userJSONBytes, _ := json.Marshal(respJSON)
  3505. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3506. utils.ErrorLog("解析失败:%v", err)
  3507. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3508. adminUser := c.GetAdminUserInfo()
  3509. errlog := &models.HisOrderError{
  3510. UserOrgId: adminUser.CurrentOrgId,
  3511. Ctime: time.Now().Unix(),
  3512. Mtime: time.Now().Unix(),
  3513. ErrMsg: res.ErrMsg + "解析失败",
  3514. Status: 1,
  3515. PatientId: order_id,
  3516. Stage: 10088,
  3517. }
  3518. service.CreateErrMsgLog(errlog)
  3519. continue
  3520. }
  3521. } else {
  3522. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3523. fmt.Println(result)
  3524. var dat map[string]interface{}
  3525. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3526. fmt.Println(dat)
  3527. } else {
  3528. fmt.Println(err)
  3529. }
  3530. userJSONBytes, _ := json.Marshal(dat)
  3531. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3532. utils.ErrorLog("解析失败:%v", err)
  3533. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3534. adminUser := c.GetAdminUserInfo()
  3535. errlog := &models.HisOrderError{
  3536. UserOrgId: adminUser.CurrentOrgId,
  3537. Ctime: time.Now().Unix(),
  3538. Mtime: time.Now().Unix(),
  3539. ErrMsg: res.ErrMsg + "解析失败",
  3540. Status: 1,
  3541. PatientId: order_id,
  3542. Stage: 10106,
  3543. }
  3544. service.CreateErrMsgLog(errlog)
  3545. continue
  3546. }
  3547. }
  3548. if res.Infcode != 0 {
  3549. adminUser := c.GetAdminUserInfo()
  3550. errlog := &models.HisOrderError{
  3551. UserOrgId: adminUser.CurrentOrgId,
  3552. Ctime: time.Now().Unix(),
  3553. Mtime: time.Now().Unix(),
  3554. ErrMsg: res.ErrMsg,
  3555. Status: 1,
  3556. PatientId: order_id,
  3557. Stage: 10106,
  3558. }
  3559. service.CreateErrMsgLog(errlog)
  3560. continue
  3561. } else {
  3562. hisFundSettleListResult := &models.HisFundSettleListResult{
  3563. Number: res.Output.SetlListId,
  3564. Status: 1,
  3565. Ctime: time.Now().Unix(),
  3566. Mtime: time.Now().Unix(),
  3567. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3568. IsUpload: 1,
  3569. OrderId: order_id,
  3570. }
  3571. service.CreateUploadRecord(hisFundSettleListResult)
  3572. continue
  3573. }
  3574. }
  3575. }
  3576. func (c *HisApiController) GetOrgInfo() {
  3577. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3578. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3579. }
  3580. func (c *HisApiController) GetHisPatientInfo() {
  3581. medical_insurance_card := c.GetString("medical_insurance_card")
  3582. id_card_type, _ := c.GetInt64("id_card_type")
  3583. id_card := c.GetString("id_card")
  3584. adminInfo := c.GetAdminUserInfo()
  3585. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3586. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3587. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3588. IdCardNo := ""
  3589. if id_card_type == 1 {
  3590. IdCardNo = medical_insurance_card
  3591. } else if id_card_type == 2 {
  3592. IdCardNo = id_card
  3593. }
  3594. if config.IsOpen == 1 {
  3595. 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
  3596. resp, requestErr := http.Get(api)
  3597. if requestErr != nil {
  3598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3599. return
  3600. }
  3601. defer resp.Body.Close()
  3602. body, ioErr := ioutil.ReadAll(resp.Body)
  3603. if ioErr != nil {
  3604. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3606. return
  3607. }
  3608. var respJSON map[string]interface{}
  3609. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3610. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3612. return
  3613. }
  3614. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3615. userJSONBytes, _ := json.Marshal(userJSON)
  3616. var res ResultTwo
  3617. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3618. utils.ErrorLog("解析失败:%v", err)
  3619. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3620. return
  3621. }
  3622. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3623. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3624. infoStr := string(Iinfos)
  3625. idetinfoStr := string(Idetinfos)
  3626. if res.Infcode == 0 {
  3627. his := models.VMHisPatient{
  3628. Status: 1,
  3629. Ctime: time.Now().Unix(),
  3630. Mtime: time.Now().Unix(),
  3631. PsnNo: res.Output.Baseinfo.PsnNo,
  3632. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3633. Certno: res.Output.Baseinfo.Certno,
  3634. PsnName: res.Output.Baseinfo.PsnName,
  3635. Gend: res.Output.Baseinfo.Gend,
  3636. Naty: res.Output.Baseinfo.Naty,
  3637. Brdy: res.Output.Baseinfo.Brdy,
  3638. Age: res.Output.Baseinfo.Age,
  3639. Iinfo: infoStr,
  3640. Idetinfo: idetinfoStr,
  3641. UserOrgId: adminInfo.CurrentOrgId,
  3642. IsReturn: 1,
  3643. IdCardType: id_card_type,
  3644. }
  3645. c.ServeSuccessJSON(map[string]interface{}{
  3646. "info": his,
  3647. })
  3648. } else {
  3649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3650. return
  3651. }
  3652. }
  3653. }
  3654. //func GetBasBaseInfo() (jsonStr string, err error) {
  3655. //
  3656. // handle := syscall.NewLazyDLL("SSCard.dll")
  3657. // add := handle.NewProc("ReadCardBas")
  3658. // str := make([]byte, 1024)
  3659. // str1 := make([]byte, 1024)
  3660. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3661. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3662. //
  3663. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3664. //
  3665. // fmt.Println("> Add(4,5)的结果为:", ret)
  3666. // handle.Release()
  3667. //
  3668. // return "", nil
  3669. //
  3670. //}
  3671. //func GetQRBaseInfo() (jsonStr string, err error) {
  3672. // handle := syscall.LoadDLL("SSCard.dll")
  3673. // ReadCardBas := handle.FindProc("GetQRBase")
  3674. //
  3675. // str := make([]byte, 256)
  3676. // str1 := make([]byte, 256)
  3677. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3678. //
  3679. // fmt.Println(string(str))
  3680. // fmt.Println(r)
  3681. // return string(str), nil
  3682. //}
  3683. //func CardInit() int {
  3684. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3685. // add := DllTestDef.MustFindProc("Init")
  3686. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3687. // if err != nil {
  3688. // fmt.Println("SSCard的运算结果为:", ret)
  3689. // }
  3690. // result := int(ret)
  3691. // return result
  3692. //}
  3693. //func CardInit() int {
  3694. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3695. // if err != nil {
  3696. // fmt.Println("SSCard的运算结果为:", ret)
  3697. // }
  3698. // fmt.Println(err)
  3699. // result := int(ret)
  3700. // return result
  3701. //}
  3702. func IntPtr(n int) uintptr {
  3703. return uintptr(n)
  3704. }
  3705. func StrPtr(s string) uintptr {
  3706. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3707. }
  3708. type Result2001 struct {
  3709. Cainfo interface{} `json:"cainfo"`
  3710. ErrMsg string `json:"err_msg"`
  3711. InfRefmsgid string `json:"inf_refmsgid"`
  3712. Infcode int64 `json:"infcode"`
  3713. Output struct {
  3714. Trtinfo struct {
  3715. PsnNo string `json:"psn_no"`
  3716. TrtChkType string `json:"trt_chk_type"`
  3717. FundPayType string `json:"fund_pay_type"`
  3718. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3719. Begndate string `json:"begndate"`
  3720. Enddate string `json:"enddate"`
  3721. TrtChkRslt string `json:"trt_chk_rslt"`
  3722. } `json:"trtinfo"`
  3723. } `json:"output"`
  3724. RefmsgTime string `json:"refmsg_time"`
  3725. RespondTime string `json:"respond_time"`
  3726. Signtype interface{} `json:"signtype"`
  3727. WarnMsg interface{} `json:"warn_msg"`
  3728. }
  3729. type Result2001Org10265 struct {
  3730. Cainfo interface{} `json:"cainfo"`
  3731. ErrMsg string `json:"err_msg"`
  3732. InfRefmsgid string `json:"inf_refmsgid"`
  3733. Infcode string `json:"infcode"`
  3734. Output struct {
  3735. Trtinfo struct {
  3736. PsnNo string `json:"psn_no"`
  3737. TrtChkType string `json:"trt_chk_type"`
  3738. FundPayType string `json:"fund_pay_type"`
  3739. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3740. Begndate string `json:"begndate"`
  3741. Enddate string `json:"enddate"`
  3742. TrtChkRslt string `json:"trt_chk_rslt"`
  3743. } `json:"trtinfo"`
  3744. } `json:"output"`
  3745. RefmsgTime string `json:"refmsg_time"`
  3746. RespondTime string `json:"respond_time"`
  3747. Signtype interface{} `json:"signtype"`
  3748. WarnMsg interface{} `json:"warn_msg"`
  3749. }
  3750. type ResultTwo struct {
  3751. ErrMsg string `json:"err_msg"`
  3752. InfRefmsgid string `json:"inf_refmsgid"`
  3753. Infcode int64 `json:"infcode"`
  3754. Output struct {
  3755. Baseinfo struct {
  3756. Age float64 `json:"age"`
  3757. Brdy string `json:"brdy"`
  3758. Certno string `json:"certno"`
  3759. Gend string `json:"gend"`
  3760. Naty string `json:"naty"`
  3761. PsnCertType string `json:"psn_cert_type"`
  3762. PsnName string `json:"psn_name"`
  3763. PsnNo string `json:"psn_no"`
  3764. } `json:"baseinfo"`
  3765. Idetinfo []interface{} `json:"idetinfo"`
  3766. Iinfo []struct {
  3767. Balc float64 `json:"balc"`
  3768. CvlservFlag string `json:"cvlserv_flag"`
  3769. EmpName string `json:"emp_name"`
  3770. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3771. Insutype string `json:"insutype"`
  3772. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3773. PausInsuDate string `json:"paus_insu_date"`
  3774. PsnInsuDate string `json:"psn_insu_date"`
  3775. PsnInsuStas string `json:"psn_insu_stas"`
  3776. PsnType string `json:"psn_type"`
  3777. } `json:"insuinfo"`
  3778. } `json:"output"`
  3779. RefmsgTime string `json:"refmsg_time"`
  3780. RespondTime string `json:"respond_time"`
  3781. Signtype interface{} `json:"signtype"`
  3782. WarnInfo interface{} `json:"warn_info"`
  3783. }
  3784. type ResultTwo10265 struct {
  3785. ErrMsg string `json:"err_msg"`
  3786. InfRefmsgid string `json:"inf_refmsgid"`
  3787. Infcode string `json:"infcode"`
  3788. Output struct {
  3789. Baseinfo struct {
  3790. Age float64 `json:"age"`
  3791. Brdy string `json:"brdy"`
  3792. Certno string `json:"certno"`
  3793. Gend string `json:"gend"`
  3794. Naty string `json:"naty"`
  3795. PsnCertType string `json:"psn_cert_type"`
  3796. PsnName string `json:"psn_name"`
  3797. PsnNo string `json:"psn_no"`
  3798. } `json:"baseinfo"`
  3799. Idetinfo []interface{} `json:"idetinfo"`
  3800. Iinfo []struct {
  3801. Balc float64 `json:"balc"`
  3802. CvlservFlag string `json:"cvlserv_flag"`
  3803. EmpName string `json:"emp_name"`
  3804. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3805. Insutype string `json:"insutype"`
  3806. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3807. PausInsuDate string `json:"paus_insu_date"`
  3808. PsnInsuDate string `json:"psn_insu_date"`
  3809. PsnInsuStas string `json:"psn_insu_stas"`
  3810. PsnType string `json:"psn_type"`
  3811. } `json:"insuinfo"`
  3812. } `json:"output"`
  3813. RefmsgTime string `json:"refmsg_time"`
  3814. RespondTime string `json:"respond_time"`
  3815. Signtype interface{} `json:"signtype"`
  3816. WarnInfo interface{} `json:"warn_info"`
  3817. }
  3818. type ResultThree struct {
  3819. Cainfo interface{} `json:"cainfo"`
  3820. ErrMsg string `json:"err_msg"`
  3821. InfRefmsgid string `json:"inf_refmsgid"`
  3822. Infcode int64 `json:"infcode"`
  3823. Output struct {
  3824. Data struct {
  3825. IptOtpNo string `json:"ipt_otp_no"`
  3826. MdtrtID string `json:"mdtrt_id"`
  3827. PsnNo string `json:"psn_no"`
  3828. } `json:"data"`
  3829. } `json:"output"`
  3830. RefmsgTime string `json:"refmsg_time"`
  3831. RespondTime string `json:"respond_time"`
  3832. Signtype interface{} `json:"signtype"`
  3833. WarnMsg interface{} `json:"warn_msg"`
  3834. }
  3835. type ResultThree10265 struct {
  3836. Cainfo interface{} `json:"cainfo"`
  3837. ErrMsg string `json:"err_msg"`
  3838. InfRefmsgid string `json:"inf_refmsgid"`
  3839. Infcode string `json:"infcode"`
  3840. Output struct {
  3841. Data struct {
  3842. IptOtpNo string `json:"ipt_otp_no"`
  3843. MdtrtID string `json:"mdtrt_id"`
  3844. PsnNo string `json:"psn_no"`
  3845. } `json:"data"`
  3846. } `json:"output"`
  3847. RefmsgTime string `json:"refmsg_time"`
  3848. RespondTime string `json:"respond_time"`
  3849. Signtype interface{} `json:"signtype"`
  3850. WarnMsg interface{} `json:"warn_msg"`
  3851. }
  3852. type ResultFour struct {
  3853. Cainfo string `json:"cainfo"`
  3854. ErrMsg string `json:"err_msg"`
  3855. InfRefmsgid string `json:"inf_refmsgid"`
  3856. Infcode int64 `json:"infcode"`
  3857. Output struct {
  3858. Result []struct {
  3859. BasMednFlag string `json:"bas_medn_flag"`
  3860. ChldMedcFlag string `json:"chld_medc_flag"`
  3861. ChrgitmLv string `json:"chrgitm_lv"`
  3862. Cnt float64 `json:"cnt"`
  3863. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3864. DrtReimFlag string `json:"drt_reim_flag"`
  3865. FeedetlSn string `json:"feedetl_sn"`
  3866. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3867. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3868. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3869. ListSpItemFlag string `json:"list_sp_item_flag"`
  3870. LmtUsedFlag string `json:"lmt_used_flag"`
  3871. MedChrgitmType string `json:"med_chrgitm_type"`
  3872. Memo string `json:"memo"`
  3873. OverlmtAmt float64 `json:"overlmt_amt"`
  3874. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3875. Pric float64 `json:"pric"`
  3876. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3877. SelfpayProp float64 `json:"selfpay_prop"`
  3878. } `json:"result"`
  3879. } `json:"output"`
  3880. RefmsgTime string `json:"refmsg_time"`
  3881. RespondTime string `json:"respond_time"`
  3882. Signtype string `json:"signtype"`
  3883. WarnMsg string `json:"warn_msg"`
  3884. }
  3885. type ResultFour10265 struct {
  3886. Cainfo string `json:"cainfo"`
  3887. ErrMsg string `json:"err_msg"`
  3888. InfRefmsgid string `json:"inf_refmsgid"`
  3889. Infcode string `json:"infcode"`
  3890. Output struct {
  3891. Result []struct {
  3892. BasMednFlag string `json:"bas_medn_flag"`
  3893. ChldMedcFlag string `json:"chld_medc_flag"`
  3894. ChrgitmLv string `json:"chrgitm_lv"`
  3895. Cnt float64 `json:"cnt"`
  3896. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3897. DrtReimFlag string `json:"drt_reim_flag"`
  3898. FeedetlSn string `json:"feedetl_sn"`
  3899. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3900. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3901. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3902. ListSpItemFlag string `json:"list_sp_item_flag"`
  3903. LmtUsedFlag string `json:"lmt_used_flag"`
  3904. MedChrgitmType string `json:"med_chrgitm_type"`
  3905. Memo string `json:"memo"`
  3906. OverlmtAmt float64 `json:"overlmt_amt"`
  3907. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3908. Pric float64 `json:"pric"`
  3909. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3910. SelfpayProp float64 `json:"selfpay_prop"`
  3911. } `json:"result"`
  3912. } `json:"output"`
  3913. RefmsgTime string `json:"refmsg_time"`
  3914. RespondTime string `json:"respond_time"`
  3915. Signtype string `json:"signtype"`
  3916. WarnMsg string `json:"warn_msg"`
  3917. }
  3918. type ResultFive struct {
  3919. Balc float64 `json:"balc"`
  3920. CvlservFlag string `json:"cvlserv_flag"`
  3921. EmpName string `json:"emp_name"`
  3922. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3923. Insutype string `json:"insutype"`
  3924. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3925. PausInsuDate string `json:"paus_insu_date"`
  3926. PsnInsuDate string `json:"psn_insu_date"`
  3927. PsnInsuStas string `json:"psn_insu_stas"`
  3928. PsnType string `json:"psn_type"`
  3929. }
  3930. type ResultSix struct {
  3931. Cainfo interface{} `json:"cainfo"`
  3932. ErrMsg string `json:"err_msg"`
  3933. InfRefmsgid string `json:"inf_refmsgid"`
  3934. Infcode int64 `json:"infcode"`
  3935. Output struct {
  3936. } `json:"output"`
  3937. RefmsgTime string `json:"refmsg_time"`
  3938. RespondTime string `json:"respond_time"`
  3939. Signtype interface{} `json:"signtype"`
  3940. WarnMsg interface{} `json:"warn_msg"`
  3941. }
  3942. type ResultSix10265 struct {
  3943. Cainfo interface{} `json:"cainfo"`
  3944. ErrMsg string `json:"err_msg"`
  3945. InfRefmsgid string `json:"inf_refmsgid"`
  3946. Infcode string `json:"infcode"`
  3947. Output struct {
  3948. } `json:"output"`
  3949. RefmsgTime string `json:"refmsg_time"`
  3950. RespondTime string `json:"respond_time"`
  3951. Signtype interface{} `json:"signtype"`
  3952. WarnMsg interface{} `json:"warn_msg"`
  3953. }
  3954. type ResultSeven struct {
  3955. Cainfo string `json:"cainfo"`
  3956. ErrMsg string `json:"err_msg"`
  3957. InfRefmsgid string `json:"inf_refmsgid"`
  3958. Infcode int64 `json:"infcode"`
  3959. Output struct {
  3960. Setldetail []interface{} `json:"setldetail"`
  3961. Setlinfo struct {
  3962. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3963. AcctPay float64 `json:"acct_pay"`
  3964. ActPayDedc float64 `json:"act_pay_dedc"`
  3965. Age float64 `json:"age"`
  3966. Balc float64 `json:"balc"`
  3967. Brdy string `json:"brdy"`
  3968. Certno string `json:"certno"`
  3969. ClrOptins string `json:"clr_optins"`
  3970. ClrType string `json:"clr_type"`
  3971. ClrWay string `json:"clr_way"`
  3972. CvlservFlag string `json:"cvlserv_flag"`
  3973. CvlservPay float64 `json:"cvlserv_pay"`
  3974. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3975. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3976. Gend string `json:"gend"`
  3977. HifesPay float64 `json:"hifes_pay"`
  3978. HifmiPay float64 `json:"hifmi_pay"`
  3979. HifpPay float64 `json:"hifp_pay"`
  3980. HospPartAmt float64 `json:"hosp_part_amt"`
  3981. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3982. Insutype string `json:"insutype"`
  3983. MafPay float64 `json:"maf_pay"`
  3984. MdtrtCertType string `json:"mdtrt_cert_type"`
  3985. HifobPay float64 `json:"hifob_pay"`
  3986. MdtrtID string `json:"mdtrt_id"`
  3987. MedType string `json:"med_type"`
  3988. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3989. MedinsSetlID string `json:"medins_setl_id"`
  3990. Naty string `json:"naty"`
  3991. OthPay float64 `json:"oth_pay"`
  3992. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3993. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3994. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3995. PsnCashPay float64 `json:"psn_cash_pay"`
  3996. PsnCertType string `json:"psn_cert_type"`
  3997. PsnName string `json:"psn_name"`
  3998. PsnNo string `json:"psn_no"`
  3999. PsnPartAmt float64 `json:"psn_part_amt"`
  4000. PsnType string `json:"psn_type"`
  4001. SetlID string `json:"setl_id"`
  4002. SetlTime string `json:"setl_time"`
  4003. } `json:"setlinfo"`
  4004. } `json:"output"`
  4005. RefmsgTime string `json:"refmsg_time"`
  4006. RespondTime string `json:"respond_time"`
  4007. Signtype interface{} `json:"signtype"`
  4008. WarnMsg interface{} `json:"warn_msg"`
  4009. }
  4010. type ResultSeven10265 struct {
  4011. Cainfo string `json:"cainfo"`
  4012. ErrMsg string `json:"err_msg"`
  4013. InfRefmsgid string `json:"inf_refmsgid"`
  4014. Infcode string `json:"infcode"`
  4015. Output struct {
  4016. Setldetail []interface{} `json:"setldetail"`
  4017. Setlinfo struct {
  4018. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4019. AcctPay float64 `json:"acct_pay"`
  4020. ActPayDedc float64 `json:"act_pay_dedc"`
  4021. Age float64 `json:"age"`
  4022. Balc float64 `json:"balc"`
  4023. Brdy string `json:"brdy"`
  4024. Certno string `json:"certno"`
  4025. ClrOptins string `json:"clr_optins"`
  4026. ClrType string `json:"clr_type"`
  4027. ClrWay string `json:"clr_way"`
  4028. CvlservFlag string `json:"cvlserv_flag"`
  4029. CvlservPay float64 `json:"cvlserv_pay"`
  4030. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4031. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4032. Gend string `json:"gend"`
  4033. HifesPay float64 `json:"hifes_pay"`
  4034. HifmiPay float64 `json:"hifmi_pay"`
  4035. HifpPay float64 `json:"hifp_pay"`
  4036. HospPartAmt float64 `json:"hosp_part_amt"`
  4037. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4038. Insutype string `json:"insutype"`
  4039. MafPay float64 `json:"maf_pay"`
  4040. MdtrtCertType string `json:"mdtrt_cert_type"`
  4041. HifobPay float64 `json:"hifob_pay"`
  4042. MdtrtID string `json:"mdtrt_id"`
  4043. MedType string `json:"med_type"`
  4044. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4045. MedinsSetlID string `json:"medins_setl_id"`
  4046. Naty string `json:"naty"`
  4047. OthPay float64 `json:"oth_pay"`
  4048. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4049. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4050. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4051. PsnCashPay float64 `json:"psn_cash_pay"`
  4052. PsnCertType string `json:"psn_cert_type"`
  4053. PsnName string `json:"psn_name"`
  4054. PsnNo string `json:"psn_no"`
  4055. PsnPartAmt float64 `json:"psn_part_amt"`
  4056. PsnType string `json:"psn_type"`
  4057. SetlID string `json:"setl_id"`
  4058. SetlTime string `json:"setl_time"`
  4059. } `json:"setlinfo"`
  4060. } `json:"output"`
  4061. RefmsgTime string `json:"refmsg_time"`
  4062. RespondTime string `json:"respond_time"`
  4063. Signtype interface{} `json:"signtype"`
  4064. WarnMsg interface{} `json:"warn_msg"`
  4065. }
  4066. type ResultEight struct {
  4067. Cainfo string `json:"cainfo"`
  4068. ErrMsg string `json:"err_msg"`
  4069. InfRefmsgid string `json:"inf_refmsgid"`
  4070. Infcode int64 `json:"infcode"`
  4071. Output struct {
  4072. Stmtinfo struct {
  4073. SetlOptins string `json:"setl_optins"`
  4074. StmtRslt string `json:"stmt_rslt"`
  4075. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4076. } `json:"stmtinfo"`
  4077. } `json:"output"`
  4078. RefmsgTime string `json:"refmsg_time"`
  4079. RespondTime string `json:"respond_time"`
  4080. Signtype interface{} `json:"signtype"`
  4081. WarnMsg interface{} `json:"warn_msg"`
  4082. }
  4083. type ResultEightFor10188 struct {
  4084. Cainfo string `json:"cainfo"`
  4085. ErrMsg string `json:"err_msg"`
  4086. InfRefmsgid string `json:"inf_refmsgid"`
  4087. Infcode string `json:"infcode"`
  4088. Output struct {
  4089. Stmtinfo struct {
  4090. SetlOptins string `json:"setl_optins"`
  4091. StmtRslt string `json:"stmt_rslt"`
  4092. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  4093. } `json:"stmtinfo"`
  4094. } `json:"output"`
  4095. RefmsgTime string `json:"refmsg_time"`
  4096. RespondTime string `json:"respond_time"`
  4097. Signtype interface{} `json:"signtype"`
  4098. WarnMsg interface{} `json:"warn_msg"`
  4099. }
  4100. type ResultNine struct {
  4101. Cainfo string `json:"cainfo"`
  4102. ErrMsg string `json:"err_msg"`
  4103. InfRefmsgid string `json:"inf_refmsgid"`
  4104. Infcode int64 `json:"infcode"`
  4105. Output struct {
  4106. FileQuryNo string `json:"file_qury_no"`
  4107. } `json:"output"`
  4108. RefmsgTime string `json:"refmsg_time"`
  4109. RespondTime string `json:"respond_time"`
  4110. Signtype interface{} `json:"signtype"`
  4111. WarnMsg interface{} `json:"warn_msg"`
  4112. }
  4113. type ResultTen struct {
  4114. Cainfo string `json:"cainfo"`
  4115. ErrMsg string `json:"err_msg"`
  4116. InfRefmsgid string `json:"inf_refmsgid"`
  4117. Infcode int64 `json:"infcode"`
  4118. Output struct {
  4119. DldEndtime string `json:"dld_endtime"`
  4120. FileQuryNo string `json:"file_qury_no"`
  4121. Filename string `json:"filename"`
  4122. } `json:"output"`
  4123. RefmsgTime string `json:"refmsg_time"`
  4124. RespondTime string `json:"respond_time"`
  4125. Signtype interface{} `json:"signtype"`
  4126. WarnMsg interface{} `json:"warn_msg"`
  4127. }
  4128. //type Autogenerated struct {
  4129. // Output struct {
  4130. // Setlinfo struct {
  4131. // SetlTime string `json:"setl_time"`
  4132. // CvlservPay float64 `json:"cvlserv_pay"`
  4133. // Year string `json:"year"`
  4134. // MedType string `json:"med_type"`
  4135. // PsnPay float64 `json:"psn_pay"`
  4136. // OpterID string `json:"opter_id"`
  4137. // Begndate string `json:"begndate"`
  4138. // FlxempeFlag string `json:"flxempe_flag"`
  4139. // HifmiPay float64 `json:"hifmi_pay"`
  4140. // PsnNo string `json:"psn_no"`
  4141. // ActPayDedc float64 `json:"act_pay_dedc"`
  4142. // MedinsSetlID interface{} `json:"medins_setl_id"`
  4143. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4144. // ClrWay string `json:"clr_way"`
  4145. // OthPay float64 `json:"oth_pay"`
  4146. // Gend string `json:"gend"`
  4147. // MdtrtID string `json:"mdtrt_id"`
  4148. // AcctPay float64 `json:"acct_pay"`
  4149. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  4150. // Insutype string `json:"insutype"`
  4151. // Invono interface{} `json:"invono"`
  4152. // Enddate string `json:"enddate"`
  4153. // CashPayamt float64 `json:"cash_payamt"`
  4154. // PsnType string `json:"psn_type"`
  4155. // FixmedinsName string `json:"fixmedins_name"`
  4156. // HifpPay float64 `json:"hifp_pay"`
  4157. // NewFlag interface{} `json:"new_flag"`
  4158. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4159. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4160. // PayLoc string `json:"pay_loc"`
  4161. // ClrType string `json:"clr_type"`
  4162. // RefdSetlFlag string `json:"refd_setl_flag"`
  4163. // CvlservFlag string `json:"cvlserv_flag"`
  4164. // EmpName string `json:"emp_name"`
  4165. // Brdy string `json:"brdy"`
  4166. // Naty string `json:"naty"`
  4167. // Certno string `json:"certno"`
  4168. // DiseCode string `json:"dise_code"`
  4169. // FixmedinsCode string `json:"fixmedins_code"`
  4170. // DedcHospLv string `json:"dedc_hosp_lv"`
  4171. // OpterName string `json:"opter_name"`
  4172. // Balc float64 `json:"balc"`
  4173. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4174. // PsnCertType string `json:"psn_cert_type"`
  4175. // HifobPay float64 `json:"hifob_pay"`
  4176. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4177. // HifesPay float64 `json:"hifes_pay"`
  4178. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4179. // OptTime string `json:"opt_time"`
  4180. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4181. // SetlID string `json:"setl_id"`
  4182. // MafPay float64 `json:"maf_pay"`
  4183. // PsnName string `json:"psn_name"`
  4184. // InsuOptins interface{} `json:"insu_optins"`
  4185. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4186. // ClrOptins string `json:"clr_optins"`
  4187. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4188. // DiseName string `json:"dise_name"`
  4189. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4190. // Age float64 `json:"age"`
  4191. // DtrtCertType string `json:"dtrt_cert_type"`
  4192. // HospLv string `json:"hosp_lv"`
  4193. // } `json:"setlinfo"`
  4194. // Setldetail []struct {
  4195. // FundPayType string `json:"fund_pay_type"`
  4196. // FundPayamt float64 `json:"fund_payamt"`
  4197. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4198. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4199. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4200. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4201. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4202. // } `json:"setldetail"`
  4203. // } `json:"output"`
  4204. // Infcode int `json:"infcode"`
  4205. // WarnMsg interface{} `json:"warn_msg"`
  4206. // Cainfo interface{} `json:"cainfo"`
  4207. // ErrMsg interface{} `json:"err_msg"`
  4208. // RefmsgTime string `json:"refmsg_time"`
  4209. // Signtype interface{} `json:"signtype"`
  4210. // RespondTime string `json:"respond_time"`
  4211. // InfRefmsgid string `json:"inf_refmsgid"`
  4212. //}
  4213. type ResultEleven struct {
  4214. Cainfo string `json:"cainfo"`
  4215. ErrMsg string `json:"err_msg"`
  4216. InfRefmsgid string `json:"inf_refmsgid"`
  4217. Infcode int64 `json:"infcode"`
  4218. Output struct {
  4219. Setlinfo struct {
  4220. SetlTime string `json:"setl_time"`
  4221. CvlservPay float64 `json:"cvlserv_pay"`
  4222. Year string `json:"year"`
  4223. MedType string `json:"med_type"`
  4224. PsnPay float64 `json:"psn_pay"`
  4225. OpterID string `json:"opter_id"`
  4226. Begndate string `json:"begndate"`
  4227. FlxempeFlag string `json:"flxempe_flag"`
  4228. HifmiPay float64 `json:"hifmi_pay"`
  4229. PsnNo string `json:"psn_no"`
  4230. ActPayDedc float64 `json:"act_pay_dedc"`
  4231. MedinsSetlID interface{} `json:"medins_setl_id"`
  4232. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4233. ClrWay string `json:"clr_way"`
  4234. OthPay float64 `json:"oth_pay"`
  4235. Gend string `json:"gend"`
  4236. MdtrtID string `json:"mdtrt_id"`
  4237. AcctPay float64 `json:"acct_pay"`
  4238. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4239. Insutype string `json:"insutype"`
  4240. Invono interface{} `json:"invono"`
  4241. Enddate string `json:"enddate"`
  4242. CashPayamt float64 `json:"cash_payamt"`
  4243. PsnType string `json:"psn_type"`
  4244. FixmedinsName string `json:"fixmedins_name"`
  4245. HifpPay float64 `json:"hifp_pay"`
  4246. NewFlag interface{} `json:"new_flag"`
  4247. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4248. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4249. PayLoc string `json:"pay_loc"`
  4250. ClrType string `json:"clr_type"`
  4251. RefdSetlFlag string `json:"refd_setl_flag"`
  4252. CvlservFlag string `json:"cvlserv_flag"`
  4253. EmpName string `json:"emp_name"`
  4254. Brdy string `json:"brdy"`
  4255. Naty string `json:"naty"`
  4256. Certno string `json:"certno"`
  4257. DiseCode string `json:"dise_code"`
  4258. FixmedinsCode string `json:"fixmedins_code"`
  4259. DedcHospLv string `json:"dedc_hosp_lv"`
  4260. OpterName string `json:"opter_name"`
  4261. Balc float64 `json:"balc"`
  4262. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4263. PsnCertType string `json:"psn_cert_type"`
  4264. HifobPay float64 `json:"hifob_pay"`
  4265. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4266. HifesPay float64 `json:"hifes_pay"`
  4267. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4268. OptTime string `json:"opt_time"`
  4269. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4270. SetlID string `json:"setl_id"`
  4271. MafPay float64 `json:"maf_pay"`
  4272. PsnName string `json:"psn_name"`
  4273. InsuOptins interface{} `json:"insu_optins"`
  4274. PrefFundPay interface{} `json:"pref_fund_pay"`
  4275. ClrOptins string `json:"clr_optins"`
  4276. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4277. DiseName string `json:"dise_name"`
  4278. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4279. Age float64 `json:"age"`
  4280. DtrtCertType string `json:"dtrt_cert_type"`
  4281. HospLv string `json:"hosp_lv"`
  4282. } `json:"setlinfo"`
  4283. } `json:"output"`
  4284. RefmsgTime string `json:"refmsg_time"`
  4285. RespondTime string `json:"respond_time"`
  4286. Signtype interface{} `json:"signtype"`
  4287. WarnMsg interface{} `json:"warn_msg"`
  4288. }
  4289. type ResultEleven10265 struct {
  4290. Cainfo string `json:"cainfo"`
  4291. ErrMsg string `json:"err_msg"`
  4292. InfRefmsgid string `json:"inf_refmsgid"`
  4293. Infcode string `json:"infcode"`
  4294. Output struct {
  4295. Setlinfo struct {
  4296. SetlTime string `json:"setl_time"`
  4297. CvlservPay float64 `json:"cvlserv_pay"`
  4298. Year string `json:"year"`
  4299. MedType string `json:"med_type"`
  4300. PsnPay float64 `json:"psn_pay"`
  4301. OpterID string `json:"opter_id"`
  4302. Begndate string `json:"begndate"`
  4303. FlxempeFlag string `json:"flxempe_flag"`
  4304. HifmiPay float64 `json:"hifmi_pay"`
  4305. PsnNo string `json:"psn_no"`
  4306. ActPayDedc float64 `json:"act_pay_dedc"`
  4307. MedinsSetlID interface{} `json:"medins_setl_id"`
  4308. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4309. ClrWay string `json:"clr_way"`
  4310. OthPay float64 `json:"oth_pay"`
  4311. Gend string `json:"gend"`
  4312. MdtrtID string `json:"mdtrt_id"`
  4313. AcctPay float64 `json:"acct_pay"`
  4314. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4315. Insutype string `json:"insutype"`
  4316. Invono interface{} `json:"invono"`
  4317. Enddate string `json:"enddate"`
  4318. CashPayamt float64 `json:"cash_payamt"`
  4319. PsnType string `json:"psn_type"`
  4320. FixmedinsName string `json:"fixmedins_name"`
  4321. HifpPay float64 `json:"hifp_pay"`
  4322. NewFlag interface{} `json:"new_flag"`
  4323. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4324. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4325. PayLoc string `json:"pay_loc"`
  4326. ClrType string `json:"clr_type"`
  4327. RefdSetlFlag string `json:"refd_setl_flag"`
  4328. CvlservFlag string `json:"cvlserv_flag"`
  4329. EmpName string `json:"emp_name"`
  4330. Brdy string `json:"brdy"`
  4331. Naty string `json:"naty"`
  4332. Certno string `json:"certno"`
  4333. DiseCode string `json:"dise_code"`
  4334. FixmedinsCode string `json:"fixmedins_code"`
  4335. DedcHospLv string `json:"dedc_hosp_lv"`
  4336. OpterName string `json:"opter_name"`
  4337. Balc float64 `json:"balc"`
  4338. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4339. PsnCertType string `json:"psn_cert_type"`
  4340. HifobPay float64 `json:"hifob_pay"`
  4341. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4342. HifesPay float64 `json:"hifes_pay"`
  4343. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4344. OptTime string `json:"opt_time"`
  4345. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4346. SetlID string `json:"setl_id"`
  4347. MafPay float64 `json:"maf_pay"`
  4348. PsnName string `json:"psn_name"`
  4349. InsuOptins interface{} `json:"insu_optins"`
  4350. PrefFundPay interface{} `json:"pref_fund_pay"`
  4351. ClrOptins string `json:"clr_optins"`
  4352. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4353. DiseName string `json:"dise_name"`
  4354. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4355. Age float64 `json:"age"`
  4356. DtrtCertType string `json:"dtrt_cert_type"`
  4357. HospLv string `json:"hosp_lv"`
  4358. } `json:"setlinfo"`
  4359. } `json:"output"`
  4360. RefmsgTime string `json:"refmsg_time"`
  4361. RespondTime string `json:"respond_time"`
  4362. Signtype interface{} `json:"signtype"`
  4363. WarnMsg interface{} `json:"warn_msg"`
  4364. }
  4365. type ResultTwelve struct {
  4366. Cainfo string `json:"cainfo"`
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode int64 `json:"infcode"`
  4370. Output struct {
  4371. MdtrtId string `json:"mdtrt_id"`
  4372. ChrgBchno string `json:"chrg_bchno"`
  4373. PsnNo string `json:"psn_no"`
  4374. } `json:"output"`
  4375. RefmsgTime string `json:"refmsg_time"`
  4376. RespondTime string `json:"respond_time"`
  4377. Signtype interface{} `json:"signtype"`
  4378. WarnMsg interface{} `json:"warn_msg"`
  4379. }
  4380. type ResultThirteen struct {
  4381. ErrMsg string `json:"err_msg"`
  4382. InfRefmsgid string `json:"inf_refmsgid"`
  4383. Infcode int64 `json:"infcode"`
  4384. Output struct {
  4385. Result struct {
  4386. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4387. } `json:"result"`
  4388. } `json:"output"`
  4389. RefmsgTime string `json:"refmsg_time"`
  4390. RespondTime string `json:"respond_time"`
  4391. Signtype interface{} `json:"signtype"`
  4392. WarnInfo interface{} `json:"warn_info"`
  4393. }
  4394. type ResultThirteen10265 struct {
  4395. ErrMsg string `json:"err_msg"`
  4396. InfRefmsgid string `json:"inf_refmsgid"`
  4397. Infcode string `json:"infcode"`
  4398. Output struct {
  4399. Result struct {
  4400. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4401. } `json:"result"`
  4402. } `json:"output"`
  4403. RefmsgTime string `json:"refmsg_time"`
  4404. RespondTime string `json:"respond_time"`
  4405. Signtype interface{} `json:"signtype"`
  4406. WarnInfo interface{} `json:"warn_info"`
  4407. }
  4408. type ResultFourteen struct {
  4409. ErrMsg string `json:"err_msg"`
  4410. InfRefmsgid string `json:"inf_refmsgid"`
  4411. Infcode int64 `json:"infcode"`
  4412. Output struct {
  4413. } `json:"output"`
  4414. RefmsgTime string `json:"refmsg_time"`
  4415. RespondTime string `json:"respond_time"`
  4416. Signtype interface{} `json:"signtype"`
  4417. WarnInfo interface{} `json:"warn_info"`
  4418. }
  4419. type ResultFourteen10265 struct {
  4420. ErrMsg string `json:"err_msg"`
  4421. InfRefmsgid string `json:"inf_refmsgid"`
  4422. Infcode string `json:"infcode"`
  4423. Output struct {
  4424. } `json:"output"`
  4425. RefmsgTime string `json:"refmsg_time"`
  4426. RespondTime string `json:"respond_time"`
  4427. Signtype interface{} `json:"signtype"`
  4428. WarnInfo interface{} `json:"warn_info"`
  4429. }
  4430. type ResultSixteen struct {
  4431. Cainfo string `json:"cainfo"`
  4432. ErrMsg string `json:"err_msg"`
  4433. InfRefmsgid string `json:"inf_refmsgid"`
  4434. Infcode int64 `json:"infcode"`
  4435. Output struct {
  4436. Setldetail []interface{} `json:"setldetail"`
  4437. Setlinfo struct {
  4438. MdtrtID string `json:"mdtrt_id"`
  4439. SetlID string `json:"setl_id"`
  4440. ClrOptins string `json:"clr_optins"`
  4441. SetlTime string `json:"setl_time"`
  4442. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4443. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4444. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4445. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4446. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4447. ActPayDedc float64 `json:"act_pay_dedc"`
  4448. HifpPay float64 `json:"hifp_pay"`
  4449. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4450. Lfpay float64 `json:"selfpay"`
  4451. CvlservPay float64 `json:"cvlserv_pay"`
  4452. HifesPay float64 `json:"hifes_pay"`
  4453. HifmiPay float64 `json:"hifmi_pay"`
  4454. HifobPay float64 `json:"hifob_pay"`
  4455. MafPay float64 `json:"maf_pay"`
  4456. OthPay float64 `json:"oth_pay"`
  4457. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4458. PsnPartAmt float64 `json:"psn_part_amt"`
  4459. AcctPay float64 `json:"acct_pay"`
  4460. Balc float64 `json:"balc"`
  4461. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4462. HospPartAmt float64 `json:"hosp_part_amt"`
  4463. MedinsSetlID string `json:"medins_setl_id"`
  4464. PdnCashPay string `json:"pdn_cash_pay"`
  4465. } `json:"setlinfo"`
  4466. } `json:"output"`
  4467. RefmsgTime string `json:"refmsg_time"`
  4468. RespondTime string `json:"respond_time"`
  4469. Signtype interface{} `json:"signtype"`
  4470. WarnMsg interface{} `json:"warn_msg"`
  4471. }
  4472. type ResultSixteen10265 struct {
  4473. Cainfo string `json:"cainfo"`
  4474. ErrMsg string `json:"err_msg"`
  4475. InfRefmsgid string `json:"inf_refmsgid"`
  4476. Infcode string `json:"infcode"`
  4477. Output struct {
  4478. Setldetail []interface{} `json:"setldetail"`
  4479. Setlinfo struct {
  4480. MdtrtID string `json:"mdtrt_id"`
  4481. SetlID string `json:"setl_id"`
  4482. ClrOptins string `json:"clr_optins"`
  4483. SetlTime string `json:"setl_time"`
  4484. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4485. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4486. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4487. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4488. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4489. ActPayDedc float64 `json:"act_pay_dedc"`
  4490. HifpPay float64 `json:"hifp_pay"`
  4491. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4492. Lfpay float64 `json:"selfpay"`
  4493. CvlservPay float64 `json:"cvlserv_pay"`
  4494. HifesPay float64 `json:"hifes_pay"`
  4495. HifmiPay float64 `json:"hifmi_pay"`
  4496. HifobPay float64 `json:"hifob_pay"`
  4497. MafPay float64 `json:"maf_pay"`
  4498. OthPay float64 `json:"oth_pay"`
  4499. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4500. PsnPartAmt float64 `json:"psn_part_amt"`
  4501. AcctPay float64 `json:"acct_pay"`
  4502. Balc float64 `json:"balc"`
  4503. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4504. HospPartAmt float64 `json:"hosp_part_amt"`
  4505. MedinsSetlID string `json:"medins_setl_id"`
  4506. PdnCashPay string `json:"pdn_cash_pay"`
  4507. } `json:"setlinfo"`
  4508. } `json:"output"`
  4509. RefmsgTime string `json:"refmsg_time"`
  4510. RespondTime string `json:"respond_time"`
  4511. Signtype interface{} `json:"signtype"`
  4512. WarnMsg interface{} `json:"warn_msg"`
  4513. }
  4514. type ResultSeventeen struct {
  4515. ErrMsg string `json:"err_msg"`
  4516. InfRefmsgid string `json:"inf_refmsgid"`
  4517. Infcode int64 `json:"infcode"`
  4518. Output struct {
  4519. SetlListId string `json:"setl_list_id"`
  4520. } `json:"output"`
  4521. RefmsgTime string `json:"refmsg_time"`
  4522. RespondTime string `json:"respond_time"`
  4523. Signtype string `json:"signtype"`
  4524. WarnInfo string `json:"warn_info"`
  4525. }
  4526. type ResultSeventeenOther struct {
  4527. ErrMsg string `json:"err_msg"`
  4528. InfRefmsgid string `json:"inf_refmsgid"`
  4529. Infcode string `json:"infcode"`
  4530. Output struct {
  4531. SetlListId string `json:"setl_list_id"`
  4532. } `json:"output"`
  4533. RefmsgTime string `json:"refmsg_time"`
  4534. RespondTime string `json:"respond_time"`
  4535. Signtype string `json:"signtype"`
  4536. WarnInfo string `json:"warn_info"`
  4537. }
  4538. type Result90991 struct {
  4539. ErrMsg string `json:"err_msg"`
  4540. InfRefmsgid string `json:"inf_refmsgid"`
  4541. Infcode int64 `json:"infcode"`
  4542. Output struct {
  4543. Result struct {
  4544. PsnNo string `json:"psn_no"`
  4545. CardStat string `json:"card_stat"`
  4546. Certno string `json:"certno"`
  4547. PsnName string `json:"psn_name"`
  4548. CheckStat string `json:"check_stat"`
  4549. SscnoCheckStat string `json:"sscno_check_stat"`
  4550. } `json:"result"`
  4551. } `json:"output"`
  4552. RefmsgTime string `json:"refmsg_time"`
  4553. RespondTime string `json:"respond_time"`
  4554. Signtype interface{} `json:"signtype"`
  4555. WarnInfo interface{} `json:"warn_info"`
  4556. }
  4557. type Result90100 struct {
  4558. ErrMsg string `json:"err_msg"`
  4559. InfRefmsgid string `json:"inf_refmsgid"`
  4560. Infcode int64 `json:"infcode"`
  4561. Output struct {
  4562. PoolareaNo string `json:"poolarea_no"`
  4563. PoolareaNoName string `json:"poolarea_no_name"`
  4564. Insutype string `json:"insutype"`
  4565. InsutypeName string `json:"insutype_name"`
  4566. ClctType string `json:"clct_type"`
  4567. ClctTypeName string `json:"clct_type_name"`
  4568. ClctFlag string `json:"clct_flag"`
  4569. ClctFlagName string `json:"clct_flag_name"`
  4570. AccrymBegn string `json:"accrym_begn"`
  4571. AccrymEnd string `json:"accrym_end"`
  4572. ClctTime string `json:"clct_time"`
  4573. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4574. } `json:"output"`
  4575. RefmsgTime string `json:"refmsg_time"`
  4576. RespondTime string `json:"respond_time"`
  4577. Signtype interface{} `json:"signtype"`
  4578. WarnInfo interface{} `json:"warn_info"`
  4579. }
  4580. type Custom struct {
  4581. DetItemFeeSumamt string
  4582. Cut string
  4583. FeedetlSn string
  4584. Price string
  4585. MedListCodg string
  4586. Type int64
  4587. AdviceId int64
  4588. ProjectId int64
  4589. ItemId int64
  4590. }
  4591. type Result5301 struct {
  4592. ErrMsg string `json:"err_msg"`
  4593. InfRefmsgid string `json:"inf_refmsgid"`
  4594. Infcode int64 `json:"infcode"`
  4595. Output struct {
  4596. Result []struct {
  4597. OpspDiseCode string `json:"opsp_dise_code"`
  4598. OpspDiseName string `json:"opsp_dise_name"`
  4599. Begndate string `json:"begndate"`
  4600. Enddate string `json:"enddate"`
  4601. } `json:"feedetail"`
  4602. } `json:"output"`
  4603. RefmsgTime string `json:"refmsg_time"`
  4604. RespondTime string `json:"respond_time"`
  4605. Signtype interface{} `json:"signtype"`
  4606. WarnInfo interface{} `json:"warn_info"`
  4607. }
  4608. type Result5301For10265 struct {
  4609. ErrMsg string `json:"err_msg"`
  4610. InfRefmsgid string `json:"inf_refmsgid"`
  4611. Infcode string `json:"infcode"`
  4612. Output struct {
  4613. Result []struct {
  4614. OpspDiseCode string `json:"opsp_dise_code"`
  4615. OpspDiseName string `json:"opsp_dise_name"`
  4616. Begndate string `json:"begndate"`
  4617. Enddate string `json:"enddate"`
  4618. } `json:"feedetail"`
  4619. } `json:"output"`
  4620. RefmsgTime string `json:"refmsg_time"`
  4621. RespondTime string `json:"respond_time"`
  4622. Signtype interface{} `json:"signtype"`
  4623. WarnInfo interface{} `json:"warn_info"`
  4624. }
  4625. //获取个人信息----挂号-----上传就诊信息
  4626. func (c *HisApiController) GetRegisterInfo() {
  4627. id, _ := c.GetInt64("id")
  4628. record_time := c.GetString("record_time")
  4629. settlementValue, _ := c.GetInt64("settlement_value")
  4630. medical_insurance_card := c.GetString("medical_insurance_card")
  4631. name := c.GetString("name")
  4632. id_card_type, _ := c.GetInt64("id_card_type")
  4633. certificates, _ := c.GetInt64("certificates")
  4634. medical_care, _ := c.GetInt64("medical_care")
  4635. birthday := c.GetString("birthday")
  4636. id_card := c.GetString("id_card")
  4637. register_type, _ := c.GetInt64("register")
  4638. doctor, _ := c.GetInt64("doctor")
  4639. department, _ := c.GetInt64("department")
  4640. gender, _ := c.GetInt64("sex")
  4641. registration_fee, _ := c.GetFloat("registration_fee")
  4642. medical_expenses, _ := c.GetFloat("medical_expenses")
  4643. social_type, _ := c.GetInt64("social_type")
  4644. med_type := c.GetString("social_type")
  4645. admin_user_id, _ := c.GetInt64("admin_user_id")
  4646. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4647. timeLayout := "2006-01-02"
  4648. loc, _ := time.LoadLocation("Local")
  4649. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4650. birthUnix := birthdays.Unix()
  4651. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4652. if err != nil {
  4653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4654. return
  4655. }
  4656. recordDateTime := theTime.Unix()
  4657. adminInfo := c.GetAdminUserInfo()
  4658. var patient service.Patients
  4659. if id == 0 {
  4660. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4661. } else {
  4662. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4663. }
  4664. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4665. if patientPrescription.ID == 0 {
  4666. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4667. }
  4668. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4669. if patient.ID == 0 {
  4670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4671. return
  4672. }
  4673. if len(patient.IdCardNo) == 0 {
  4674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4675. return
  4676. }
  4677. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4678. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4679. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4680. //就诊结算未完成,不能进行二次挂号
  4681. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4682. if len(his) >= 1 {
  4683. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4684. if len(his) >= 1 && order.ID == 0 {
  4685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4686. return
  4687. }
  4688. }
  4689. //var register_log string
  4690. if config.IsOpen == 1 {
  4691. var res ResultTwo
  4692. var res10265 ResultTwo10265
  4693. var PsnNo string
  4694. var PsnCertType string
  4695. var Certno string
  4696. var PsnName string
  4697. var Gend string
  4698. var Naty string
  4699. var Brdy string
  4700. var Age float64
  4701. var infoStr string
  4702. var idetinfoStr string
  4703. var infocode int64
  4704. var verify_number string
  4705. fmt.Println(verify_number)
  4706. if miConfig.MdtrtareaAdmvs == "421300" {
  4707. psn_info, _ := service.GetPsnByPatientId(id)
  4708. PsnNo = psn_info.PsnNo
  4709. PsnCertType = psn_info.PsnCertType
  4710. Certno = psn_info.Certno
  4711. PsnName = psn_info.PsnName
  4712. Gend = psn_info.Gend
  4713. Naty = psn_info.Naty
  4714. Brdy = psn_info.Brdy
  4715. Age = psn_info.Age
  4716. infoStr = psn_info.Insuinfo
  4717. idetinfoStr = psn_info.Idetinfo
  4718. infocode = 0
  4719. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4720. psn_info, _ := service.GetPsnByPatientId(id)
  4721. PsnNo = psn_info.PsnNo
  4722. PsnCertType = psn_info.PsnCertType
  4723. Certno = psn_info.Certno
  4724. PsnName = psn_info.PsnName
  4725. Gend = psn_info.Gend
  4726. Naty = psn_info.Naty
  4727. Brdy = psn_info.Brdy
  4728. Age = psn_info.Age
  4729. infoStr = psn_info.Insuinfo
  4730. idetinfoStr = psn_info.Idetinfo
  4731. infocode = 0
  4732. verify_number = psn_info.VerifyNumber
  4733. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4734. if id_card_type == 1 {
  4735. psn_info, _ := service.GetPsnByPatientId(id)
  4736. PsnNo = psn_info.PsnNo
  4737. PsnCertType = psn_info.PsnCertType
  4738. Certno = psn_info.Certno
  4739. PsnName = psn_info.PsnName
  4740. Gend = psn_info.Gend
  4741. Naty = psn_info.Naty
  4742. Brdy = psn_info.Brdy
  4743. Age = psn_info.Age
  4744. infoStr = psn_info.Insuinfo
  4745. idetinfoStr = psn_info.Idetinfo
  4746. infocode = 0
  4747. verify_number = psn_info.VerifyNumber
  4748. } else if id_card_type == 2 {
  4749. result, requestLog, errMsgLog := service.FJyb1101(patient.IdCardNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, patient.IdCardNo, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4750. fmt.Println(errMsgLog)
  4751. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4753. utils.ErrorLog("解析失败:%v", err)
  4754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4755. return
  4756. }
  4757. PsnNo = res.Output.Baseinfo.PsnNo
  4758. PsnCertType = res.Output.Baseinfo.PsnCertType
  4759. Certno = res.Output.Baseinfo.Certno
  4760. PsnName = res.Output.Baseinfo.PsnName
  4761. Gend = res.Output.Baseinfo.Gend
  4762. Naty = res.Output.Baseinfo.Naty
  4763. Brdy = res.Output.Baseinfo.Brdy
  4764. Age = res.Output.Baseinfo.Age
  4765. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4766. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4767. infoStr = string(Iinfos)
  4768. idetinfoStr = string(Idetinfos)
  4769. infocode = res.Infcode
  4770. }
  4771. } else {
  4772. var result string
  4773. var requestLog string
  4774. if miConfig.UserOrgId == 10138 {
  4775. if id_card_type == 4 {
  4776. psn_info, _ := service.GetPsnByPatientId(id)
  4777. result, requestLog = service.Gdyb1101ForEleCert(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_info.VerifyNumber)
  4778. } else {
  4779. 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)
  4780. }
  4781. } else {
  4782. 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)
  4783. }
  4784. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4785. if miConfig.Code == "H15049901371" {
  4786. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4787. utils.ErrorLog("解析失败:%v", err)
  4788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. return
  4790. }
  4791. res.ErrMsg = res10265.ErrMsg
  4792. res.Output = res10265.Output
  4793. res.InfRefmsgid = res10265.InfRefmsgid
  4794. } else {
  4795. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4796. utils.ErrorLog("解析失败:%v", err)
  4797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4798. return
  4799. }
  4800. }
  4801. PsnNo = res.Output.Baseinfo.PsnNo
  4802. PsnCertType = res.Output.Baseinfo.PsnCertType
  4803. Certno = res.Output.Baseinfo.Certno
  4804. PsnName = res.Output.Baseinfo.PsnName
  4805. Gend = res.Output.Baseinfo.Gend
  4806. Naty = res.Output.Baseinfo.Naty
  4807. Brdy = res.Output.Baseinfo.Brdy
  4808. Age = res.Output.Baseinfo.Age
  4809. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4810. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4811. infoStr = string(Iinfos)
  4812. idetinfoStr = string(Idetinfos)
  4813. if miConfig.Code == "H15049901371" {
  4814. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4815. } else {
  4816. infocode = res.Infcode
  4817. }
  4818. }
  4819. if infocode == 0 {
  4820. his := models.VMHisPatient{
  4821. Name: name,
  4822. Gender: gender,
  4823. Birthday: birthUnix,
  4824. MedicalTreatmentType: medical_care,
  4825. IdType: certificates,
  4826. IdCardNo: id_card,
  4827. BalanceAccountsType: settlementValue,
  4828. SocialType: social_type,
  4829. MedicalInsuranceNumber: medical_insurance_card,
  4830. RegisterType: register_type,
  4831. RegisterCost: registration_fee,
  4832. TreatmentCost: medical_expenses,
  4833. Status: 1,
  4834. Ctime: time.Now().Unix(),
  4835. Mtime: time.Now().Unix(),
  4836. PsnNo: PsnNo,
  4837. PsnCertType: PsnCertType,
  4838. Certno: Certno,
  4839. PsnName: PsnName,
  4840. Gend: Gend,
  4841. Naty: Naty,
  4842. Brdy: Brdy,
  4843. Age: Age,
  4844. Iinfo: infoStr,
  4845. Idetinfo: idetinfoStr,
  4846. PatientId: patient.ID,
  4847. RecordDate: theTime.Unix(),
  4848. UserOrgId: adminInfo.CurrentOrgId,
  4849. AdminUserId: admin_user_id,
  4850. IsReturn: 1,
  4851. IdCardType: id_card_type,
  4852. Doctor: doctor,
  4853. Departments: department,
  4854. }
  4855. timestamp := time.Now().Unix()
  4856. tempTime := time.Unix(timestamp, 0)
  4857. timeFormat := tempTime.Format("20060102150405")
  4858. chrgBchno := rand.Intn(100000) + 10000
  4859. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4860. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4861. department, _ := service.GetDepartMentDetail(department)
  4862. //doctor_id := strconv.FormatInt(patientPrescription., 10)
  4863. IdCardNo := ""
  4864. if id_card_type == 1 {
  4865. // IdCardNo = medical_insurance_card
  4866. IdCardNo = patient.IdCardNo
  4867. } else {
  4868. IdCardNo = patient.IdCardNo
  4869. }
  4870. var rf []*ResultFive
  4871. json.Unmarshal([]byte(his.Iinfo), &rf)
  4872. var insutypes []*ResultFive
  4873. var insutype string
  4874. var insuplc_admdvs_temp string
  4875. var is390 int = 0
  4876. var is310 int = 0
  4877. for _, item := range rf {
  4878. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4879. insutypes = append(insutypes, item)
  4880. }
  4881. }
  4882. if len(insutypes) == 1 {
  4883. insutype = insutypes[0].Insutype
  4884. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4885. } else {
  4886. for _, i := range insutypes {
  4887. if i.Insutype == "390" {
  4888. is390 = 1
  4889. }
  4890. if i.Insutype == "310" {
  4891. is310 = 1
  4892. }
  4893. }
  4894. }
  4895. if is390 == 1 {
  4896. insutype = "390"
  4897. }
  4898. if is310 == 1 {
  4899. insutype = "310"
  4900. }
  4901. if len(insutypes) == 0 {
  4902. insutype = "310"
  4903. }
  4904. if len(insutypes) == 2 {
  4905. insutype = med_type
  4906. }
  4907. if len(med_type) > 0 {
  4908. insutype = med_type
  4909. }
  4910. //for _, item := range rf {
  4911. // if item.Insutype == insutype {
  4912. // insuplc_admdvs = item.InsuplcAdmdvs
  4913. // }
  4914. //}
  4915. var infocode int64
  4916. var resThree ResultThree
  4917. var resThree10265 ResultThree10265
  4918. if len(insuplc_admdvs) == 0 {
  4919. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4920. } else {
  4921. insuplc_admdvs_temp = insuplc_admdvs
  4922. }
  4923. if miConfig.MdtrtareaAdmvs == "421300" {
  4924. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4925. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4926. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4927. "&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
  4928. resp, requestErr := http.Get(api)
  4929. if requestErr != nil {
  4930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4931. return
  4932. }
  4933. body, ioErr := ioutil.ReadAll(resp.Body)
  4934. if ioErr != nil {
  4935. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4937. return
  4938. }
  4939. var respJSON map[string]interface{}
  4940. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4941. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4943. return
  4944. }
  4945. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4946. result, _ := json.Marshal(respJSON)
  4947. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4948. utils.ErrorLog("解析失败:%v", err)
  4949. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4950. return
  4951. }
  4952. infocode = resThree.Infcode
  4953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4954. psn_info, _ := service.GetPsnByPatientId(id)
  4955. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4956. var cert_no string
  4957. if id_card_type == 3 {
  4958. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4959. cert_no = IdCardNo
  4960. } else if id_card_type == 4 {
  4961. cert_no = IdCardNo
  4962. psn_info.VerifyNumber = psn_info.VerifyNumber
  4963. } else {
  4964. bas := strings.Split(psn_info.CardInfo, "|")
  4965. cert_no = bas[2]
  4966. }
  4967. var api string
  4968. if miConfig.MdtrtareaAdmvs == "320921" {
  4969. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4970. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4971. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4972. } else {
  4973. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4974. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4975. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_info.DoctorNumber + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4976. }
  4977. resp, requestErr := http.Get(api)
  4978. if requestErr != nil {
  4979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4980. return
  4981. }
  4982. body, ioErr := ioutil.ReadAll(resp.Body)
  4983. if ioErr != nil {
  4984. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4985. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4986. return
  4987. }
  4988. var respJSON map[string]interface{}
  4989. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4990. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4992. return
  4993. }
  4994. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4995. result, _ := json.Marshal(respJSON)
  4996. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4997. utils.ErrorLog("解析失败:%v", err)
  4998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4999. return
  5000. }
  5001. resThree.ErrMsg = resThree10265.ErrMsg
  5002. resThree.Output = resThree10265.Output
  5003. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5004. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5005. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5006. psn_info, _ := service.GetPsnByPatientId(id)
  5007. var cert_no string
  5008. if id_card_type == 1 {
  5009. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5010. } else {
  5011. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  5012. }
  5013. fmt.Println(cert_no)
  5014. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  5015. saveLog(result, requestLog, "2201", "挂号")
  5016. if miConfig.Code == "H15049901371" {
  5017. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5018. utils.ErrorLog("解析失败:%v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. resThree.ErrMsg = resThree10265.ErrMsg
  5023. resThree.Output = resThree10265.Output
  5024. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5025. } else {
  5026. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5027. utils.ErrorLog("解析失败:%v", err)
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. return
  5030. }
  5031. }
  5032. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5033. } else {
  5034. //Check3101(c, patient.ID, his.ID, admin_user_id)
  5035. psn_info, _ := service.GetPsnByPatientId(id)
  5036. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_info.DoctorNumber, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time, psn_info.VerifyNumber)
  5037. saveLog(result, requestLog, "2201A", "挂号")
  5038. if miConfig.Code == "H15049901371" {
  5039. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  5040. utils.ErrorLog("解析失败:%v", err)
  5041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5042. return
  5043. }
  5044. resThree.ErrMsg = resThree10265.ErrMsg
  5045. resThree.Output = resThree10265.Output
  5046. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  5047. } else {
  5048. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  5049. utils.ErrorLog("解析失败:%v", err)
  5050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5051. return
  5052. }
  5053. }
  5054. if miConfig.Code == "H15049901371" {
  5055. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  5056. } else {
  5057. infocode = resThree.Infcode
  5058. }
  5059. }
  5060. if infocode != 0 {
  5061. adminUser := c.GetAdminUserInfo()
  5062. errlog := &models.HisOrderError{
  5063. UserOrgId: adminUser.CurrentOrgId,
  5064. Ctime: time.Now().Unix(),
  5065. Mtime: time.Now().Unix(),
  5066. ErrMsg: resThree.ErrMsg,
  5067. Status: 1,
  5068. PatientId: id,
  5069. RecordTime: recordDateTime,
  5070. Stage: 2,
  5071. }
  5072. service.CreateErrMsgLog(errlog)
  5073. c.ServeSuccessJSON(map[string]interface{}{
  5074. "failed_code": -10,
  5075. "msg": resThree.ErrMsg,
  5076. })
  5077. return
  5078. }
  5079. his.Number = resThree.Output.Data.MdtrtID
  5080. his.PsnNo = resThree.Output.Data.PsnNo
  5081. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  5082. his.IdCardNo = patient.IdCardNo
  5083. his.PhoneNumber = patient.Phone
  5084. his.UserOrgId = adminInfo.CurrentOrgId
  5085. his.Insutype = insutype
  5086. his.Ctime = time.Now().Unix()
  5087. his.Mtime = time.Now().Unix()
  5088. his.InsuplcAdmdvs = insuplc_admdvs_temp
  5089. his.Status = 1
  5090. service.UpdateHisPatientStatus(&his)
  5091. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  5092. var prescriptions []*models.HisPrescription
  5093. res := Check3101(c, patient.ID, his.ID, admin_user_id, "1", record_time, prescriptions)
  5094. if res.Infcode == "0" {
  5095. if len(res.Output.Result) > 0 {
  5096. var res2 ResultSix
  5097. var resSix10265 ResultSix10265
  5098. var api3 string
  5099. if miConfig.MdtrtareaAdmvs == "320921" {
  5100. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5101. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5102. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5103. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5104. } else {
  5105. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5106. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  5107. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  5108. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  5109. }
  5110. resp3, requestErr3 := http.Get(api3)
  5111. if requestErr3 != nil {
  5112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5113. return
  5114. }
  5115. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  5116. if ioErr3 != nil {
  5117. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  5118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5119. return
  5120. }
  5121. var respJSON3 map[string]interface{}
  5122. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  5123. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5125. return
  5126. }
  5127. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5128. userJSONBytes3, _ := json.Marshal(respJSON3)
  5129. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  5130. utils.ErrorLog("解析失败:%v", err)
  5131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5132. return
  5133. }
  5134. res2.InfRefmsgid = resSix10265.InfRefmsgid
  5135. res2.Output = resSix10265.Output
  5136. res2.ErrMsg = resSix10265.ErrMsg
  5137. res2.Cainfo = resSix10265.Cainfo
  5138. res2.WarnMsg = resSix10265.WarnMsg
  5139. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  5140. res2.Infcode = infocode
  5141. if res2.Infcode == 0 {
  5142. var msg []string
  5143. msg = append(msg, "挂号失败")
  5144. for _, item := range res.Output.Result {
  5145. msg = append(msg, item.VolaCont)
  5146. }
  5147. c.ServeSuccessJSON(map[string]interface{}{
  5148. "failed_code": -10,
  5149. "msg": msg,
  5150. })
  5151. } else {
  5152. c.ServeSuccessJSON(map[string]interface{}{
  5153. "failed_code": -10,
  5154. "msg": res2.ErrMsg,
  5155. })
  5156. }
  5157. } else {
  5158. c.ServeSuccessJSON(map[string]interface{}{
  5159. "his_info": his,
  5160. })
  5161. }
  5162. } else {
  5163. c.ServeSuccessJSON(map[string]interface{}{
  5164. "failed_code": -10,
  5165. "msg": res.ErrMsg,
  5166. })
  5167. }
  5168. } else {
  5169. adminUser := c.GetAdminUserInfo()
  5170. errlog := &models.HisOrderError{
  5171. UserOrgId: adminUser.CurrentOrgId,
  5172. Ctime: time.Now().Unix(),
  5173. Mtime: time.Now().Unix(),
  5174. ErrMsg: res.ErrMsg,
  5175. Status: 1,
  5176. PatientId: id,
  5177. RecordTime: recordDateTime,
  5178. Stage: 1,
  5179. }
  5180. service.CreateErrMsgLog(errlog)
  5181. c.ServeSuccessJSON(map[string]interface{}{
  5182. "failed_code": -10,
  5183. "msg": res.ErrMsg,
  5184. })
  5185. return
  5186. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  5187. }
  5188. }
  5189. }
  5190. //上传明细----预结算----确认订单
  5191. func (c *HisApiController) GetUploadInfo() {
  5192. id, _ := c.GetInt64("id")
  5193. record_time := c.GetString("record_time")
  5194. his_patient_id, _ := c.GetInt64("his_patient_id")
  5195. order_id, _ := c.GetInt64("order_id")
  5196. pay_way, _ := c.GetInt64("pay_way")
  5197. pay_price, _ := c.GetFloat("pay_price")
  5198. pay_card_no := c.GetString("pay_card_no")
  5199. token := c.GetString("token")
  5200. discount_price, _ := c.GetFloat("discount_price")
  5201. preferential_price, _ := c.GetFloat("preferential_price")
  5202. reality_price, _ := c.GetFloat("reality_price")
  5203. found_price, _ := c.GetFloat("found_price")
  5204. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  5205. private_price, _ := c.GetFloat("private_price")
  5206. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  5207. admin_user_id, _ := c.GetInt64("admin_user_id")
  5208. fapiao_code := c.GetString("fapiao_code")
  5209. fapiao_number := c.GetString("fapiao_number")
  5210. diagnosis_id := c.GetString("diagnosis")
  5211. sick_type, _ := c.GetInt64("sick_type")
  5212. reg_type, _ := c.GetInt64("p_type")
  5213. begin_time := c.GetString("begin_time")
  5214. id_str := c.GetString("ids")
  5215. ids_arr := strings.Split(id_str, ",")
  5216. timeLayout := "2006-01-02"
  5217. loc, _ := time.LoadLocation("Local")
  5218. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  5219. if err != nil {
  5220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5221. return
  5222. }
  5223. recordDateTime := theTime.Unix()
  5224. adminUser := c.GetAdminUserInfo()
  5225. var tempOrder models.HisOrder
  5226. tempOrder, _ = service.GetHisOrderByID(order_id)
  5227. var prescriptions []*models.HisPrescription
  5228. var start_time int64
  5229. var end_time int64
  5230. //押金模块
  5231. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  5232. tmp_decimal := c.GetString("tmp_decimal")
  5233. var decimal float64 //本次使用的押金
  5234. var errmsg error
  5235. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  5236. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  5237. return
  5238. }
  5239. if len(tmp_decimal) > 0 {
  5240. if tmp_decimal[0] == 45 {
  5241. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  5242. return
  5243. }
  5244. }
  5245. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  5246. fmt.Println(errs)
  5247. decimal = tt
  5248. //if adminUser.CurrentOrgId == 10106{
  5249. // if len(fapiao_code) == 0{
  5250. // fapiao_code = "144072080589"
  5251. // }
  5252. // if len(fapiao_number) == 0{
  5253. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  5254. // if order.ID == 0{
  5255. // fapiao_number = "00001520"
  5256. // }else{
  5257. // //fapiao_code = "00001520"
  5258. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  5259. // var zero string
  5260. // if fpNumber >= 1000{
  5261. // zero = "0000" + strconv.Itoa(fpNumber)
  5262. // }else if fpNumber >= 10000{
  5263. // zero = "000" + strconv.Itoa(fpNumber)
  5264. // } else if fpNumber >= 100000{
  5265. // zero = "00" + strconv.Itoa(fpNumber)
  5266. // } else if fpNumber >= 1000000{
  5267. // zero = "0" + strconv.Itoa(fpNumber)
  5268. // }else {
  5269. // zero = strconv.Itoa(fpNumber)
  5270. // }
  5271. // fapiao_number = zero
  5272. // }
  5273. // }
  5274. //}
  5275. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5276. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5277. var patientPrescription models.HisPrescriptionInfo
  5278. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5279. if patientPrescription.ID == 0 {
  5280. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5281. }
  5282. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5283. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5284. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5285. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5286. var config []*models.HisXtDiagnoseConfig
  5287. for _, item := range diagnosis_ids {
  5288. id, _ := strconv.ParseInt(item, 10, 64)
  5289. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5290. config = append(config, &diagnosisConfig)
  5291. }
  5292. sickConfig, _ := service.FindSickById(sick_type)
  5293. //if tempOrder.ID == 0 {
  5294. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5295. //}
  5296. if tempOrder.ID == 0 {
  5297. var result string
  5298. var requestLog string
  5299. var res2 ResultSix
  5300. var ressix10265 ResultSix10265
  5301. if miConfig.MdtrtareaAdmvs == "421300" {
  5302. data := make(map[string]interface{})
  5303. client := &http.Client{}
  5304. data["psn_no"] = his.PsnNo
  5305. data["mdtrt_id"] = his.Number
  5306. data["opter"] = roles.UserName
  5307. data["org_name"] = miConfig.OrgName
  5308. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5309. data["doctor_id"] = doctor_info.DoctorNumber
  5310. data["doctor_name"] = doctor_info.UserName
  5311. data["department"] = department.Name
  5312. data["fixmedins_code"] = miConfig.Code
  5313. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5314. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5315. data["secret_key"] = miConfig.SecretKey
  5316. data["sick_code"] = sickConfig.CountryCode
  5317. data["sick_name"] = sickConfig.ClassName
  5318. data["dept"] = strconv.FormatInt(department.ID, 10)
  5319. data["config"] = config
  5320. data["begin_time"] = begin_time
  5321. bytesData, _ := json.Marshal(data)
  5322. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  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, &res2); err != nil {
  5342. utils.ErrorLog("解析失败:%v", err)
  5343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5344. return
  5345. }
  5346. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5347. //江苏地区国家医保医疗类别
  5348. //职工透析:医疗类别选特殊情况门诊9933
  5349. //居民血透门慢: 医疗类别选门诊慢病1402
  5350. //var med_type string
  5351. //if his.Insutype == "310" {
  5352. // if reg_type == 14 {
  5353. // med_type = "9933"
  5354. // } else if reg_type == 11 {
  5355. // med_type = "11"
  5356. //
  5357. // }
  5358. //} else if his.Insutype == "390" {
  5359. // if reg_type == 14 {
  5360. // med_type = "1402"
  5361. // } else if reg_type == 11 {
  5362. // med_type = "11"
  5363. // }
  5364. //}
  5365. data := make(map[string]interface{})
  5366. client := &http.Client{}
  5367. data["psn_no"] = his.PsnNo
  5368. data["mdtrt_id"] = his.Number
  5369. data["doctor"] = roles.UserName
  5370. data["department"] = department.Name
  5371. data["org_name"] = miConfig.OrgName
  5372. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5373. data["doctor_id"] = doctor_info.DoctorNumber
  5374. data["new_doctor_name"] = doctor_info.UserName
  5375. data["fixmedins_code"] = miConfig.Code
  5376. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5377. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5378. data["secret_key"] = miConfig.SecretKey
  5379. data["sick_code"] = sickConfig.CountryCode
  5380. data["sick_name"] = sickConfig.ClassName
  5381. data["url"] = miConfig.Url
  5382. data["ak"] = miConfig.AccessKey
  5383. data["begin_time"] = begin_time
  5384. data["cainfo"] = miConfig.Cainfo
  5385. data["dept"] = strconv.FormatInt(department.ID, 10)
  5386. data["config"] = config
  5387. bytesData, _ := json.Marshal(data)
  5388. var req *http.Request
  5389. if miConfig.MdtrtareaAdmvs == "320921" {
  5390. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5391. //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 +
  5392. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5393. } else {
  5394. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5395. }
  5396. resp, _ := client.Do(req)
  5397. defer resp.Body.Close()
  5398. body, ioErr := ioutil.ReadAll(resp.Body)
  5399. if ioErr != nil {
  5400. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. return
  5403. }
  5404. var respJSON map[string]interface{}
  5405. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5406. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5408. return
  5409. }
  5410. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5411. userJSONBytes, _ := json.Marshal(respJSON)
  5412. fmt.Println("log")
  5413. fmt.Println(string(userJSONBytes))
  5414. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5415. utils.ErrorLog("解析失败:%v", err)
  5416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5417. return
  5418. }
  5419. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5420. res2.Output = ressix10265.Output
  5421. res2.ErrMsg = ressix10265.ErrMsg
  5422. res2.Cainfo = ressix10265.Cainfo
  5423. res2.WarnMsg = ressix10265.WarnMsg
  5424. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5425. res2.Infcode = infocode
  5426. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5427. 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)
  5428. saveLog(result, requestLog, "2203", "上传就诊信息")
  5429. var respJSON2 map[string]interface{}
  5430. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5431. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5432. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5433. return
  5434. }
  5435. userJSONBytes2, _ := json.Marshal(respJSON2)
  5436. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5437. utils.ErrorLog("解析失败:%v", err)
  5438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5439. return
  5440. }
  5441. } else {
  5442. if miConfig.MdtrtareaAdmvs == "440781" { //
  5443. 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)
  5444. } else {
  5445. if miConfig.Code == "H15049901371" {
  5446. //赤峰地区国家医保医疗类别
  5447. //职工透析:医疗类别选特殊情况门诊990502
  5448. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5449. var med_type string
  5450. if his.Insutype == "390" {
  5451. if reg_type == 14 {
  5452. med_type = "9933"
  5453. } else if reg_type == 11 {
  5454. med_type = "11"
  5455. }
  5456. } else if his.Insutype == "310" {
  5457. if reg_type == 14 {
  5458. med_type = "990502"
  5459. } else if reg_type == 11 {
  5460. med_type = "11"
  5461. }
  5462. }
  5463. 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)
  5464. } else {
  5465. 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)
  5466. }
  5467. }
  5468. saveLog(result, requestLog, "2203", "上传就诊信息")
  5469. var respJSON2 map[string]interface{}
  5470. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5471. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5473. return
  5474. }
  5475. userJSONBytes2, _ := json.Marshal(respJSON2)
  5476. if miConfig.Code == "H15049901371" {
  5477. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5478. utils.ErrorLog("解析失败:%v", err)
  5479. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5480. return
  5481. }
  5482. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5483. res2.Output = ressix10265.Output
  5484. res2.ErrMsg = ressix10265.ErrMsg
  5485. res2.Cainfo = ressix10265.Cainfo
  5486. res2.WarnMsg = ressix10265.WarnMsg
  5487. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5488. res2.Infcode = infocode
  5489. } else {
  5490. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5491. utils.ErrorLog("解析失败:%v", err)
  5492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5493. return
  5494. }
  5495. }
  5496. }
  5497. if res2.Infcode != 0 {
  5498. adminUser := c.GetAdminUserInfo()
  5499. errlog := &models.HisOrderError{
  5500. UserOrgId: adminUser.CurrentOrgId,
  5501. Ctime: time.Now().Unix(),
  5502. Mtime: time.Now().Unix(),
  5503. ErrMsg: res2.ErrMsg,
  5504. Status: 1,
  5505. PatientId: id,
  5506. RecordTime: recordDateTime,
  5507. Stage: 3,
  5508. }
  5509. service.CreateErrMsgLog(errlog)
  5510. c.ServeSuccessJSON(map[string]interface{}{
  5511. "failed_code": -10,
  5512. "msg": res2.ErrMsg,
  5513. })
  5514. return
  5515. } else {
  5516. his.Diagnosis = diagnosis_id
  5517. his.SickType = sickConfig.ID
  5518. //var p_type int64
  5519. //if reg_type == 1111 || reg_type == 1112 {
  5520. // p_type = 11
  5521. //
  5522. //}
  5523. his.PType = fmt.Sprintf("%d", reg_type)
  5524. service.UpdateHisPatientThree(&his)
  5525. data := make(map[string]interface{})
  5526. if settle_accounts_type == 1 { //日结
  5527. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5528. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5529. } else {
  5530. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5531. }
  5532. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5533. data["pre"] = prescriptions
  5534. } else { //月结
  5535. start_time_str := c.GetString("start_time")
  5536. end_time_str := c.GetString("end_time")
  5537. timeLayout := "2006-01-02"
  5538. loc, _ := time.LoadLocation("Local")
  5539. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5540. if err != nil {
  5541. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5542. return
  5543. }
  5544. recordStartTime := theStartTime.Unix()
  5545. start_time = recordStartTime
  5546. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5547. if err != nil {
  5548. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5549. return
  5550. }
  5551. recordEndTime := theEndTime.Unix()
  5552. end_time = recordEndTime
  5553. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5554. data["pre"] = prescriptions
  5555. }
  5556. timestamp := time.Now().Unix()
  5557. tempTime := time.Unix(timestamp, 0)
  5558. timeFormat := tempTime.Format("20060102150405")
  5559. chrgBchno := rand.Intn(100000) + 10000
  5560. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5561. strconv.FormatInt(his.PatientId, 10)
  5562. client := &http.Client{}
  5563. data["psn_no"] = his.PsnNo
  5564. data["mdtrt_id"] = his.Number
  5565. data["chrg_bchno"] = chrg_bchno
  5566. data["org_name"] = miConfig.OrgName
  5567. data["doctor"] = doctor_info.UserName
  5568. data["doctor_id"] = doctor_info.DoctorNumber
  5569. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5570. data["fixmedins_code"] = miConfig.Code
  5571. data["opter"] = roles.UserName
  5572. data["dept_code"] = department.Number
  5573. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5574. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5575. data["secret_key"] = miConfig.SecretKey
  5576. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5577. data["url"] = miConfig.Url
  5578. data["ak"] = miConfig.AccessKey
  5579. data["new_doctor_name"] = patientPrescription.Doctor
  5580. data["diag_code"] = sickConfig.CountryCode
  5581. data["cainfo"] = miConfig.Cainfo
  5582. var ids []int64
  5583. for _, item := range prescriptions {
  5584. ids = append(ids, item.ID)
  5585. }
  5586. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5587. if config.IsOpen == 1 { //对接了医保,走医保流程
  5588. var res ResultFour
  5589. var resFour10265 ResultFour10265
  5590. if miConfig.MdtrtareaAdmvs == "421300" {
  5591. bytesData, _ := json.Marshal(data)
  5592. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5593. resp, _ := client.Do(req)
  5594. defer resp.Body.Close()
  5595. body, ioErr := ioutil.ReadAll(resp.Body)
  5596. if ioErr != nil {
  5597. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5599. return
  5600. }
  5601. var respJSON map[string]interface{}
  5602. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5603. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5604. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5605. return
  5606. }
  5607. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5608. userJSONBytes, _ := json.Marshal(respJSON)
  5609. fmt.Println("log")
  5610. fmt.Println(string(userJSONBytes))
  5611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5612. utils.ErrorLog("解析失败:%v", err)
  5613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5614. return
  5615. }
  5616. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5617. result3101 := Check3101(c, id, his_patient_id, admin_user_id, "2", record_time, prescriptions)
  5618. if result3101.Infcode == "0" {
  5619. if len(result3101.Output.Result) > 0 {
  5620. var errMsgs []string
  5621. for _, item := range result3101.Output.Result {
  5622. errMsgs = append(errMsgs, item.VolaCont)
  5623. }
  5624. c.ServeSuccessJSON(map[string]interface{}{
  5625. "failed_code": -10,
  5626. "msg": errMsgs,
  5627. })
  5628. return
  5629. }
  5630. }
  5631. bytesData, _ := json.Marshal(data)
  5632. var req *http.Request
  5633. if miConfig.MdtrtareaAdmvs == "320921" {
  5634. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5635. } else {
  5636. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5637. }
  5638. resp, _ := client.Do(req)
  5639. defer resp.Body.Close()
  5640. body, ioErr := ioutil.ReadAll(resp.Body)
  5641. if ioErr != nil {
  5642. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5644. return
  5645. }
  5646. var respJSON map[string]interface{}
  5647. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5648. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5650. return
  5651. }
  5652. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5653. userJSONBytes, _ := json.Marshal(respJSON)
  5654. fmt.Println("log")
  5655. fmt.Println(string(userJSONBytes))
  5656. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5657. utils.ErrorLog("解析失败:%v", err)
  5658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5659. return
  5660. }
  5661. res.InfRefmsgid = resFour10265.InfRefmsgid
  5662. res.Output = resFour10265.Output
  5663. res.ErrMsg = resFour10265.ErrMsg
  5664. res.Cainfo = resFour10265.Cainfo
  5665. res.WarnMsg = resFour10265.WarnMsg
  5666. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5667. res.Infcode = infocode
  5668. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5669. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  5670. var dat map[string]interface{}
  5671. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5672. fmt.Println(dat)
  5673. } else {
  5674. fmt.Println(err)
  5675. }
  5676. saveLog(result, request_log, "2204", "上传费用明细")
  5677. userJSONBytes, _ := json.Marshal(dat)
  5678. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5679. utils.ErrorLog("解析失败:%v", err)
  5680. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5681. return
  5682. }
  5683. res.InfRefmsgid = resFour10265.InfRefmsgid
  5684. res.Output = resFour10265.Output
  5685. res.ErrMsg = resFour10265.ErrMsg
  5686. res.Cainfo = resFour10265.Cainfo
  5687. res.WarnMsg = resFour10265.WarnMsg
  5688. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5689. res.Infcode = infocode
  5690. } else {
  5691. if miConfig.Code == "H15049901371" {
  5692. 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)
  5693. var dat map[string]interface{}
  5694. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5695. fmt.Println(dat)
  5696. } else {
  5697. fmt.Println(err)
  5698. }
  5699. saveLog(result, request_log, "2204", "上传费用明细")
  5700. userJSONBytes, _ := json.Marshal(dat)
  5701. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5702. utils.ErrorLog("解析失败:%v", err)
  5703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5704. return
  5705. }
  5706. res.InfRefmsgid = resFour10265.InfRefmsgid
  5707. res.Output = resFour10265.Output
  5708. res.ErrMsg = resFour10265.ErrMsg
  5709. res.Cainfo = resFour10265.Cainfo
  5710. res.WarnMsg = resFour10265.WarnMsg
  5711. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5712. res.Infcode = infocode
  5713. } else {
  5714. 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)
  5715. var dat map[string]interface{}
  5716. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5717. fmt.Println(dat)
  5718. } else {
  5719. fmt.Println(err)
  5720. }
  5721. saveLog(result, request_log, "2204", "上传费用明细")
  5722. userJSONBytes, _ := json.Marshal(dat)
  5723. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5724. utils.ErrorLog("解析失败:%v", err)
  5725. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5726. return
  5727. }
  5728. }
  5729. }
  5730. if res.Infcode == 0 {
  5731. order := &models.HisOrder{
  5732. UserOrgId: adminUser.CurrentOrgId,
  5733. HisPatientId: his.ID,
  5734. PatientId: his.PatientId,
  5735. SettleAccountsDate: recordDateTime,
  5736. MdtrtId: his.Number,
  5737. PsnNo: his.PsnNo,
  5738. MedType: strconv.FormatInt(reg_type, 10),
  5739. Ctime: time.Now().Unix(),
  5740. Mtime: time.Now().Unix(),
  5741. Status: 1,
  5742. Number: chrg_bchno,
  5743. Infcode: res.Infcode,
  5744. WarnMsg: res.WarnMsg,
  5745. Cainfo: res.Cainfo,
  5746. ErrMsg: res.ErrMsg,
  5747. RespondTime: res.RefmsgTime,
  5748. InfRefmsgid: res.InfRefmsgid,
  5749. OrderStatus: 1,
  5750. PayWay: pay_way,
  5751. PayPrice: pay_price,
  5752. PayCardNo: pay_card_no,
  5753. DiscountPrice: discount_price,
  5754. PreferentialPrice: preferential_price,
  5755. RealityPrice: reality_price,
  5756. FoundPrice: found_price,
  5757. MedicalInsurancePrice: medical_insurance_price,
  5758. PrivatePrice: private_price,
  5759. IsMedicineInsurance: 1,
  5760. SettleType: settle_accounts_type,
  5761. SettleStartTime: start_time,
  5762. SettleEndTime: end_time,
  5763. Creator: roles.AdminUserId,
  5764. Modify: roles.AdminUserId,
  5765. FaPiaoNumber: fapiao_number,
  5766. FaPiaoCode: fapiao_code,
  5767. PType: 2,
  5768. Diagnosis: diagnosis_id,
  5769. }
  5770. err = service.CreateOrder(order)
  5771. if err != nil {
  5772. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5773. return
  5774. }
  5775. for _, item := range res.Output.Result {
  5776. temp := strings.Split(item.FeedetlSn, "-")
  5777. var advice_id int64 = 0
  5778. var project_id int64 = 0
  5779. var types int64 = 0
  5780. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5781. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5782. if temp[1] == "1" {
  5783. advice_id = id
  5784. project_id = 0
  5785. } else if temp[1] == "2" {
  5786. advice_id = 0
  5787. project_id = id
  5788. }
  5789. info := &models.HisOrderInfo{
  5790. OrderNumber: order.Number,
  5791. FeedetlSn: item.FeedetlSn,
  5792. UploadDate: time.Now().Unix(),
  5793. AdviceId: advice_id,
  5794. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5795. Cnt: item.Cnt,
  5796. Pric: float64(item.Pric),
  5797. PatientId: his.PatientId,
  5798. PricUplmtAmt: item.PricUplmtAmt,
  5799. SelfpayProp: item.SelfpayProp,
  5800. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5801. OverlmtAmt: item.OverlmtAmt,
  5802. PreselfpayAmt: item.PreselfpayAmt,
  5803. BasMednFlag: item.BasMednFlag,
  5804. MedChrgitmType: item.MedChrgitmType,
  5805. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5806. Status: 1,
  5807. Memo: item.Memo,
  5808. Mtime: time.Now().Unix(),
  5809. InscpScpAmt: item.InscpScpAmt,
  5810. DrtReimFlag: item.DrtReimFlag,
  5811. Ctime: time.Now().Unix(),
  5812. ListSpItemFlag: item.ListSpItemFlag,
  5813. ChldMedcFlag: item.ChldMedcFlag,
  5814. LmtUsedFlag: item.LmtUsedFlag,
  5815. ChrgitmLv: item.ChrgitmLv,
  5816. UserOrgId: adminUser.CurrentOrgId,
  5817. HisPatientId: his.ID,
  5818. OrderId: order.ID,
  5819. ProjectId: project_id,
  5820. Type: types,
  5821. }
  5822. service.CreateOrderInfo(info)
  5823. }
  5824. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5825. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5826. var total float64
  5827. for _, item := range prescriptions {
  5828. if item.Type == 1 { //药品
  5829. for _, subItem := range item.HisDoctorAdviceInfo {
  5830. total = total + (subItem.Price * subItem.PrescribingNumber)
  5831. }
  5832. }
  5833. if item.Type == 2 { //项目
  5834. for _, subItem := range item.HisPrescriptionProject {
  5835. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5836. total = total + (subItem.Price * cnt)
  5837. }
  5838. }
  5839. }
  5840. for _, item := range prescriptions {
  5841. for _, subItem := range item.HisAdditionalCharge {
  5842. total = total + (subItem.Price * float64(subItem.Count))
  5843. }
  5844. }
  5845. var allTotal string
  5846. if adminUser.CurrentOrgId == 9919 {
  5847. allTotal = fmt.Sprintf("%.4f", total)
  5848. } else {
  5849. allTotal = fmt.Sprintf("%.4f", total)
  5850. }
  5851. if res.Infcode == 0 {
  5852. var rf []*ResultFive
  5853. json.Unmarshal([]byte(his.Iinfo), &rf)
  5854. chrg_bchno := chrg_bchno
  5855. cert_no := his.Certno
  5856. var insutypes []string
  5857. var insutype string
  5858. var is390 int = 0
  5859. var is310 int = 0
  5860. for _, item := range rf {
  5861. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5862. insutypes = append(insutypes, item.Insutype)
  5863. }
  5864. }
  5865. if len(insutypes) == 1 {
  5866. insutype = insutypes[0]
  5867. } else {
  5868. for _, i := range insutypes {
  5869. if i == "390" {
  5870. is390 = 1
  5871. }
  5872. if i == "310" {
  5873. is310 = 1
  5874. }
  5875. }
  5876. }
  5877. if is390 == 1 {
  5878. insutype = "390"
  5879. }
  5880. if is310 == 1 {
  5881. insutype = "310"
  5882. }
  5883. if len(insutypes) == 0 {
  5884. insutype = "310"
  5885. }
  5886. if len(insutypes) == 2 {
  5887. insutype = strconv.FormatInt(his.SocialType, 10)
  5888. }
  5889. insutype = strconv.FormatInt(his.SocialType, 10)
  5890. //insutype = "390"
  5891. if his.IdCardType == 1 {
  5892. // cert_no = his.MedicalInsuranceNumber
  5893. cert_no = his.Certno
  5894. } else {
  5895. cert_no = his.Certno
  5896. }
  5897. var res ResultSeven
  5898. var resSeven10265 ResultSeven10265
  5899. var src_resquest string
  5900. var result2 string
  5901. var acct_used_flag string
  5902. fmt.Println("pay_way")
  5903. fmt.Println(pay_way)
  5904. fmt.Println("pay_way")
  5905. if pay_way == 4 {
  5906. acct_used_flag = "1"
  5907. } else {
  5908. acct_used_flag = "0"
  5909. }
  5910. if miConfig.MdtrtareaAdmvs == "421300" {
  5911. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5912. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5913. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5914. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5915. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5916. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5917. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5918. resp, requestErr := http.Get(api)
  5919. if requestErr != nil {
  5920. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5921. return
  5922. }
  5923. body, ioErr := ioutil.ReadAll(resp.Body)
  5924. if ioErr != nil {
  5925. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5927. return
  5928. }
  5929. var respJSON map[string]interface{}
  5930. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5931. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5933. return
  5934. }
  5935. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5936. result, _ := json.Marshal(respJSON)
  5937. if miConfig.Code == "H15049901371" {
  5938. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5939. utils.ErrorLog("解析失败:%v", err)
  5940. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5941. return
  5942. }
  5943. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5944. res.Output = resSeven10265.Output
  5945. res.ErrMsg = resSeven10265.ErrMsg
  5946. res.Cainfo = resSeven10265.Cainfo
  5947. res.WarnMsg = resSeven10265.WarnMsg
  5948. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5949. res.Infcode = infocode
  5950. } else {
  5951. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5952. utils.ErrorLog("解析失败:%v", err)
  5953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5954. return
  5955. }
  5956. }
  5957. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5958. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5959. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5960. bas := strings.Split(psn_info.CardInfo, "|")
  5961. if his.IdCardType == 1 {
  5962. cert_no = bas[2]
  5963. } else if his.IdCardType == 3 {
  5964. cert_no = his.Certno
  5965. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5966. } else if his.IdCardType == 4 {
  5967. cert_no = his.Certno
  5968. psn_info.VerifyNumber = token
  5969. }
  5970. var api string
  5971. if miConfig.MdtrtareaAdmvs == "320921" {
  5972. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5973. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5974. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5975. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5976. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5977. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5978. "&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
  5979. } else {
  5980. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5981. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5982. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5983. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5984. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5985. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5986. "&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
  5987. }
  5988. resp, requestErr := http.Get(api)
  5989. if requestErr != nil {
  5990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5991. return
  5992. }
  5993. body, ioErr := ioutil.ReadAll(resp.Body)
  5994. if ioErr != nil {
  5995. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5996. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5997. return
  5998. }
  5999. var respJSON map[string]interface{}
  6000. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6001. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6002. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6003. return
  6004. }
  6005. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6006. result, _ := json.Marshal(respJSON)
  6007. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6008. utils.ErrorLog("解析失败:%v", err)
  6009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6010. return
  6011. }
  6012. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6013. res.Output = resSeven10265.Output
  6014. res.ErrMsg = resSeven10265.ErrMsg
  6015. res.Cainfo = resSeven10265.Cainfo
  6016. res.WarnMsg = resSeven10265.WarnMsg
  6017. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6018. res.Infcode = infocode
  6019. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6020. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6021. var cert_no string
  6022. if his.IdCardType == 1 {
  6023. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6024. }
  6025. fmt.Println(cert_no)
  6026. 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)
  6027. //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)
  6028. var dat map[string]interface{}
  6029. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6030. fmt.Println(dat)
  6031. } else {
  6032. fmt.Println(err)
  6033. }
  6034. saveLog(result2, src_resquest, "2207", "结算")
  6035. userJSONBytes, _ := json.Marshal(dat)
  6036. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6037. utils.ErrorLog("解析失败:%v", err)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6042. res.Output = resSeven10265.Output
  6043. res.ErrMsg = resSeven10265.ErrMsg
  6044. res.Cainfo = resSeven10265.Cainfo
  6045. res.WarnMsg = resSeven10265.WarnMsg
  6046. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6047. res.Infcode = infocode
  6048. } else {
  6049. if miConfig.Code == "H15049901371" {
  6050. //赤峰地区国家医保医疗类别
  6051. //职工透析:医疗类别选特殊情况门诊990502
  6052. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6053. var med_type string
  6054. if his.Insutype == "390" {
  6055. if reg_type == 14 {
  6056. med_type = "9933"
  6057. } else if reg_type == 11 {
  6058. med_type = "11"
  6059. }
  6060. } else if his.Insutype == "310" {
  6061. if reg_type == 14 {
  6062. med_type = "990502"
  6063. } else if reg_type == 11 {
  6064. med_type = "11"
  6065. }
  6066. }
  6067. 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)
  6068. } else {
  6069. 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)
  6070. }
  6071. //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)
  6072. var dat map[string]interface{}
  6073. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6074. fmt.Println(dat)
  6075. } else {
  6076. fmt.Println(err)
  6077. }
  6078. saveLog(result2, src_resquest, "2207", "结算")
  6079. userJSONBytes, _ := json.Marshal(dat)
  6080. if miConfig.Code == "H15049901371" {
  6081. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6082. utils.ErrorLog("解析失败:%v", err)
  6083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6084. return
  6085. }
  6086. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6087. res.Output = resSeven10265.Output
  6088. res.ErrMsg = resSeven10265.ErrMsg
  6089. res.Cainfo = resSeven10265.Cainfo
  6090. res.WarnMsg = resSeven10265.WarnMsg
  6091. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6092. res.Infcode = infocode
  6093. } else {
  6094. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6095. utils.ErrorLog("解析失败:%v", err)
  6096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6097. return
  6098. }
  6099. }
  6100. }
  6101. if res.Infcode != 0 {
  6102. errlog := &models.HisOrderError{
  6103. UserOrgId: adminUser.CurrentOrgId,
  6104. Ctime: time.Now().Unix(),
  6105. Mtime: time.Now().Unix(),
  6106. Number: chrg_bchno,
  6107. ErrMsg: res.ErrMsg,
  6108. Status: 1,
  6109. PatientId: id,
  6110. RecordTime: recordDateTime,
  6111. Stage: 6,
  6112. }
  6113. service.CreateErrMsgLog(errlog)
  6114. c.ServeSuccessJSON(map[string]interface{}{
  6115. "failed_code": -10,
  6116. "msg": res.ErrMsg,
  6117. })
  6118. return
  6119. } else {
  6120. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6121. order.OrderStatus = 2
  6122. order.Status = 1
  6123. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6124. order.SetlId = res.Output.Setlinfo.SetlID
  6125. order.PsnNo = res.Output.Setlinfo.PsnNo
  6126. order.PsnName = res.Output.Setlinfo.PsnName
  6127. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6128. order.Certno = res.Output.Setlinfo.Certno
  6129. order.Gend = res.Output.Setlinfo.Gend
  6130. order.Naty = res.Output.Setlinfo.Naty
  6131. order.Age = res.Output.Setlinfo.Age
  6132. order.Insutype = res.Output.Setlinfo.Insutype
  6133. order.PsnType = res.Output.Setlinfo.PsnType
  6134. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6135. order.SetlTime = res.Output.Setlinfo.SetlTime
  6136. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6137. if res.Output.Setlinfo.MedType == "140101" {
  6138. order.MedType = "14"
  6139. } else {
  6140. order.MedType = res.Output.Setlinfo.MedType
  6141. }
  6142. if reg_type == 1112 {
  6143. order.MedType = "1112"
  6144. }
  6145. if reg_type == 1111 {
  6146. order.MedType = "1111"
  6147. }
  6148. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6149. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6150. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6151. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6152. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6153. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6154. order.HifpPay = res.Output.Setlinfo.HifpPay
  6155. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6156. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6157. order.HifesPay = res.Output.Setlinfo.HifesPay
  6158. order.HifobPay = res.Output.Setlinfo.HifobPay
  6159. order.MafPay = res.Output.Setlinfo.MafPay
  6160. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6161. order.OthPay = res.Output.Setlinfo.OthPay
  6162. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6163. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6164. order.AcctPay = res.Output.Setlinfo.AcctPay
  6165. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6166. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6167. order.Balc = res.Output.Setlinfo.Balc
  6168. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6169. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6170. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6171. order.ClrType = res.Output.Setlinfo.ClrType
  6172. order.ClrWay = res.Output.Setlinfo.ClrWay
  6173. order.Creator = order.Creator
  6174. order.Modify = roles.AdminUserId
  6175. order.RequestLog = src_resquest
  6176. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6177. detailStr := string(setlDetail)
  6178. order.SetlDetail = detailStr
  6179. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6180. err = service.UpDateOrder(order)
  6181. if err == nil {
  6182. //判断是否使用了押金
  6183. if dec_way == "true" {
  6184. tmpstring := strconv.FormatInt(order.ID, 10)
  6185. order.Decimal = decimal
  6186. service.UpDateOrder(order)
  6187. //扣押金
  6188. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6189. if errmsg != nil {
  6190. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6191. return
  6192. }
  6193. }
  6194. c.ServeSuccessJSON(map[string]interface{}{
  6195. "msg": "结算成功",
  6196. })
  6197. } else {
  6198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6199. return
  6200. }
  6201. }
  6202. } else {
  6203. adminUser := c.GetAdminUserInfo()
  6204. errlog := &models.HisOrderError{
  6205. UserOrgId: adminUser.CurrentOrgId,
  6206. Ctime: time.Now().Unix(),
  6207. Mtime: time.Now().Unix(),
  6208. ErrMsg: res.ErrMsg,
  6209. Status: 1,
  6210. PatientId: id,
  6211. RecordTime: recordDateTime,
  6212. Stage: 4,
  6213. }
  6214. service.CreateErrMsgLog(errlog)
  6215. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6216. return
  6217. }
  6218. } else {
  6219. adminUser := c.GetAdminUserInfo()
  6220. errlog := &models.HisOrderError{
  6221. UserOrgId: adminUser.CurrentOrgId,
  6222. Ctime: time.Now().Unix(),
  6223. Mtime: time.Now().Unix(),
  6224. ErrMsg: res.ErrMsg,
  6225. Status: 1,
  6226. PatientId: id,
  6227. RecordTime: recordDateTime,
  6228. Stage: 4,
  6229. }
  6230. service.CreateErrMsgLog(errlog)
  6231. c.ServeSuccessJSON(map[string]interface{}{
  6232. "failed_code": -10,
  6233. "msg": res.ErrMsg,
  6234. })
  6235. return
  6236. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6237. //return
  6238. }
  6239. }
  6240. }
  6241. } else if tempOrder.ID > 0 {
  6242. if tempOrder.IsPre == 1 {
  6243. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  6244. var rf []*ResultFive
  6245. json.Unmarshal([]byte(his.Iinfo), &rf)
  6246. chrg_bchno := tempOrder.Number
  6247. cert_no := his.Certno
  6248. var insutypes []string
  6249. var insutype string
  6250. var is390 int = 0
  6251. var is310 int = 0
  6252. for _, item := range rf {
  6253. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  6254. insutypes = append(insutypes, item.Insutype)
  6255. }
  6256. }
  6257. if len(insutypes) == 1 {
  6258. insutype = insutypes[0]
  6259. } else {
  6260. for _, i := range insutypes {
  6261. if i == "390" {
  6262. is390 = 1
  6263. }
  6264. if i == "310" {
  6265. is310 = 1
  6266. }
  6267. }
  6268. }
  6269. if is390 == 1 {
  6270. insutype = "390"
  6271. }
  6272. if is310 == 1 {
  6273. insutype = "310"
  6274. }
  6275. if len(insutypes) == 0 {
  6276. insutype = "310"
  6277. }
  6278. if len(insutypes) == 2 {
  6279. insutype = strconv.FormatInt(his.SocialType, 64)
  6280. }
  6281. //insutype = "390"
  6282. if his.IdCardType == 1 {
  6283. // cert_no = his.MedicalInsuranceNumber
  6284. cert_no = his.Certno
  6285. } else {
  6286. cert_no = his.Certno
  6287. }
  6288. var res ResultSeven
  6289. var resSeven10265 ResultSeven10265
  6290. var src_resquest string
  6291. var result2 string
  6292. var acct_used_flag string
  6293. fmt.Println("pay_way")
  6294. fmt.Println(pay_way)
  6295. fmt.Println("pay_way")
  6296. if pay_way == 4 {
  6297. acct_used_flag = "1"
  6298. } else {
  6299. acct_used_flag = "0"
  6300. }
  6301. if miConfig.MdtrtareaAdmvs == "421300" {
  6302. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6303. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6304. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6305. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6306. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6307. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6308. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6309. resp, requestErr := http.Get(api)
  6310. if requestErr != nil {
  6311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6312. return
  6313. }
  6314. body, ioErr := ioutil.ReadAll(resp.Body)
  6315. if ioErr != nil {
  6316. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6318. return
  6319. }
  6320. var respJSON map[string]interface{}
  6321. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6322. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6324. return
  6325. }
  6326. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6327. result, _ := json.Marshal(respJSON)
  6328. fmt.Println("log")
  6329. fmt.Println(string(result))
  6330. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6331. utils.ErrorLog("解析失败:%v", err)
  6332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6333. return
  6334. }
  6335. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6336. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6337. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6338. //psn_info, _ := service.GetPsnByPatientId(id)
  6339. bas := strings.Split(psn_info.CardInfo, "|")
  6340. if his.IdCardType == 1 {
  6341. cert_no = bas[2]
  6342. } else {
  6343. cert_no = bas[1]
  6344. }
  6345. //江苏地区国家医保医疗类别
  6346. //职工透析:医疗类别选特殊情况门诊9933
  6347. //居民血透门慢: 医疗类别选门诊慢病1402
  6348. //var med_type string
  6349. //if his.Insutype == "310" {
  6350. // if reg_type == 14 {
  6351. // med_type = "9933"
  6352. // } else if reg_type == 11 {
  6353. // med_type = "11"
  6354. //
  6355. // }
  6356. //} else if his.Insutype == "390" {
  6357. // if reg_type == 14 {
  6358. // med_type = "1402"
  6359. // } else if reg_type == 11 {
  6360. // med_type = "11"
  6361. // }
  6362. //}
  6363. var api string
  6364. if miConfig.MdtrtareaAdmvs == "320921" {
  6365. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6366. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6367. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6368. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6369. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6370. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6371. "&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
  6372. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6373. } else {
  6374. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6375. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6376. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6377. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6378. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6379. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6380. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6381. "&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
  6382. }
  6383. resp, requestErr := http.Get(api)
  6384. if requestErr != nil {
  6385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6386. return
  6387. }
  6388. body, ioErr := ioutil.ReadAll(resp.Body)
  6389. if ioErr != nil {
  6390. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6392. return
  6393. }
  6394. var respJSON map[string]interface{}
  6395. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6396. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6398. return
  6399. }
  6400. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6401. result, _ := json.Marshal(respJSON)
  6402. fmt.Println("log")
  6403. fmt.Println(string(result))
  6404. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6405. utils.ErrorLog("解析失败:%v", err)
  6406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6407. return
  6408. }
  6409. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6410. res.Output = resSeven10265.Output
  6411. res.ErrMsg = resSeven10265.ErrMsg
  6412. res.Cainfo = resSeven10265.Cainfo
  6413. res.WarnMsg = resSeven10265.WarnMsg
  6414. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6415. res.Infcode = infocode
  6416. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6417. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6418. var cert_no string
  6419. if his.IdCardType == 1 {
  6420. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6421. }
  6422. fmt.Println(cert_no)
  6423. 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)
  6424. var dat map[string]interface{}
  6425. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6426. fmt.Println(dat)
  6427. } else {
  6428. fmt.Println(err)
  6429. }
  6430. saveLog(result2, src_resquest, "2207", "结算")
  6431. userJSONBytes, _ := json.Marshal(dat)
  6432. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6433. utils.ErrorLog("解析失败:%v", err)
  6434. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. return
  6436. }
  6437. } else {
  6438. var src_resquest string
  6439. if miConfig.Code == "H15049901371" {
  6440. //赤峰地区国家医保医疗类别
  6441. //职工透析:医疗类别选特殊情况门诊990502
  6442. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6443. var med_type string
  6444. if his.Insutype == "390" {
  6445. if reg_type == 14 {
  6446. med_type = "9933"
  6447. } else if reg_type == 11 {
  6448. med_type = "11"
  6449. }
  6450. } else if his.Insutype == "310" {
  6451. if reg_type == 14 {
  6452. med_type = "990502"
  6453. } else if reg_type == 11 {
  6454. med_type = "11"
  6455. }
  6456. }
  6457. 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)
  6458. } else {
  6459. 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)
  6460. }
  6461. var dat map[string]interface{}
  6462. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6463. fmt.Println(dat)
  6464. } else {
  6465. fmt.Println(err)
  6466. }
  6467. saveLog(result2, src_resquest, "2207", "结算")
  6468. userJSONBytes, _ := json.Marshal(dat)
  6469. if miConfig.Code == "H15049901371" {
  6470. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6471. utils.ErrorLog("解析失败:%v", err)
  6472. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6473. return
  6474. }
  6475. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6476. res.Output = resSeven10265.Output
  6477. res.ErrMsg = resSeven10265.ErrMsg
  6478. res.Cainfo = resSeven10265.Cainfo
  6479. res.WarnMsg = resSeven10265.WarnMsg
  6480. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6481. res.Infcode = infocode
  6482. } else {
  6483. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6484. utils.ErrorLog("解析失败:%v", err)
  6485. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6486. return
  6487. }
  6488. }
  6489. }
  6490. if res.Infcode != 0 {
  6491. errlog := &models.HisOrderError{
  6492. UserOrgId: adminUser.CurrentOrgId,
  6493. Ctime: time.Now().Unix(),
  6494. Mtime: time.Now().Unix(),
  6495. Number: chrg_bchno,
  6496. ErrMsg: res.ErrMsg,
  6497. Status: 1,
  6498. PatientId: id,
  6499. RecordTime: recordDateTime,
  6500. Stage: 6,
  6501. }
  6502. service.CreateErrMsgLog(errlog)
  6503. c.ServeSuccessJSON(map[string]interface{}{
  6504. "failed_code": -10,
  6505. "msg": res.ErrMsg,
  6506. })
  6507. return
  6508. } else {
  6509. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6510. order.OrderStatus = 2
  6511. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6512. order.SetlId = res.Output.Setlinfo.SetlID
  6513. order.PsnNo = res.Output.Setlinfo.PsnNo
  6514. order.PsnName = res.Output.Setlinfo.PsnName
  6515. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6516. order.Certno = res.Output.Setlinfo.Certno
  6517. order.Gend = res.Output.Setlinfo.Gend
  6518. order.Naty = res.Output.Setlinfo.Naty
  6519. order.Age = res.Output.Setlinfo.Age
  6520. order.Insutype = res.Output.Setlinfo.Insutype
  6521. order.PsnType = res.Output.Setlinfo.PsnType
  6522. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6523. order.SetlTime = res.Output.Setlinfo.SetlTime
  6524. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6525. //order.MedType = res.Output.Setlinfo.MedType
  6526. if reg_type == 1112 {
  6527. order.MedType = "1112"
  6528. }
  6529. if reg_type == 1111 {
  6530. order.MedType = "1111"
  6531. }
  6532. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6533. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6534. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6535. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6536. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6537. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6538. order.HifpPay = res.Output.Setlinfo.HifpPay
  6539. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6540. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6541. order.HifesPay = res.Output.Setlinfo.HifesPay
  6542. order.HifobPay = res.Output.Setlinfo.HifobPay
  6543. order.MafPay = res.Output.Setlinfo.MafPay
  6544. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6545. order.OthPay = res.Output.Setlinfo.OthPay
  6546. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6547. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6548. order.AcctPay = res.Output.Setlinfo.AcctPay
  6549. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6550. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6551. order.Balc = res.Output.Setlinfo.Balc
  6552. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6553. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6554. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6555. order.ClrWay = res.Output.Setlinfo.ClrWay
  6556. order.Creator = order.Creator
  6557. order.Modify = roles.AdminUserId
  6558. order.RequestLog = src_resquest
  6559. order.Diagnosis = diagnosis_id
  6560. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6561. detailStr := string(setlDetail)
  6562. order.SetlDetail = detailStr
  6563. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6564. err = service.UpDateOrder(order)
  6565. if err == nil {
  6566. //判断是否使用了押金
  6567. if dec_way == "true" {
  6568. tmpstring := strconv.FormatInt(order.ID, 10)
  6569. //扣押金
  6570. order.Decimal = decimal
  6571. service.UpDateOrder(order)
  6572. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6573. if errmsg != nil {
  6574. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6575. return
  6576. }
  6577. }
  6578. c.ServeSuccessJSON(map[string]interface{}{
  6579. "msg": "结算成功",
  6580. })
  6581. } else {
  6582. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6583. return
  6584. }
  6585. }
  6586. }
  6587. }
  6588. }
  6589. //func (c *HisApiController) GetPreUploadInfo() {
  6590. // id, _ := c.GetInt64("id")
  6591. // record_time := c.GetString("record_time")
  6592. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6593. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6594. //
  6595. // timeLayout := "2006-01-02"
  6596. // loc, _ := time.LoadLocation("Local")
  6597. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6598. // if err != nil {
  6599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6600. // return
  6601. // }
  6602. // recordDateTime := theTime.Unix()
  6603. // adminUser := c.GetAdminUserInfo()
  6604. //
  6605. // var prescriptions []*models.HisPrescription
  6606. //
  6607. // var start_time int64
  6608. // var end_time int64
  6609. //
  6610. // data := make(map[string]interface{})
  6611. // if settle_accounts_type == 1 { //日结
  6612. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6613. // data["pre"] = prescriptions
  6614. //
  6615. // } else { //月结
  6616. // start_time_str := c.GetString("start_time")
  6617. // end_time_str := c.GetString("end_time")
  6618. // timeLayout := "2006-01-02"
  6619. // loc, _ := time.LoadLocation("Local")
  6620. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6621. // if err != nil {
  6622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6623. // return
  6624. // }
  6625. // recordStartTime := theStartTime.Unix()
  6626. // start_time = recordStartTime
  6627. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6628. // if err != nil {
  6629. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6630. // return
  6631. // }
  6632. // recordEndTime := theEndTime.Unix()
  6633. // end_time = recordEndTime
  6634. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6635. // data["pre"] = prescriptions
  6636. //
  6637. // }
  6638. //
  6639. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6640. //
  6641. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6642. // timestamp := time.Now().Unix()
  6643. // tempTime := time.Unix(timestamp, 0)
  6644. // timeFormat := tempTime.Format("20060102150405")
  6645. // chrgBchno := rand.Intn(100000) + 10000
  6646. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6647. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6648. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6649. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6650. // strconv.FormatInt(his.PatientId, 10)
  6651. // client := &http.Client{}
  6652. // data["psn_no"] = his.PsnNo
  6653. // data["mdtrt_id"] = his.Number
  6654. // data["chrg_bchno"] = chrg_bchno
  6655. // data["org_name"] = miConfig.OrgName
  6656. // data["doctor"] = roles.UserName
  6657. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6658. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6659. // data["fixmedins_code"] = miConfig.Code
  6660. // data["dept_code"] = department.Number
  6661. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6662. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6663. // data["secret_key"] = miConfig.SecretKey
  6664. // var ids []int64
  6665. //
  6666. // for _, item := range prescriptions {
  6667. // ids = append(ids, item.ID)
  6668. // }
  6669. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6670. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6671. // bytesData, _ := json.Marshal(data)
  6672. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6673. // resp, _ := client.Do(req)
  6674. // defer resp.Body.Close()
  6675. // body, ioErr := ioutil.ReadAll(resp.Body)
  6676. // if ioErr != nil {
  6677. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6678. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6679. // return
  6680. // }
  6681. // var respJSON map[string]interface{}
  6682. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6683. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6685. // return
  6686. // }
  6687. //
  6688. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6689. // userJSONBytes, _ := json.Marshal(respJSON)
  6690. // var res ResultFour
  6691. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6692. // utils.ErrorLog("解析失败:%v", err)
  6693. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. // return
  6695. // }
  6696. //
  6697. // if res.Infcode == 0 {
  6698. // order := &models.HisOrder{
  6699. // UserOrgId: adminUser.CurrentOrgId,
  6700. // HisPatientId: his.ID,
  6701. // PatientId: his.PatientId,
  6702. // SettleAccountsDate: recordDateTime,
  6703. // Ctime: time.Now().Unix(),
  6704. // Mtime: time.Now().Unix(),
  6705. // Status: 1,
  6706. // Number: chrg_bchno,
  6707. // Infcode: res.Infcode,
  6708. // WarnMsg: res.WarnMsg,
  6709. // Cainfo: res.Cainfo,
  6710. // ErrMsg: res.ErrMsg,
  6711. // RespondTime: res.RefmsgTime,
  6712. // InfRefmsgid: res.InfRefmsgid,
  6713. // OrderStatus: 1,
  6714. // IsMedicineInsurance: 1,
  6715. // SettleType: settle_accounts_type,
  6716. // SettleStartTime: start_time,
  6717. // SettleEndTime: end_time,
  6718. // Creator: roles.ID,
  6719. // Modify: roles.ID,
  6720. // PType: 2,
  6721. // }
  6722. // err = service.CreateOrder(order)
  6723. // if err != nil {
  6724. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6725. // return
  6726. // }
  6727. //
  6728. // for _, item := range res.Output.Result {
  6729. // temp := strings.Split(item.FeedetlSn, "-")
  6730. // var advice_id int64 = 0
  6731. // var project_id int64 = 0
  6732. // var types int64 = 0
  6733. //
  6734. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6735. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6736. //
  6737. // if temp[1] == "1" {
  6738. // advice_id = id
  6739. // project_id = 0
  6740. // } else if temp[1] == "2" {
  6741. // advice_id = 0
  6742. // project_id = id
  6743. // }
  6744. //
  6745. // info := &models.HisOrderInfo{
  6746. // OrderNumber: order.Number,
  6747. // FeedetlSn: item.FeedetlSn,
  6748. // UploadDate: time.Now().Unix(),
  6749. // AdviceId: advice_id,
  6750. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6751. // Cnt: item.Cnt,
  6752. // Pric: float64(item.Pric),
  6753. // PatientId: his.PatientId,
  6754. // PricUplmtAmt: item.PricUplmtAmt,
  6755. // SelfpayProp: item.SelfpayProp,
  6756. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6757. // OverlmtAmt: item.OverlmtAmt,
  6758. // PreselfpayAmt: item.PreselfpayAmt,
  6759. // BasMednFlag: item.BasMednFlag,
  6760. // MedChrgitmType: item.MedChrgitmType,
  6761. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6762. // Status: 1,
  6763. // Memo: item.Memo,
  6764. // Mtime: time.Now().Unix(),
  6765. // InscpScpAmt: item.InscpScpAmt,
  6766. // DrtReimFlag: item.DrtReimFlag,
  6767. // Ctime: time.Now().Unix(),
  6768. // ListSpItemFlag: item.ListSpItemFlag,
  6769. // ChldMedcFlag: item.ChldMedcFlag,
  6770. // LmtUsedFlag: item.LmtUsedFlag,
  6771. // ChrgitmLv: item.ChrgitmLv,
  6772. // UserOrgId: adminUser.CurrentOrgId,
  6773. // HisPatientId: his.ID,
  6774. // OrderId: order.ID,
  6775. // ProjectId: project_id,
  6776. // Type: types,
  6777. // }
  6778. // service.CreateOrderInfo(info)
  6779. //
  6780. // }
  6781. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6782. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6783. //
  6784. // var total float64
  6785. // for _, item := range prescriptions {
  6786. // if item.Type == 1 { //药品
  6787. // for _, subItem := range item.HisDoctorAdviceInfo {
  6788. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6789. // }
  6790. // }
  6791. // if item.Type == 2 { //项目
  6792. // for _, subItem := range item.HisPrescriptionProject {
  6793. // total = total + (subItem.Price * float64(subItem.Count))
  6794. // }
  6795. // }
  6796. // }
  6797. //
  6798. // for _, item := range prescriptions {
  6799. // for _, subItem := range item.HisAdditionalCharge {
  6800. // total = total + (subItem.Price * float64(subItem.Count))
  6801. // }
  6802. // }
  6803. //
  6804. // allTotal := fmt.Sprintf("%.2f", total)
  6805. // if res.Infcode == 0 {
  6806. // var rf []*ResultFive
  6807. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6808. // psn_no := his.PsnNo
  6809. // mdtrt_id := his.Number
  6810. // chrg_bchno := chrg_bchno
  6811. // cert_no := his.Certno
  6812. // insutype := rf[0].Insutype
  6813. //
  6814. // if his.IdCardType == 1 {
  6815. // cert_no = his.MedicalInsuranceNumber
  6816. //
  6817. // } else {
  6818. //
  6819. // cert_no = his.Certno
  6820. //
  6821. // }
  6822. //
  6823. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6824. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6825. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6826. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6827. // resp, requestErr := http.Get(api)
  6828. // if requestErr != nil {
  6829. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6830. // return
  6831. // }
  6832. // defer resp.Body.Close()
  6833. // body, ioErr := ioutil.ReadAll(resp.Body)
  6834. // if ioErr != nil {
  6835. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6836. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6837. // return
  6838. // }
  6839. // var respJSON map[string]interface{}
  6840. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6841. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6842. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6843. // return
  6844. // }
  6845. // fmt.Println(respJSON)
  6846. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6847. // userJSONBytes, _ := json.Marshal(respJSON)
  6848. // var res ResultSeven
  6849. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6850. // utils.ErrorLog("解析失败:%v", err)
  6851. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6852. // return
  6853. // }
  6854. // if res.Infcode != 0 {
  6855. // errlog := &models.HisOrderError{
  6856. // UserOrgId: adminUser.CurrentOrgId,
  6857. // Ctime: time.Now().Unix(),
  6858. // Mtime: time.Now().Unix(),
  6859. // Number: chrg_bchno,
  6860. // ErrMsg: res.ErrMsg,
  6861. // Status: 1,
  6862. // PatientId: id,
  6863. // RecordTime: recordDateTime,
  6864. // Stage: 7,
  6865. // }
  6866. // service.CreateErrMsgLog(errlog)
  6867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6868. // return
  6869. // } else {
  6870. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6871. // order.OrderStatus = 1
  6872. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6873. // order.SetlId = res.Output.Setlinfo.SetlID
  6874. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6875. // order.PsnName = res.Output.Setlinfo.PsnName
  6876. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6877. // order.Certno = res.Output.Setlinfo.Certno
  6878. // order.Gend = res.Output.Setlinfo.Gend
  6879. // order.Naty = res.Output.Setlinfo.Naty
  6880. // order.Age = res.Output.Setlinfo.Age
  6881. // order.Insutype = res.Output.Setlinfo.Insutype
  6882. // order.PsnType = res.Output.Setlinfo.PsnType
  6883. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6884. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6885. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6886. // order.MedType = res.Output.Setlinfo.MedType
  6887. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6888. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6889. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6890. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6891. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6892. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6893. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6894. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6895. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6896. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6897. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6898. // order.MafPay = res.Output.Setlinfo.MafPay
  6899. // order.OthPay = res.Output.Setlinfo.OthPay
  6900. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6901. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6902. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6903. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6904. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6905. // order.Balc = res.Output.Setlinfo.Balc
  6906. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6907. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6908. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6909. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6910. // order.Creator = order.Creator
  6911. // order.Modify = roles.ID
  6912. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6913. // detailStr := string(setlDetail)
  6914. // order.SetlDetail = detailStr
  6915. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6916. // err = service.UpDateOrder(order)
  6917. // if err == nil {
  6918. // c.ServeSuccessJSON(map[string]interface{}{
  6919. // "msg": "预结算成功",
  6920. // })
  6921. // } else {
  6922. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6923. // return
  6924. // }
  6925. // }
  6926. // } else {
  6927. // adminUser := c.GetAdminUserInfo()
  6928. // errlog := &models.HisOrderError{
  6929. // UserOrgId: adminUser.CurrentOrgId,
  6930. // Ctime: time.Now().Unix(),
  6931. // Mtime: time.Now().Unix(),
  6932. // ErrMsg: res.ErrMsg,
  6933. // Status: 1,
  6934. // PatientId: id,
  6935. // RecordTime: recordDateTime,
  6936. // Stage: 4,
  6937. // }
  6938. // service.CreateErrMsgLog(errlog)
  6939. //
  6940. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6941. // return
  6942. // }
  6943. // } else {
  6944. // adminUser := c.GetAdminUserInfo()
  6945. // errlog := &models.HisOrderError{
  6946. // UserOrgId: adminUser.CurrentOrgId,
  6947. // Ctime: time.Now().Unix(),
  6948. // Mtime: time.Now().Unix(),
  6949. // ErrMsg: res.ErrMsg,
  6950. // Status: 1,
  6951. // PatientId: id,
  6952. // RecordTime: recordDateTime,
  6953. // Stage: 4,
  6954. // }
  6955. // service.CreateErrMsgLog(errlog)
  6956. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6957. // return
  6958. // }
  6959. //
  6960. // } else {
  6961. // var total float64
  6962. // for _, item := range prescriptions {
  6963. // if item.Type == 1 { //药品
  6964. // for _, subItem := range item.HisDoctorAdviceInfo {
  6965. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6966. // }
  6967. // }
  6968. // if item.Type == 2 { //项目
  6969. // for _, subItem := range item.HisPrescriptionProject {
  6970. // total = total + (subItem.Price * float64(subItem.Count))
  6971. // }
  6972. // }
  6973. //
  6974. // for _, subItem := range item.HisAdditionalCharge {
  6975. // total = total + (subItem.Price * float64(subItem.Count))
  6976. // }
  6977. // }
  6978. //
  6979. // allTotal := fmt.Sprintf("%.2f", total)
  6980. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6981. // order := &models.HisOrder{
  6982. // UserOrgId: adminUser.CurrentOrgId,
  6983. // HisPatientId: his.ID,
  6984. // PatientId: id,
  6985. // SettleAccountsDate: recordDateTime,
  6986. // Ctime: time.Now().Unix(),
  6987. // Mtime: time.Now().Unix(),
  6988. // Status: 1,
  6989. // OrderStatus: 2,
  6990. // Number: chrg_bchno,
  6991. // MedfeeSumamt: totals,
  6992. // }
  6993. // err = service.CreateOrder(order)
  6994. // if err != nil {
  6995. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6996. // return
  6997. // }
  6998. //
  6999. // var customs []*Custom
  7000. // for _, item := range prescriptions {
  7001. //
  7002. // if item.Type == 1 { //药品
  7003. // for _, subItem := range item.HisDoctorAdviceInfo {
  7004. // cus := &Custom{
  7005. // AdviceId: subItem.ID,
  7006. // ProjectId: 0,
  7007. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  7008. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  7009. // FeedetlSn: subItem.FeedetlSn,
  7010. // Price: fmt.Sprintf("%.2f", subItem.Price),
  7011. // MedListCodg: subItem.MedListCodg,
  7012. // Type: 1,
  7013. // }
  7014. // customs = append(customs, cus)
  7015. // }
  7016. // }
  7017. //
  7018. // if item.Type == 2 { //项目
  7019. // for _, subItem := range item.HisPrescriptionProject {
  7020. //
  7021. // cus := &Custom{
  7022. // AdviceId: 0,
  7023. // ProjectId: subItem.ID,
  7024. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  7025. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  7026. // FeedetlSn: subItem.FeedetlSn,
  7027. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  7028. // MedListCodg: subItem.MedListCodg,
  7029. // Type: 2,
  7030. // }
  7031. //
  7032. // customs = append(customs, cus)
  7033. // }
  7034. // }
  7035. //
  7036. // for _, item := range item.HisAdditionalCharge {
  7037. // cus := &Custom{
  7038. // ItemId: item.ID,
  7039. // AdviceId: 0,
  7040. // ProjectId: 0,
  7041. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  7042. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  7043. // FeedetlSn: item.FeedetlSn,
  7044. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  7045. // MedListCodg: item.XtHisAddtionConfig.Code,
  7046. // Type: 3,
  7047. // }
  7048. //
  7049. // customs = append(customs, cus)
  7050. // }
  7051. //
  7052. // }
  7053. //
  7054. // for _, item := range customs {
  7055. // var advice_id int64 = 0
  7056. // var project_id int64 = 0
  7057. // var item_id int64 = 0
  7058. //
  7059. // var types int64 = 0
  7060. //
  7061. // if item.Type == 1 {
  7062. // advice_id = item.AdviceId
  7063. // project_id = 0
  7064. // item_id = 0
  7065. // } else if item.Type == 2 {
  7066. // advice_id = 0
  7067. // item_id = 0
  7068. //
  7069. // project_id = item.ProjectId
  7070. // } else if item.Type == 3 {
  7071. // advice_id = 0
  7072. // item_id = item.ItemId
  7073. // project_id = 0
  7074. // }
  7075. //
  7076. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  7077. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  7078. // pric, _ := strconv.ParseFloat(item.Price, 32)
  7079. //
  7080. // info := &models.HisOrderInfo{
  7081. // OrderNumber: order.Number,
  7082. // UploadDate: time.Now().Unix(),
  7083. // AdviceId: advice_id,
  7084. // DetItemFeeSumamt: detItemFeeSumamt,
  7085. // Cnt: cut,
  7086. // Pric: pric,
  7087. // PatientId: id,
  7088. // Status: 1,
  7089. // Mtime: time.Now().Unix(),
  7090. // Ctime: time.Now().Unix(),
  7091. // UserOrgId: adminUser.CurrentOrgId,
  7092. // HisPatientId: his.ID,
  7093. // OrderId: order.ID,
  7094. // ProjectId: project_id,
  7095. // Type: types,
  7096. // ItemId: item_id,
  7097. // }
  7098. // service.CreateOrderInfo(info)
  7099. // }
  7100. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7101. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7102. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  7103. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7104. // if err == nil {
  7105. // c.ServeSuccessJSON(map[string]interface{}{
  7106. // "msg": "结算成功",
  7107. // })
  7108. // } else {
  7109. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7110. // return
  7111. // }
  7112. // }
  7113. //}
  7114. //上传明细-预结算-
  7115. func (c *HisApiController) GetPreUploadInfo() {
  7116. id, _ := c.GetInt64("id")
  7117. record_time := c.GetString("record_time")
  7118. his_patient_id, _ := c.GetInt64("his_patient_id")
  7119. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7120. admin_user_id, _ := c.GetInt64("admin_user_id")
  7121. diagnosis_id := c.GetString("diagnosis")
  7122. sick_type, _ := c.GetInt64("sick_type")
  7123. reg_type, _ := c.GetInt64("p_type")
  7124. begin_time := c.GetString("begin_time")
  7125. id_str := c.GetString("ids")
  7126. ids_arr := strings.Split(id_str, ",")
  7127. timeLayout := "2006-01-02"
  7128. loc, _ := time.LoadLocation("Local")
  7129. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7130. if err != nil {
  7131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7132. return
  7133. }
  7134. recordDateTime := theTime.Unix()
  7135. adminUser := c.GetAdminUserInfo()
  7136. diagnosis_ids := strings.Split(diagnosis_id, ",")
  7137. var config []*models.HisXtDiagnoseConfig
  7138. for _, item := range diagnosis_ids {
  7139. id, _ := strconv.ParseInt(item, 10, 64)
  7140. diagnosisConfig, _ := service.FindDiagnoseById(id)
  7141. config = append(config, &diagnosisConfig)
  7142. }
  7143. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  7144. sickConfig, _ := service.FindSickById(sick_type)
  7145. var prescriptions []*models.HisPrescription
  7146. var start_time int64
  7147. var end_time int64
  7148. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7149. fmt.Println(his_patient_id)
  7150. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7151. timestamp := time.Now().Unix()
  7152. tempTime := time.Unix(timestamp, 0)
  7153. timeFormat := tempTime.Format("20060102150405")
  7154. chrgBchno := rand.Intn(100000) + 10000
  7155. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  7156. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7157. var patientPrescription models.HisPrescriptionInfo
  7158. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  7159. if patientPrescription.ID == 0 {
  7160. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7161. }
  7162. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7163. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  7164. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  7165. strconv.FormatInt(his.PatientId, 10)
  7166. var res2 ResultSix
  7167. var resSix10265 ResultSix10265
  7168. var time_stamp string
  7169. if miConfig.MdtrtareaAdmvs == "421300" {
  7170. data := make(map[string]interface{})
  7171. client := &http.Client{}
  7172. data["psn_no"] = his.PsnNo
  7173. data["mdtrt_id"] = his.Number
  7174. data["department"] = department.Name
  7175. data["org_name"] = miConfig.OrgName
  7176. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7177. data["doctor_id"] = doctor_info.DoctorNumber
  7178. data["doctor_name"] = roles.UserName
  7179. data["fixmedins_code"] = miConfig.Code
  7180. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  7181. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7182. data["secret_key"] = miConfig.SecretKey
  7183. data["sick_code"] = sickConfig.CountryCode
  7184. data["sick_name"] = sickConfig.ClassName
  7185. data["begin_time"] = begin_time
  7186. data["dept"] = strconv.FormatInt(department.ID, 10)
  7187. data["config"] = config
  7188. data["opter"] = roles.UserName
  7189. fmt.Println(data)
  7190. bytesData, _ := json.Marshal(data)
  7191. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  7192. resp, _ := client.Do(req)
  7193. defer resp.Body.Close()
  7194. body, ioErr := ioutil.ReadAll(resp.Body)
  7195. if ioErr != nil {
  7196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. var respJSON map[string]interface{}
  7201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. return
  7205. }
  7206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7207. userJSONBytes, _ := json.Marshal(respJSON)
  7208. fmt.Println("log")
  7209. fmt.Println(string(userJSONBytes))
  7210. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7211. utils.ErrorLog("解析失败:%v", err)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. return
  7214. }
  7215. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7216. data := make(map[string]interface{})
  7217. client := &http.Client{}
  7218. data["psn_no"] = his.PsnNo
  7219. data["mdtrt_id"] = his.Number
  7220. data["doctor"] = roles.UserName
  7221. data["department"] = department.Name
  7222. data["org_name"] = miConfig.OrgName
  7223. data["med_type"] = strconv.FormatInt(reg_type, 10)
  7224. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  7225. data["fixmedins_code"] = miConfig.Code
  7226. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7227. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7228. data["secret_key"] = miConfig.SecretKey
  7229. data["sick_code"] = sickConfig.CountryCode
  7230. data["sick_name"] = sickConfig.ClassName
  7231. data["begin_time"] = begin_time
  7232. data["dept"] = strconv.FormatInt(department.ID, 10)
  7233. data["config"] = config
  7234. data["url"] = miConfig.Url
  7235. data["ak"] = miConfig.AccessKey
  7236. data["cainfo"] = miConfig.Cainfo
  7237. bytesData, _ := json.Marshal(data)
  7238. var req *http.Request
  7239. if miConfig.MdtrtareaAdmvs == "320921" {
  7240. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7241. //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 +
  7242. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  7243. } else {
  7244. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  7245. }
  7246. resp, _ := client.Do(req)
  7247. defer resp.Body.Close()
  7248. body, ioErr := ioutil.ReadAll(resp.Body)
  7249. if ioErr != nil {
  7250. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7251. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7252. return
  7253. }
  7254. var respJSON map[string]interface{}
  7255. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7256. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7257. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7258. return
  7259. }
  7260. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  7261. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  7262. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  7263. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7264. userJSONBytes, _ := json.Marshal(respJSON)
  7265. fmt.Println("log")
  7266. fmt.Println(string(userJSONBytes))
  7267. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7268. utils.ErrorLog("解析失败:%v", err)
  7269. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7270. return
  7271. }
  7272. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7273. res2.Output = resSix10265.Output
  7274. res2.ErrMsg = resSix10265.ErrMsg
  7275. res2.Cainfo = resSix10265.Cainfo
  7276. res2.WarnMsg = resSix10265.WarnMsg
  7277. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7278. res2.Infcode = infocode
  7279. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7280. 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)
  7281. saveLog(result, requestLog, "2203", "上传就诊信息")
  7282. var respJSON2 map[string]interface{}
  7283. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7284. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7286. return
  7287. }
  7288. userJSONBytes2, _ := json.Marshal(respJSON2)
  7289. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7290. utils.ErrorLog("解析失败:%v", err)
  7291. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7292. return
  7293. }
  7294. } else {
  7295. var result string
  7296. var requestLog string
  7297. if miConfig.MdtrtareaAdmvs == "440781" { //
  7298. 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)
  7299. } else {
  7300. if miConfig.Code == "H15049901371" {
  7301. //赤峰地区国家医保医疗类别
  7302. //职工透析:医疗类别选特殊情况门诊990502
  7303. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7304. var med_type string
  7305. if his.Insutype == "390" {
  7306. if reg_type == 14 {
  7307. med_type = "9933"
  7308. } else if reg_type == 11 {
  7309. med_type = "11"
  7310. }
  7311. } else if his.Insutype == "310" {
  7312. if reg_type == 14 {
  7313. med_type = "990502"
  7314. } else if reg_type == 11 {
  7315. med_type = "11"
  7316. }
  7317. }
  7318. 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)
  7319. } else {
  7320. 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)
  7321. }
  7322. saveLog(result, requestLog, "2203", "上传就诊信息")
  7323. var respJSON2 map[string]interface{}
  7324. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7325. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7326. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7327. return
  7328. }
  7329. userJSONBytes2, _ := json.Marshal(respJSON2)
  7330. if miConfig.Code == "H15049901371" {
  7331. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7332. utils.ErrorLog("解析失败:%v", err)
  7333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7334. return
  7335. }
  7336. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7337. res2.Output = resSix10265.Output
  7338. res2.ErrMsg = resSix10265.ErrMsg
  7339. res2.Cainfo = resSix10265.Cainfo
  7340. res2.WarnMsg = resSix10265.WarnMsg
  7341. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7342. res2.Infcode = infocode
  7343. } else {
  7344. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7345. utils.ErrorLog("解析失败:%v", err)
  7346. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7347. return
  7348. }
  7349. }
  7350. }
  7351. }
  7352. if res2.Infcode != 0 {
  7353. adminUser := c.GetAdminUserInfo()
  7354. errlog := &models.HisOrderError{
  7355. UserOrgId: adminUser.CurrentOrgId,
  7356. Ctime: time.Now().Unix(),
  7357. Mtime: time.Now().Unix(),
  7358. ErrMsg: res2.ErrMsg,
  7359. Status: 1,
  7360. PatientId: id,
  7361. RecordTime: recordDateTime,
  7362. Stage: 3,
  7363. }
  7364. service.CreateErrMsgLog(errlog)
  7365. c.ServeSuccessJSON(map[string]interface{}{
  7366. "failed_code": -10,
  7367. "msg": res2.ErrMsg,
  7368. })
  7369. return
  7370. } else {
  7371. his.Diagnosis = diagnosis_id
  7372. his.SickType = sickConfig.ID
  7373. his.PType = fmt.Sprintf("%d", reg_type)
  7374. service.UpdateHisPatientThree(&his)
  7375. data := make(map[string]interface{})
  7376. if settle_accounts_type == 1 { //日结
  7377. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7378. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7379. } else {
  7380. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7381. }
  7382. data["pre"] = prescriptions
  7383. } else { //月结
  7384. start_time_str := c.GetString("start_time")
  7385. end_time_str := c.GetString("end_time")
  7386. timeLayout := "2006-01-02"
  7387. loc, _ := time.LoadLocation("Local")
  7388. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7389. if err != nil {
  7390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7391. return
  7392. }
  7393. recordStartTime := theStartTime.Unix()
  7394. start_time = recordStartTime
  7395. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7396. if err != nil {
  7397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7398. return
  7399. }
  7400. recordEndTime := theEndTime.Unix()
  7401. end_time = recordEndTime
  7402. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7403. data["pre"] = prescriptions
  7404. }
  7405. client := &http.Client{}
  7406. data["psn_no"] = his.PsnNo
  7407. data["mdtrt_id"] = his.Number
  7408. data["chrg_bchno"] = chrg_bchno
  7409. data["org_name"] = miConfig.OrgName
  7410. data["doctor"] = roles.UserName
  7411. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7412. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7413. data["fixmedins_code"] = miConfig.Code
  7414. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7415. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7416. data["dept_code"] = "15"
  7417. } else {
  7418. data["dept_code"] = department.Number
  7419. }
  7420. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7421. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7422. data["secret_key"] = miConfig.SecretKey
  7423. data["url"] = miConfig.Url
  7424. data["ak"] = miConfig.AccessKey
  7425. data["new_doctor_name"] = patientPrescription.Doctor
  7426. data["diag_code"] = sickConfig.CountryCode
  7427. data["time_stamp"] = time_stamp
  7428. data["cainfo"] = miConfig.Cainfo
  7429. var ids []int64
  7430. for _, item := range prescriptions {
  7431. ids = append(ids, item.ID)
  7432. }
  7433. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7434. if config.IsOpen == 1 { //对接了医保,走医保流程
  7435. var res ResultFour
  7436. var resFour10265 ResultFour10265
  7437. if miConfig.MdtrtareaAdmvs == "421300" {
  7438. bytesData, _ := json.Marshal(data)
  7439. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7440. resp, _ := client.Do(req)
  7441. defer resp.Body.Close()
  7442. body, ioErr := ioutil.ReadAll(resp.Body)
  7443. if ioErr != nil {
  7444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7446. return
  7447. }
  7448. var respJSON map[string]interface{}
  7449. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7452. return
  7453. }
  7454. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7455. userJSONBytes, _ := json.Marshal(respJSON)
  7456. fmt.Println("log")
  7457. fmt.Println(string(userJSONBytes))
  7458. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7459. utils.ErrorLog("解析失败:%v", err)
  7460. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7461. return
  7462. }
  7463. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7464. bytesData, _ := json.Marshal(data)
  7465. var req *http.Request
  7466. if miConfig.MdtrtareaAdmvs == "320921" {
  7467. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7468. } else {
  7469. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7470. }
  7471. resp, _ := client.Do(req)
  7472. defer resp.Body.Close()
  7473. body, ioErr := ioutil.ReadAll(resp.Body)
  7474. if ioErr != nil {
  7475. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7476. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7477. return
  7478. }
  7479. var respJSON map[string]interface{}
  7480. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7481. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7483. return
  7484. }
  7485. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7486. userJSONBytes, _ := json.Marshal(respJSON)
  7487. fmt.Println("log")
  7488. fmt.Println(string(userJSONBytes))
  7489. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7490. utils.ErrorLog("解析失败:%v", err)
  7491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7492. return
  7493. }
  7494. res.InfRefmsgid = resFour10265.InfRefmsgid
  7495. res.Output = resFour10265.Output
  7496. res.ErrMsg = resFour10265.ErrMsg
  7497. res.Cainfo = resFour10265.Cainfo
  7498. res.WarnMsg = resFour10265.WarnMsg
  7499. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7500. res.Infcode = infocode
  7501. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7502. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, sickConfig.CountryCode)
  7503. var dat map[string]interface{}
  7504. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7505. fmt.Println(dat)
  7506. } else {
  7507. fmt.Println(err)
  7508. }
  7509. saveLog(result, request_log, "2204", "上传费用明细")
  7510. userJSONBytes, _ := json.Marshal(dat)
  7511. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7512. utils.ErrorLog("解析失败:%v", err)
  7513. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7514. return
  7515. }
  7516. } else {
  7517. if miConfig.Code == "H15049901371" {
  7518. 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)
  7519. var dat map[string]interface{}
  7520. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7521. fmt.Println(dat)
  7522. } else {
  7523. fmt.Println(err)
  7524. }
  7525. saveLog(result, request_log, "2204", "上传费用明细")
  7526. userJSONBytes, _ := json.Marshal(dat)
  7527. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7528. utils.ErrorLog("解析失败:%v", err)
  7529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7530. return
  7531. }
  7532. res.InfRefmsgid = resFour10265.InfRefmsgid
  7533. res.Output = resFour10265.Output
  7534. res.ErrMsg = resFour10265.ErrMsg
  7535. res.Cainfo = resFour10265.Cainfo
  7536. res.WarnMsg = resFour10265.WarnMsg
  7537. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7538. res.Infcode = infocode
  7539. } else {
  7540. 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)
  7541. var dat map[string]interface{}
  7542. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7543. fmt.Println(dat)
  7544. } else {
  7545. fmt.Println(err)
  7546. }
  7547. saveLog(result, request_log, "2204", "上传费用明细")
  7548. userJSONBytes, _ := json.Marshal(dat)
  7549. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7550. utils.ErrorLog("解析失败:%v", err)
  7551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7552. return
  7553. }
  7554. }
  7555. }
  7556. if res.Infcode == 0 {
  7557. order := &models.HisOrder{
  7558. UserOrgId: adminUser.CurrentOrgId,
  7559. HisPatientId: his.ID,
  7560. PatientId: his.PatientId,
  7561. SettleAccountsDate: recordDateTime,
  7562. Ctime: time.Now().Unix(),
  7563. Mtime: time.Now().Unix(),
  7564. MdtrtId: his.Number,
  7565. PsnNo: his.PsnNo,
  7566. MedType: strconv.FormatInt(reg_type, 10),
  7567. Status: 1,
  7568. Number: chrg_bchno,
  7569. Infcode: res.Infcode,
  7570. WarnMsg: res.WarnMsg,
  7571. Cainfo: res.Cainfo,
  7572. ErrMsg: res.ErrMsg,
  7573. RespondTime: res.RefmsgTime,
  7574. InfRefmsgid: res.InfRefmsgid,
  7575. OrderStatus: 1,
  7576. IsMedicineInsurance: 1,
  7577. SettleType: settle_accounts_type,
  7578. SettleStartTime: start_time,
  7579. SettleEndTime: end_time,
  7580. Creator: roles.AdminUserId,
  7581. Modify: roles.AdminUserId,
  7582. PType: 2,
  7583. Diagnosis: diagnosis_id,
  7584. }
  7585. err = service.CreateOrder(order)
  7586. if err != nil {
  7587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7588. return
  7589. }
  7590. for _, item := range res.Output.Result {
  7591. temp := strings.Split(item.FeedetlSn, "-")
  7592. var advice_id int64 = 0
  7593. var project_id int64 = 0
  7594. var types int64 = 0
  7595. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7596. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7597. if temp[1] == "1" {
  7598. advice_id = id
  7599. project_id = 0
  7600. } else if temp[1] == "2" {
  7601. advice_id = 0
  7602. project_id = id
  7603. }
  7604. info := &models.HisOrderInfo{
  7605. OrderNumber: order.Number,
  7606. FeedetlSn: item.FeedetlSn,
  7607. UploadDate: time.Now().Unix(),
  7608. AdviceId: advice_id,
  7609. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7610. Cnt: item.Cnt,
  7611. Pric: float64(item.Pric),
  7612. PatientId: his.PatientId,
  7613. PricUplmtAmt: item.PricUplmtAmt,
  7614. SelfpayProp: item.SelfpayProp,
  7615. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7616. OverlmtAmt: item.OverlmtAmt,
  7617. PreselfpayAmt: item.PreselfpayAmt,
  7618. BasMednFlag: item.BasMednFlag,
  7619. MedChrgitmType: item.MedChrgitmType,
  7620. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7621. Status: 1,
  7622. Memo: item.Memo,
  7623. Mtime: time.Now().Unix(),
  7624. InscpScpAmt: item.InscpScpAmt,
  7625. DrtReimFlag: item.DrtReimFlag,
  7626. Ctime: time.Now().Unix(),
  7627. ListSpItemFlag: item.ListSpItemFlag,
  7628. ChldMedcFlag: item.ChldMedcFlag,
  7629. LmtUsedFlag: item.LmtUsedFlag,
  7630. ChrgitmLv: item.ChrgitmLv,
  7631. UserOrgId: adminUser.CurrentOrgId,
  7632. HisPatientId: his.ID,
  7633. OrderId: order.ID,
  7634. ProjectId: project_id,
  7635. Type: types,
  7636. }
  7637. service.CreateOrderInfo(info)
  7638. }
  7639. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7640. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7641. var total float64
  7642. for _, item := range prescriptions {
  7643. if item.Type == 1 { //药品
  7644. for _, subItem := range item.HisDoctorAdviceInfo {
  7645. total = total + (subItem.Price * subItem.PrescribingNumber)
  7646. }
  7647. }
  7648. if item.Type == 2 { //项目
  7649. for _, subItem := range item.HisPrescriptionProject {
  7650. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7651. total = total + (subItem.Price * cnt)
  7652. }
  7653. }
  7654. }
  7655. for _, item := range prescriptions {
  7656. for _, subItem := range item.HisAdditionalCharge {
  7657. total = total + (subItem.Price * float64(subItem.Count))
  7658. }
  7659. }
  7660. allTotal := fmt.Sprintf("%.4f", total)
  7661. if res.Infcode == 0 {
  7662. var rf []*ResultFive
  7663. json.Unmarshal([]byte(his.Iinfo), &rf)
  7664. chrg_bchno := chrg_bchno
  7665. cert_no := his.Certno
  7666. var insutypes []string
  7667. var insutype string
  7668. var is390 int = 0
  7669. var is310 int = 0
  7670. for _, item := range rf {
  7671. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7672. insutypes = append(insutypes, item.Insutype)
  7673. }
  7674. }
  7675. if len(insutypes) == 1 {
  7676. insutype = insutypes[0]
  7677. } else {
  7678. for _, i := range insutypes {
  7679. if i == "390" {
  7680. is390 = 1
  7681. }
  7682. if i == "310" {
  7683. is310 = 1
  7684. }
  7685. }
  7686. }
  7687. if is390 == 1 {
  7688. insutype = "390"
  7689. }
  7690. if is310 == 1 {
  7691. insutype = "310"
  7692. }
  7693. if len(insutypes) == 0 {
  7694. insutype = "310"
  7695. }
  7696. if len(insutypes) == 2 {
  7697. insutype = strconv.FormatInt(his.SocialType, 64)
  7698. }
  7699. //insutype = "390"
  7700. if his.IdCardType == 1 {
  7701. cert_no = his.MedicalInsuranceNumber
  7702. } else {
  7703. cert_no = his.Certno
  7704. }
  7705. var res ResultSeven
  7706. var resSeven10265 ResultSeven10265
  7707. if miConfig.MdtrtareaAdmvs == "421300" {
  7708. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7709. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7710. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7711. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7712. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7713. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7714. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7715. resp, requestErr := http.Get(api)
  7716. if requestErr != nil {
  7717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7718. return
  7719. }
  7720. body, ioErr := ioutil.ReadAll(resp.Body)
  7721. if ioErr != nil {
  7722. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7724. return
  7725. }
  7726. var respJSON map[string]interface{}
  7727. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7728. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7729. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7730. return
  7731. }
  7732. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7733. result, _ := json.Marshal(respJSON)
  7734. fmt.Println("log")
  7735. fmt.Println(string(result))
  7736. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7737. utils.ErrorLog("解析失败:%v", err)
  7738. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7739. return
  7740. }
  7741. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7742. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7743. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7744. bas := strings.Split(psn_info.CardInfo, "|")
  7745. if his.IdCardType == 1 {
  7746. cert_no = bas[2]
  7747. } else {
  7748. cert_no = bas[1]
  7749. }
  7750. //江苏地区国家医保医疗类别
  7751. //职工透析:医疗类别选特殊情况门诊9933
  7752. //居民血透门慢: 医疗类别选门诊慢病1402
  7753. //var med_type string
  7754. //if his.Insutype == "310" {
  7755. // if reg_type == 14 {
  7756. // med_type = "9933"
  7757. // } else if reg_type == 11 {
  7758. // med_type = "11"
  7759. //
  7760. // }
  7761. //} else if his.Insutype == "390" {
  7762. // if reg_type == 14 {
  7763. // med_type = "1402"
  7764. // } else if reg_type == 11 {
  7765. // med_type = "11"
  7766. // }
  7767. //}
  7768. var api string
  7769. if miConfig.MdtrtareaAdmvs == "320921" {
  7770. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7771. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7772. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7773. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7774. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7775. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7776. "&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
  7777. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7778. } else {
  7779. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7780. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7781. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7782. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7783. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7784. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7785. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7786. "&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
  7787. }
  7788. resp, requestErr := http.Get(api)
  7789. if requestErr != nil {
  7790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7791. return
  7792. }
  7793. body, ioErr := ioutil.ReadAll(resp.Body)
  7794. if ioErr != nil {
  7795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7797. return
  7798. }
  7799. var respJSON map[string]interface{}
  7800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7803. return
  7804. }
  7805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7806. result, _ := json.Marshal(respJSON)
  7807. fmt.Println("log")
  7808. fmt.Println(string(result))
  7809. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7810. utils.ErrorLog("解析失败:%v", err)
  7811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7812. return
  7813. }
  7814. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7815. res.Output = resSeven10265.Output
  7816. res.ErrMsg = resSeven10265.ErrMsg
  7817. res.Cainfo = resSeven10265.Cainfo
  7818. res.WarnMsg = resSeven10265.WarnMsg
  7819. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7820. res.Infcode = infocode
  7821. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7822. 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)
  7823. var dat map[string]interface{}
  7824. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7825. fmt.Println(dat)
  7826. } else {
  7827. fmt.Println(err)
  7828. }
  7829. saveLog(result, request_log, "2206", "预结算")
  7830. userJSONBytes, _ := json.Marshal(dat)
  7831. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. } else {
  7837. var result string
  7838. var request_log string
  7839. if miConfig.Code == "H15049901371" {
  7840. //赤峰地区国家医保医疗类别
  7841. //职工透析:医疗类别选特殊情况门诊990502
  7842. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7843. var med_type string
  7844. if his.Insutype == "390" {
  7845. if reg_type == 14 {
  7846. med_type = "9933"
  7847. } else if reg_type == 11 {
  7848. med_type = "11"
  7849. }
  7850. } else if his.Insutype == "310" {
  7851. if reg_type == 14 {
  7852. med_type = "990502"
  7853. } else if reg_type == 11 {
  7854. med_type = "11"
  7855. }
  7856. }
  7857. 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)
  7858. } else {
  7859. 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)
  7860. }
  7861. var dat map[string]interface{}
  7862. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7863. fmt.Println(dat)
  7864. } else {
  7865. fmt.Println(err)
  7866. }
  7867. saveLog(result, request_log, "2206", "预结算")
  7868. //userJSONBytes, _ := json.Marshal(dat)
  7869. //
  7870. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7871. // utils.ErrorLog("解析失败:%v", err)
  7872. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7873. // return
  7874. //}
  7875. userJSONBytes, _ := json.Marshal(dat)
  7876. if miConfig.Code == "H15049901371" {
  7877. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7878. utils.ErrorLog("解析失败:%v", err)
  7879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7880. return
  7881. }
  7882. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7883. res.Output = resSeven10265.Output
  7884. res.ErrMsg = resSeven10265.ErrMsg
  7885. res.Cainfo = resSeven10265.Cainfo
  7886. res.WarnMsg = resSeven10265.WarnMsg
  7887. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7888. res.Infcode = infocode
  7889. } else {
  7890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7891. utils.ErrorLog("解析失败:%v", err)
  7892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7893. return
  7894. }
  7895. }
  7896. }
  7897. if res.Infcode != 0 {
  7898. errlog := &models.HisOrderError{
  7899. UserOrgId: adminUser.CurrentOrgId,
  7900. Ctime: time.Now().Unix(),
  7901. Mtime: time.Now().Unix(),
  7902. Number: chrg_bchno,
  7903. ErrMsg: res.ErrMsg,
  7904. Status: 1,
  7905. PatientId: id,
  7906. RecordTime: recordDateTime,
  7907. Stage: 20,
  7908. }
  7909. service.CreateErrMsgLog(errlog)
  7910. c.ServeSuccessJSON(map[string]interface{}{
  7911. "failed_code": -10,
  7912. "msg": res.ErrMsg,
  7913. })
  7914. return
  7915. } else {
  7916. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7917. order.OrderStatus = 1
  7918. order.IsPre = 1
  7919. order.Status = 1
  7920. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7921. order.SetlId = res.Output.Setlinfo.SetlID
  7922. order.PsnNo = res.Output.Setlinfo.PsnNo
  7923. order.PsnName = res.Output.Setlinfo.PsnName
  7924. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7925. order.Certno = res.Output.Setlinfo.Certno
  7926. order.Gend = res.Output.Setlinfo.Gend
  7927. order.Naty = res.Output.Setlinfo.Naty
  7928. order.Age = res.Output.Setlinfo.Age
  7929. order.Insutype = res.Output.Setlinfo.Insutype
  7930. order.PsnType = res.Output.Setlinfo.PsnType
  7931. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7932. order.SetlTime = res.Output.Setlinfo.SetlTime
  7933. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7934. if res.Output.Setlinfo.MedType == "140101" {
  7935. order.MedType = "14"
  7936. } else {
  7937. order.MedType = res.Output.Setlinfo.MedType
  7938. }
  7939. if reg_type == 1112 {
  7940. order.MedType = "1112"
  7941. }
  7942. if reg_type == 1111 {
  7943. order.MedType = "1111"
  7944. }
  7945. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7946. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7947. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7948. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7949. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7950. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7951. order.HifpPay = res.Output.Setlinfo.HifpPay
  7952. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7953. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7954. order.HifesPay = res.Output.Setlinfo.HifesPay
  7955. order.HifobPay = res.Output.Setlinfo.HifobPay
  7956. order.MafPay = res.Output.Setlinfo.MafPay
  7957. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7958. order.OthPay = res.Output.Setlinfo.OthPay
  7959. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7960. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7961. order.AcctPay = res.Output.Setlinfo.AcctPay
  7962. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7963. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7964. order.Balc = res.Output.Setlinfo.Balc
  7965. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7966. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7967. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7968. order.ClrWay = res.Output.Setlinfo.ClrWay
  7969. order.Creator = order.Creator
  7970. order.Modify = roles.AdminUserId
  7971. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7972. detailStr := string(setlDetail)
  7973. order.SetlDetail = detailStr
  7974. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7975. err = service.UpDateOrder(order)
  7976. if err == nil {
  7977. c.ServeSuccessJSON(map[string]interface{}{
  7978. "msg": "预结算成功",
  7979. })
  7980. } else {
  7981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7982. return
  7983. }
  7984. }
  7985. } else {
  7986. adminUser := c.GetAdminUserInfo()
  7987. errlog := &models.HisOrderError{
  7988. UserOrgId: adminUser.CurrentOrgId,
  7989. Ctime: time.Now().Unix(),
  7990. Mtime: time.Now().Unix(),
  7991. ErrMsg: res.ErrMsg,
  7992. Status: 1,
  7993. PatientId: id,
  7994. RecordTime: recordDateTime,
  7995. Stage: 4,
  7996. }
  7997. service.CreateErrMsgLog(errlog)
  7998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7999. return
  8000. }
  8001. } else {
  8002. adminUser := c.GetAdminUserInfo()
  8003. errlog := &models.HisOrderError{
  8004. UserOrgId: adminUser.CurrentOrgId,
  8005. Ctime: time.Now().Unix(),
  8006. Mtime: time.Now().Unix(),
  8007. ErrMsg: res.ErrMsg,
  8008. Status: 1,
  8009. PatientId: id,
  8010. RecordTime: recordDateTime,
  8011. Stage: 4,
  8012. }
  8013. service.CreateErrMsgLog(errlog)
  8014. c.ServeSuccessJSON(map[string]interface{}{
  8015. "failed_code": -10,
  8016. "msg": res.ErrMsg,
  8017. })
  8018. return
  8019. }
  8020. }
  8021. }
  8022. }
  8023. //退款
  8024. func (c *HisApiController) Refund() {
  8025. order_id, _ := c.GetInt64("order_id")
  8026. admin_user_id, _ := c.GetInt64("admin_user_id")
  8027. adminUser := c.GetAdminUserInfo()
  8028. var order models.HisOrder
  8029. order, _ = service.GetHisOrderByID(order_id)
  8030. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8031. if order.ID == 0 {
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8033. return
  8034. }
  8035. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8036. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8037. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8038. if config.IsOpen == 1 { //对接了医保,走医保流程
  8039. var res ResultSixteen
  8040. var resSixteen10265 ResultSixteen10265
  8041. var src_resquest string
  8042. var result string
  8043. if miConfig.MdtrtareaAdmvs == "421300" {
  8044. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  8045. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8046. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8047. resp3, requestErr3 := http.Get(api3)
  8048. if requestErr3 != nil {
  8049. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8050. return
  8051. }
  8052. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8053. if ioErr3 != nil {
  8054. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. var respJSON3 map[string]interface{}
  8059. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8060. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8061. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8062. return
  8063. }
  8064. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8065. userJSONBytes3, _ := json.Marshal(respJSON3)
  8066. fmt.Println("log")
  8067. fmt.Println(string(userJSONBytes3))
  8068. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  8069. utils.ErrorLog("解析失败:%v", err)
  8070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8071. return
  8072. }
  8073. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8074. var api3 string
  8075. if miConfig.MdtrtareaAdmvs == "320921" {
  8076. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8077. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8078. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8079. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8080. } else {
  8081. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8082. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  8083. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8084. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8085. }
  8086. resp3, requestErr3 := http.Get(api3)
  8087. if requestErr3 != nil {
  8088. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8089. return
  8090. }
  8091. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8092. if ioErr3 != nil {
  8093. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8095. return
  8096. }
  8097. var respJSON3 map[string]interface{}
  8098. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8099. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8101. return
  8102. }
  8103. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8104. userJSONBytes3, _ := json.Marshal(respJSON3)
  8105. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  8106. utils.ErrorLog("解析失败:%v", err)
  8107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8108. return
  8109. }
  8110. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8111. res.Output = resSixteen10265.Output
  8112. res.ErrMsg = resSixteen10265.ErrMsg
  8113. res.Cainfo = resSixteen10265.Cainfo
  8114. res.WarnMsg = resSixteen10265.WarnMsg
  8115. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8116. res.Infcode = infocode
  8117. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8118. 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)
  8119. var dat map[string]interface{}
  8120. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8121. fmt.Println(dat)
  8122. } else {
  8123. fmt.Println(err)
  8124. }
  8125. saveLog(result, src_resquest, "2208", "退费")
  8126. userJSONBytes, _ := json.Marshal(dat)
  8127. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8128. utils.ErrorLog("解析失败:%v", err)
  8129. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8130. return
  8131. }
  8132. } else {
  8133. if miConfig.Code == "H15049901371" {
  8134. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8135. var dat map[string]interface{}
  8136. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8137. fmt.Println(dat)
  8138. } else {
  8139. fmt.Println(err)
  8140. }
  8141. saveLog(result, src_resquest, "2208", "退费")
  8142. userJSONBytes, _ := json.Marshal(dat)
  8143. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  8144. utils.ErrorLog("解析失败:%v", err)
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  8149. res.Output = resSixteen10265.Output
  8150. res.ErrMsg = resSixteen10265.ErrMsg
  8151. res.Cainfo = resSixteen10265.Cainfo
  8152. res.WarnMsg = resSixteen10265.WarnMsg
  8153. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  8154. res.Infcode = infocode
  8155. } else {
  8156. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  8157. var dat map[string]interface{}
  8158. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8159. fmt.Println(dat)
  8160. } else {
  8161. fmt.Println(err)
  8162. }
  8163. saveLog(result, src_resquest, "2208", "退费")
  8164. userJSONBytes, _ := json.Marshal(dat)
  8165. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8166. utils.ErrorLog("解析失败:%v", err)
  8167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8168. return
  8169. }
  8170. }
  8171. }
  8172. if res.Infcode == 0 {
  8173. var res2 ResultSix
  8174. var resSix10265 ResultSix10265
  8175. if miConfig.MdtrtareaAdmvs == "421300" {
  8176. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8177. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8178. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8179. resp3, requestErr3 := http.Get(api3)
  8180. if requestErr3 != nil {
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8185. if ioErr3 != nil {
  8186. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. var respJSON3 map[string]interface{}
  8191. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8192. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8197. userJSONBytes3, _ := json.Marshal(respJSON3)
  8198. fmt.Println("log")
  8199. fmt.Println(string(userJSONBytes3))
  8200. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8201. utils.ErrorLog("解析失败:%v", err)
  8202. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8203. return
  8204. }
  8205. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8206. var api3 string
  8207. if miConfig.MdtrtareaAdmvs == "320921" {
  8208. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8209. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8210. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8211. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8212. } else {
  8213. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8214. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8215. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8216. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8217. }
  8218. resp3, requestErr3 := http.Get(api3)
  8219. if requestErr3 != nil {
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8224. if ioErr3 != nil {
  8225. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8227. return
  8228. }
  8229. var respJSON3 map[string]interface{}
  8230. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8231. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8233. return
  8234. }
  8235. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8236. userJSONBytes3, _ := json.Marshal(respJSON3)
  8237. fmt.Println("log")
  8238. fmt.Println(string(userJSONBytes3))
  8239. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8240. utils.ErrorLog("解析失败:%v", err)
  8241. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8242. return
  8243. }
  8244. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8245. res2.Output = resSix10265.Output
  8246. res2.ErrMsg = resSix10265.ErrMsg
  8247. res2.Cainfo = resSix10265.Cainfo
  8248. res2.WarnMsg = resSix10265.WarnMsg
  8249. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8250. res2.Infcode = infocode
  8251. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8252. 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)
  8253. var dat map[string]interface{}
  8254. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8255. fmt.Println(dat)
  8256. } else {
  8257. fmt.Println(err)
  8258. }
  8259. saveLog(result2, src_request, "2205", "撤销明细")
  8260. userJSONBytes, _ := json.Marshal(dat)
  8261. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8262. utils.ErrorLog("解析失败:%v", err)
  8263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8264. return
  8265. }
  8266. } else {
  8267. if miConfig.Code == "H15049901371" {
  8268. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8269. var dat map[string]interface{}
  8270. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8271. fmt.Println(dat)
  8272. } else {
  8273. fmt.Println(err)
  8274. }
  8275. saveLog(result2, src_request, "2205", "撤销明细")
  8276. userJSONBytes, _ := json.Marshal(dat)
  8277. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8278. utils.ErrorLog("解析失败:%v", err)
  8279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8280. return
  8281. }
  8282. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8283. res2.Output = resSix10265.Output
  8284. res2.ErrMsg = resSix10265.ErrMsg
  8285. res2.Cainfo = resSix10265.Cainfo
  8286. res2.WarnMsg = resSix10265.WarnMsg
  8287. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8288. res2.Infcode = infocode
  8289. } else {
  8290. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8291. var dat map[string]interface{}
  8292. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8293. fmt.Println(dat)
  8294. } else {
  8295. fmt.Println(err)
  8296. }
  8297. saveLog(result2, src_request, "2205", "撤销明细")
  8298. userJSONBytes, _ := json.Marshal(dat)
  8299. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8300. utils.ErrorLog("解析失败:%v", err)
  8301. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8302. return
  8303. }
  8304. }
  8305. }
  8306. if res2.Infcode == 0 {
  8307. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8308. if err == nil {
  8309. //当押金不为零时产生退费记录
  8310. if order.Decimal != 0 {
  8311. tmp := strconv.FormatInt(order.ID, 10)
  8312. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8313. if err != nil {
  8314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8315. return
  8316. }
  8317. }
  8318. c.ServeSuccessJSON(map[string]interface{}{
  8319. "msg": "退费成功",
  8320. })
  8321. } else {
  8322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8323. return
  8324. }
  8325. } else {
  8326. c.ServeSuccessJSON(map[string]interface{}{
  8327. "code": -10,
  8328. "msg": res2.ErrMsg,
  8329. })
  8330. }
  8331. } else {
  8332. c.ServeSuccessJSON(map[string]interface{}{
  8333. "code": -10,
  8334. "msg": res.ErrMsg,
  8335. })
  8336. }
  8337. }
  8338. }
  8339. func (c *HisApiController) RefundNumber() {
  8340. record_time := c.GetString("record_time")
  8341. //patient_id, _ := c.GetInt64("patient_id")
  8342. admin_user_id, _ := c.GetInt64("admin_user_id")
  8343. his_patient_id, _ := c.GetInt64("id")
  8344. timeLayout := "2006-01-02"
  8345. loc, _ := time.LoadLocation("Local")
  8346. adminUser := c.GetAdminUserInfo()
  8347. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8348. fmt.Println(err)
  8349. if err != nil {
  8350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8351. return
  8352. }
  8353. recordDateTime := theTime.Unix()
  8354. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8355. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8356. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8357. //order, _ := service.GetHisOrderByID(order_id)
  8358. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8359. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8360. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8361. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8362. if count > 0 {
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8364. return
  8365. }
  8366. if config.IsOpen == 1 { //对接了医保,走医保流程
  8367. var res2 ResultSix
  8368. var resSix10265 ResultSix10265
  8369. if miConfig.MdtrtareaAdmvs == "421300" {
  8370. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8371. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8372. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8373. resp3, requestErr3 := http.Get(api3)
  8374. if requestErr3 != nil {
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8379. if ioErr3 != nil {
  8380. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8381. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8382. return
  8383. }
  8384. var respJSON3 map[string]interface{}
  8385. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8386. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8388. return
  8389. }
  8390. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8391. userJSONBytes3, _ := json.Marshal(respJSON3)
  8392. fmt.Println("log")
  8393. fmt.Println(string(userJSONBytes3))
  8394. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8395. utils.ErrorLog("解析失败:%v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8400. var api3 string
  8401. if miConfig.MdtrtareaAdmvs == "320921" {
  8402. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8403. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8404. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8405. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8406. } else {
  8407. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8408. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8409. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8410. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8411. }
  8412. resp3, requestErr3 := http.Get(api3)
  8413. if requestErr3 != nil {
  8414. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8415. return
  8416. }
  8417. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8418. if ioErr3 != nil {
  8419. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8421. return
  8422. }
  8423. var respJSON3 map[string]interface{}
  8424. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8425. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8427. return
  8428. }
  8429. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8430. userJSONBytes3, _ := json.Marshal(respJSON3)
  8431. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8432. utils.ErrorLog("解析失败:%v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8437. res2.Output = resSix10265.Output
  8438. res2.ErrMsg = resSix10265.ErrMsg
  8439. res2.Cainfo = resSix10265.Cainfo
  8440. res2.WarnMsg = resSix10265.WarnMsg
  8441. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8442. res2.Infcode = infocode
  8443. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8444. 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)
  8445. var dat map[string]interface{}
  8446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8447. fmt.Println(dat)
  8448. } else {
  8449. fmt.Println(err)
  8450. }
  8451. saveLog(result, request, "2202", "退号")
  8452. userJSONBytes, _ := json.Marshal(dat)
  8453. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8454. utils.ErrorLog("解析失败:%v", err)
  8455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8456. return
  8457. }
  8458. } else {
  8459. var api3 string
  8460. if miConfig.Code == "H15049901371" {
  8461. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8462. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8463. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8464. } else {
  8465. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8466. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8467. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8468. }
  8469. resp3, requestErr3 := http.Get(api3)
  8470. if requestErr3 != nil {
  8471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8472. return
  8473. }
  8474. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8475. if ioErr3 != nil {
  8476. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8477. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8478. return
  8479. }
  8480. var respJSON3 map[string]interface{}
  8481. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8482. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8483. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8484. return
  8485. }
  8486. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8487. userJSONBytes3, _ := json.Marshal(respJSON3)
  8488. if miConfig.Code == "H15049901371" {
  8489. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8490. utils.ErrorLog("解析失败:%v", err)
  8491. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8492. return
  8493. }
  8494. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8495. res2.Output = resSix10265.Output
  8496. res2.ErrMsg = resSix10265.ErrMsg
  8497. res2.Cainfo = resSix10265.Cainfo
  8498. res2.WarnMsg = resSix10265.WarnMsg
  8499. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8500. res2.Infcode = infocode
  8501. } else {
  8502. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8503. utils.ErrorLog("解析失败:%v", err)
  8504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8505. return
  8506. }
  8507. }
  8508. }
  8509. if res2.Infcode == 0 {
  8510. if err == nil {
  8511. c.ServeSuccessJSON(map[string]interface{}{
  8512. "msg": "退号成功",
  8513. })
  8514. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8515. } else {
  8516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8517. return
  8518. }
  8519. } else {
  8520. c.ServeSuccessJSON(map[string]interface{}{
  8521. "code": -10,
  8522. "msg": res2.ErrMsg,
  8523. })
  8524. }
  8525. } else {
  8526. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8527. //if err == nil {
  8528. // c.ServeSuccessJSON(map[string]interface{}{
  8529. // "msg": "退费成功",
  8530. // })
  8531. //} else {
  8532. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8533. // return
  8534. //}
  8535. }
  8536. }
  8537. func (c *HisApiController) RefundDetail() {
  8538. order_id, _ := c.GetInt64("order_id")
  8539. admin_user_id, _ := c.GetInt64("admin_user_id")
  8540. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8541. number := c.GetString("number")
  8542. record_time := c.GetString("record_time")
  8543. patient_id, _ := c.GetInt64("patient_id")
  8544. //med_type, _ := c.GetInt64("med_type")
  8545. timeLayout := "2006-01-02"
  8546. loc, _ := time.LoadLocation("Local")
  8547. adminUser := c.GetAdminUserInfo()
  8548. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8549. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8550. fmt.Println(err)
  8551. if err != nil {
  8552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8553. return
  8554. }
  8555. recordDateTime := theTime.Unix()
  8556. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8557. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8558. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8559. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8560. var order models.HisOrder
  8561. order, _ = service.GetHisOrderByID(order_id)
  8562. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8563. if config.IsOpen == 1 { //对接了医保,走医保流程
  8564. var res2 ResultSix
  8565. if miConfig.MdtrtareaAdmvs == "421300" {
  8566. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8567. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8568. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8569. resp3, requestErr3 := http.Get(api3)
  8570. if requestErr3 != nil {
  8571. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8572. return
  8573. }
  8574. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8575. if ioErr3 != nil {
  8576. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8577. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8578. return
  8579. }
  8580. var respJSON3 map[string]interface{}
  8581. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8582. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8584. return
  8585. }
  8586. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8587. userJSONBytes3, _ := json.Marshal(respJSON3)
  8588. fmt.Println("log")
  8589. fmt.Println(string(userJSONBytes3))
  8590. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8591. utils.ErrorLog("解析失败:%v", err)
  8592. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8593. return
  8594. }
  8595. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8596. if err == nil {
  8597. c.ServeSuccessJSON(map[string]interface{}{
  8598. "msg": "撤销明细成功",
  8599. })
  8600. return
  8601. } else {
  8602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8603. return
  8604. }
  8605. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8606. var resSix10265 ResultSix10265
  8607. var api3 string
  8608. if miConfig.MdtrtareaAdmvs == "320921" {
  8609. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8610. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8611. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8612. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8613. } else {
  8614. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8615. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8616. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8617. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8618. }
  8619. resp3, requestErr3 := http.Get(api3)
  8620. if requestErr3 != nil {
  8621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8622. return
  8623. }
  8624. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8625. if ioErr3 != nil {
  8626. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8627. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8628. return
  8629. }
  8630. var respJSON3 map[string]interface{}
  8631. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8632. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8634. return
  8635. }
  8636. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8637. userJSONBytes3, _ := json.Marshal(respJSON3)
  8638. fmt.Println("log")
  8639. fmt.Println(string(userJSONBytes3))
  8640. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8641. utils.ErrorLog("解析失败:%v", err)
  8642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8643. return
  8644. }
  8645. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8646. res2.Output = resSix10265.Output
  8647. res2.ErrMsg = resSix10265.ErrMsg
  8648. res2.Cainfo = resSix10265.Cainfo
  8649. res2.WarnMsg = resSix10265.WarnMsg
  8650. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8651. res2.Infcode = infocode
  8652. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8653. if err == nil {
  8654. c.ServeSuccessJSON(map[string]interface{}{
  8655. "msg": "撤销明细成功",
  8656. })
  8657. return
  8658. } else {
  8659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8660. return
  8661. }
  8662. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8663. 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)
  8664. var dat map[string]interface{}
  8665. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8666. fmt.Println(dat)
  8667. } else {
  8668. fmt.Println(err)
  8669. }
  8670. saveLog(result2, src_request, "2205", "撤销明细")
  8671. userJSONBytes, _ := json.Marshal(dat)
  8672. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8673. utils.ErrorLog("解析失败:%v", err)
  8674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8675. return
  8676. }
  8677. if res2.Infcode == 0 {
  8678. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8679. if err == nil {
  8680. c.ServeSuccessJSON(map[string]interface{}{
  8681. "msg": "撤销明细成功",
  8682. })
  8683. return
  8684. } else {
  8685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8686. return
  8687. }
  8688. } else {
  8689. c.ServeSuccessJSON(map[string]interface{}{
  8690. "code": -10,
  8691. "msg": res2.ErrMsg,
  8692. })
  8693. }
  8694. } else {
  8695. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8696. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8697. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8698. resp2, requestErr2 := http.Get(api2)
  8699. if requestErr2 != nil {
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8704. if ioErr2 != nil {
  8705. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8707. return
  8708. }
  8709. var respJSON2 map[string]interface{}
  8710. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8711. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8713. return
  8714. }
  8715. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8716. if err == nil {
  8717. c.ServeSuccessJSON(map[string]interface{}{
  8718. "msg": "撤销明细成功",
  8719. })
  8720. return
  8721. } else {
  8722. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8723. return
  8724. }
  8725. }
  8726. } else {
  8727. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8728. if err == nil {
  8729. c.ServeSuccessJSON(map[string]interface{}{
  8730. "msg": "退费成功",
  8731. })
  8732. } else {
  8733. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8734. return
  8735. }
  8736. }
  8737. }
  8738. //对账
  8739. func (c *HisApiController) GetCheckAccount() {
  8740. start_time := c.GetString("start_time")
  8741. end_time := c.GetString("end_time")
  8742. insutype := c.GetString("insutype")
  8743. clr_type := c.GetString("clr_type")
  8744. clr_org := c.GetString("clr_optins")
  8745. admin_user_id, _ := c.GetInt64("admin_user_id")
  8746. adminUser := c.GetAdminUserInfo()
  8747. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8748. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8749. if len(clr_org) == 0 {
  8750. clr_org = miConfig.MdtrtareaAdmvs
  8751. }
  8752. timeLayout := "2006-01-02"
  8753. loc, _ := time.LoadLocation("Local")
  8754. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8755. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8756. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8757. fixmedins_setl_cnt := int64(len(orders))
  8758. var medfee_sumamt float64
  8759. var acct_pay float64
  8760. var fund_pay_sumamt float64
  8761. for _, item := range orders {
  8762. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8763. acct_pay = acct_pay + item.AcctPay
  8764. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8765. }
  8766. var user_name string
  8767. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8768. if role.ID == 0 {
  8769. user_name = "xxx"
  8770. } else {
  8771. user_name = role.UserName
  8772. }
  8773. var res ResultEight
  8774. var res10188 ResultEightFor10188
  8775. if config.IsOpen == 1 {
  8776. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8777. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8778. "insutype=" + insutype +
  8779. "&clr_type=" + clr_type +
  8780. "&setl_optins=" + clr_org +
  8781. "&stmt_begndate=" + start_time +
  8782. "&stm_enddate=" + end_time +
  8783. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8784. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8785. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8786. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8787. "&fixmedins_code=" + miConfig.Code +
  8788. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8789. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8790. "&secret_key=" + miConfig.SecretKey +
  8791. "&org_name=" + miConfig.OrgName +
  8792. "&doctor=" + user_name +
  8793. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8794. fmt.Println(api)
  8795. resp, requestErr := http.Get(api)
  8796. if requestErr != nil {
  8797. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8798. return
  8799. }
  8800. body, ioErr := ioutil.ReadAll(resp.Body)
  8801. fmt.Println(body)
  8802. if ioErr != nil {
  8803. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8805. return
  8806. }
  8807. var respJSON map[string]interface{}
  8808. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8809. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8811. return
  8812. }
  8813. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8814. userJSONBytes, _ := json.Marshal(respJSON)
  8815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8816. utils.ErrorLog("解析失败:%v", err)
  8817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8818. return
  8819. }
  8820. res.InfRefmsgid = res10188.InfRefmsgid
  8821. res.Output = res10188.Output
  8822. res.ErrMsg = res10188.ErrMsg
  8823. res.Cainfo = res10188.Cainfo
  8824. res.WarnMsg = res10188.WarnMsg
  8825. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8826. res.Infcode = infocode
  8827. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8828. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8829. "insutype=" + insutype +
  8830. "&clr_type=" + clr_type +
  8831. "&setl_optins=" + clr_org +
  8832. "&stmt_begndate=" + start_time +
  8833. "&stm_enddate=" + end_time +
  8834. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8835. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8836. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8837. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8838. "&fixmedins_code=" + miConfig.Code +
  8839. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8840. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8841. "&secret_key=" + miConfig.SecretKey +
  8842. "&org_name=" + miConfig.OrgName +
  8843. "&doctor=" + user_name
  8844. resp, requestErr := http.Get(api)
  8845. if requestErr != nil {
  8846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8847. return
  8848. }
  8849. body, ioErr := ioutil.ReadAll(resp.Body)
  8850. if ioErr != nil {
  8851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8853. return
  8854. }
  8855. var respJSON map[string]interface{}
  8856. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8859. return
  8860. }
  8861. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8862. result, _ := json.Marshal(respJSON)
  8863. fmt.Println("log")
  8864. fmt.Println(string(result))
  8865. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8866. utils.ErrorLog("解析失败:%v", err)
  8867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8868. return
  8869. }
  8870. res.InfRefmsgid = res10188.InfRefmsgid
  8871. res.Output = res10188.Output
  8872. res.ErrMsg = res10188.ErrMsg
  8873. res.Cainfo = res10188.Cainfo
  8874. res.WarnMsg = res10188.WarnMsg
  8875. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8876. res.Infcode = infocode
  8877. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8878. var baseParams models.BaseParams
  8879. baseParams.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  8880. baseParams.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  8881. baseParams.SecretKey = miConfig.SecretKey
  8882. baseParams.OrgName = miConfig.OrgName
  8883. baseParams.EncKey = miConfig.EncKey
  8884. baseParams.AppSecret = miConfig.AppSecret
  8885. baseParams.SignKey = miConfig.SignKey
  8886. baseParams.AppID = miConfig.Code
  8887. baseParams.RequestUrl = miConfig.Url
  8888. businessParams := models.BusinessParams{
  8889. Insutype: insutype,
  8890. ClrType: clr_type,
  8891. SetlOptins: clr_org,
  8892. StmtBegndate: start_time,
  8893. StmtEnddate: end_time,
  8894. MedfeeSumamt: medfee_sumamt,
  8895. FundPaySumamt: fund_pay_sumamt,
  8896. AcctPay: acct_pay,
  8897. FixmedinsSetlCnt: fixmedins_setl_cnt,
  8898. }
  8899. result, requestLog := service.FJyb3201(baseParams, businessParams)
  8900. fmt.Println(requestLog)
  8901. fmt.Println(result)
  8902. } else {
  8903. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8904. "insutype=" + insutype +
  8905. "&clr_type=" + clr_type +
  8906. "&setl_optins=" + clr_org +
  8907. "&stmt_begndate=" + start_time +
  8908. "&stm_enddate=" + end_time +
  8909. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8910. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8911. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8912. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8913. "&fixmedins_code=" + miConfig.Code +
  8914. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8915. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8916. "&secret_key=" + miConfig.SecretKey +
  8917. "&org_name=" + miConfig.OrgName +
  8918. "&doctor=" + user_name
  8919. fmt.Println(api)
  8920. resp, requestErr := http.Get(api)
  8921. if requestErr != nil {
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. body, ioErr := ioutil.ReadAll(resp.Body)
  8926. fmt.Println(body)
  8927. if ioErr != nil {
  8928. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8930. return
  8931. }
  8932. var respJSON map[string]interface{}
  8933. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8934. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8936. return
  8937. }
  8938. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8939. userJSONBytes, _ := json.Marshal(respJSON)
  8940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8941. utils.ErrorLog("解析失败:%v", err)
  8942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8943. return
  8944. }
  8945. }
  8946. if res.Infcode == 0 {
  8947. if res.Output.Stmtinfo.StmtRslt == "0" {
  8948. micc := &models.MedicalInsuranceCostCompare{
  8949. StartTime: startime.Unix(),
  8950. EndTime: endtime.Unix(),
  8951. Insutype: insutype,
  8952. CheckType: 1,
  8953. Num: fixmedins_setl_cnt,
  8954. Mtime: time.Now().Unix(),
  8955. Status: 1,
  8956. UserOrgId: adminUser.CurrentOrgId,
  8957. CostTotal: medfee_sumamt,
  8958. FuncTotal: fund_pay_sumamt,
  8959. PsnPay: acct_pay,
  8960. Creator: admin_user_id,
  8961. Ctime: time.Now().Unix(),
  8962. ClrType: clr_type,
  8963. }
  8964. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8965. if err == nil {
  8966. c.ServeSuccessJSON(map[string]interface{}{
  8967. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8968. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8969. })
  8970. } else {
  8971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8972. }
  8973. } else {
  8974. c.ServeSuccessJSON(map[string]interface{}{
  8975. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8976. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8977. })
  8978. }
  8979. } else {
  8980. c.ServeSuccessJSON(map[string]interface{}{
  8981. "code": -10,
  8982. "msg": res.ErrMsg,
  8983. })
  8984. }
  8985. }
  8986. }
  8987. func (c *HisApiController) Check310() {
  8988. adminUser := c.GetAdminUserInfo()
  8989. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8990. var user_name string
  8991. user_name = "高慧裕"
  8992. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8993. "insutype=" + "310" +
  8994. "&clr_type=" + "" +
  8995. "&setl_optins=" + "441202" +
  8996. "&stmt_begndate=" + "2022-03-01" +
  8997. "&stm_enddate=" + "2022-03-31" +
  8998. "&medfee_sumamt=" + "194930.12" +
  8999. "&fund_pay_sumamt=" + "188741.46" +
  9000. "&acct_pay=" + "0" +
  9001. "&fixmedins_setl_cnt=" + "452" +
  9002. "&fixmedins_code=" + miConfig.Code +
  9003. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9004. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9005. "&secret_key=" + miConfig.SecretKey +
  9006. "&org_name=" + miConfig.OrgName +
  9007. "&doctor=" + user_name
  9008. fmt.Println(api)
  9009. resp, requestErr := http.Get(api)
  9010. if requestErr != nil {
  9011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9012. return
  9013. }
  9014. body, ioErr := ioutil.ReadAll(resp.Body)
  9015. fmt.Println(body)
  9016. if ioErr != nil {
  9017. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9018. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9019. return
  9020. }
  9021. var respJSON map[string]interface{}
  9022. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9023. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9024. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9025. return
  9026. }
  9027. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9028. userJSONBytes, _ := json.Marshal(respJSON)
  9029. var res ResultEight
  9030. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9031. utils.ErrorLog("解析失败:%v", err)
  9032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9033. return
  9034. }
  9035. }
  9036. func (c *HisApiController) Check390() {
  9037. adminUser := c.GetAdminUserInfo()
  9038. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9039. var user_name string
  9040. user_name = "高慧裕"
  9041. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  9042. "insutype=" + "390" +
  9043. "&clr_type=" + "" +
  9044. "&setl_optins=" + "441202" +
  9045. "&stmt_begndate=" + "2022-03-01" +
  9046. "&stm_enddate=" + "2022-03-31" +
  9047. "&medfee_sumamt=" + "1068448.89" +
  9048. "&fund_pay_sumamt=" + "1014677.62" +
  9049. "&acct_pay=" + "0" +
  9050. "&fixmedins_setl_cnt=" + "1950" +
  9051. "&fixmedins_code=" + miConfig.Code +
  9052. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9053. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9054. "&secret_key=" + miConfig.SecretKey +
  9055. "&org_name=" + miConfig.OrgName +
  9056. "&doctor=" + user_name
  9057. fmt.Println(api)
  9058. resp, requestErr := http.Get(api)
  9059. if requestErr != nil {
  9060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9061. return
  9062. }
  9063. body, ioErr := ioutil.ReadAll(resp.Body)
  9064. fmt.Println(body)
  9065. if ioErr != nil {
  9066. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9068. return
  9069. }
  9070. var respJSON map[string]interface{}
  9071. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9072. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9073. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9074. return
  9075. }
  9076. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9077. userJSONBytes, _ := json.Marshal(respJSON)
  9078. var res ResultEight
  9079. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9080. utils.ErrorLog("解析失败:%v", err)
  9081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9082. return
  9083. }
  9084. }
  9085. //对账明细
  9086. func (c *HisApiController) GetCheckDetailAccount() {
  9087. start_time := c.GetString("start_time")
  9088. end_time := c.GetString("end_time")
  9089. admin_user_id, _ := c.GetInt64("admin_user_id")
  9090. adminUser := c.GetAdminUserInfo()
  9091. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9092. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9093. timeLayout := "2006-01-02"
  9094. loc, _ := time.LoadLocation("Local")
  9095. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  9096. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  9097. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  9098. rand.Seed(time.Now().UnixNano())
  9099. num := rand.Intn(30000)
  9100. Mkdir(miConfig.OrgName)
  9101. file := strconv.FormatInt(int64(num), 10)
  9102. file_name := file + ".txt"
  9103. zip_name := file + ".zip"
  9104. zip_path := miConfig.OrgName + "/" + zip_name
  9105. file_path := miConfig.OrgName + "/" + file_name
  9106. decimal.DivisionPrecision = 2
  9107. var medfee_sumamt float64
  9108. var psn_cash_pay float64
  9109. var fund_pay_sumamt float64
  9110. fixmedins_setl_cnt := int64(len(orders))
  9111. for _, item := range orders {
  9112. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  9113. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  9114. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  9115. }
  9116. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  9117. defer f.Close()
  9118. if err != nil {
  9119. fmt.Println(err.Error())
  9120. } else {
  9121. for _, item := range orders {
  9122. var refd_setl_flag string
  9123. if item.OrderStatus == 2 {
  9124. refd_setl_flag = "0"
  9125. var str string
  9126. str = item.SetlId + " " +
  9127. item.MdtrtId + " " +
  9128. item.PsnNo + " " +
  9129. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9130. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9131. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  9132. _, err = f.Write([]byte(str))
  9133. }
  9134. if item.OrderStatus == 3 {
  9135. var str string
  9136. str = item.SetlId + " " +
  9137. item.MdtrtId + " " +
  9138. item.PsnNo + " " +
  9139. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  9140. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  9141. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  9142. _, err = f.Write([]byte(str))
  9143. var str2 string
  9144. str2 = item.SetlId + " " +
  9145. item.MdtrtId + " " +
  9146. item.PsnNo + " " +
  9147. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  9148. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  9149. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  9150. _, err = f.Write([]byte(str2))
  9151. }
  9152. }
  9153. }
  9154. Zip(file_path, zip_path)
  9155. fmt.Println(ReadFile(zip_path))
  9156. fmt.Println(string(ReadFile(zip_path)))
  9157. if config.IsOpen == 1 {
  9158. var user_name string
  9159. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9160. if role.ID == 0 {
  9161. user_name = "管理员"
  9162. } else {
  9163. user_name = role.UserName
  9164. }
  9165. baseParams := models.BaseParams{
  9166. SecretKey: miConfig.SecretKey,
  9167. FixmedinsCode: miConfig.Code,
  9168. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9169. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9170. OrgName: miConfig.OrgName,
  9171. Doctor: user_name,
  9172. }
  9173. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  9174. var dat map[string]interface{}
  9175. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9176. fmt.Println(dat)
  9177. } else {
  9178. fmt.Println(err)
  9179. }
  9180. userJSONBytes, _ := json.Marshal(dat)
  9181. var res ResultNine
  9182. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9183. utils.ErrorLog("解析失败:%v", err)
  9184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9185. return
  9186. }
  9187. if res.Infcode == 0 {
  9188. fileNo := res.Output.FileQuryNo
  9189. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  9190. "file_qury_no=" + fileNo +
  9191. "&setl_optins=" + "定点医保中心" +
  9192. "&stmt_begndate=" + start_time +
  9193. "&stm_enddate=" + end_time +
  9194. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  9195. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  9196. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  9197. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  9198. "&fixmedins_code=" + miConfig.Code +
  9199. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  9200. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  9201. "&secret_key=" + miConfig.SecretKey +
  9202. "&org_name=" + miConfig.OrgName +
  9203. "&doctor=" + user_name
  9204. resp, requestErr := http.Get(api)
  9205. if requestErr != nil {
  9206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9207. return
  9208. }
  9209. body, ioErr := ioutil.ReadAll(resp.Body)
  9210. if ioErr != nil {
  9211. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9213. return
  9214. }
  9215. var respJSON map[string]interface{}
  9216. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9217. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9218. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9219. return
  9220. }
  9221. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9222. userJSONBytes, _ := json.Marshal(respJSON)
  9223. var res ResultTen
  9224. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9225. utils.ErrorLog("解析失败:%v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. if res.Infcode == 0 {
  9230. service.Gdyb9102(baseParams, zip_name, fileNo)
  9231. micc := &models.MedicalInsuranceCostCompare{
  9232. StartTime: startime.Unix(),
  9233. EndTime: endtime.Unix(),
  9234. Insutype: "0",
  9235. CheckType: 2,
  9236. Num: fixmedins_setl_cnt,
  9237. Mtime: time.Now().Unix(),
  9238. Status: 1,
  9239. UserOrgId: adminUser.CurrentOrgId,
  9240. CostTotal: medfee_sumamt,
  9241. FuncTotal: fund_pay_sumamt,
  9242. PsnPay: psn_cash_pay,
  9243. Creator: admin_user_id,
  9244. Ctime: time.Now().Unix(),
  9245. }
  9246. service.CreateMedicalInsuranceCostCompareRecord(micc)
  9247. c.ServeSuccessJSON(map[string]interface{}{
  9248. "msg": "明细对账成功",
  9249. })
  9250. }
  9251. } else {
  9252. }
  9253. }
  9254. }
  9255. type CustomOrderInfo struct {
  9256. Name string
  9257. Spec string
  9258. Unit string
  9259. Count float64
  9260. Price float64
  9261. Total float64
  9262. }
  9263. func (c *HisApiController) GetSettleAccounts() {
  9264. //id, _ := c.GetInt64("id")
  9265. //record_time := c.GetString("record_time")
  9266. order_id, _ := c.GetInt64("order_id")
  9267. admin_user_id, _ := c.GetInt64("admin_user_id")
  9268. //timeLayout := "2006-01-02"
  9269. //loc, _ := time.LoadLocation("Local")
  9270. //
  9271. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9272. //if err != nil {
  9273. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9274. // return
  9275. //}
  9276. //recordDateTime := theTime.Unix()
  9277. adminUser := c.GetAdminUserInfo()
  9278. order, _ := service.GetHisOrderByID(order_id)
  9279. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  9280. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  9281. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  9282. orderInfos = append(orderInfos, orderInfos_two...)
  9283. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  9284. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  9285. var diagnosis_ids []string
  9286. if his.ID > 0 {
  9287. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  9288. } else {
  9289. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  9290. }
  9291. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  9292. var dia_config []*models.HisXtDiagnoseConfig
  9293. var name string
  9294. for _, item := range diagnosis_ids {
  9295. id, _ := strconv.ParseInt(item, 10, 64)
  9296. diagnosisConfig, _ := service.FindDiagnoseById(id)
  9297. dia_config = append(dia_config, &diagnosisConfig)
  9298. if len(name) == 0 {
  9299. name = diagnosisConfig.ClassName
  9300. } else {
  9301. name = name + "," + diagnosisConfig.ClassName
  9302. }
  9303. }
  9304. var bedCostTotal float64 = 0 //床位总费
  9305. var bedCostSelfTotal float64 = 0 //床位自费
  9306. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9307. var operationCostTotal float64 = 0 //手术费
  9308. var operationCostSelfTotal float64 = 0 //手术费
  9309. var operationCostPartSelfTotal float64 = 0 //手术费
  9310. var otherCostTotal float64 = 0 //其他费用
  9311. var otherCostSelfTotal float64 = 0 //其他费用
  9312. var otherCostPartSelfTotal float64 = 0 //其他费用
  9313. var materialCostTotal float64 = 0 //材料费
  9314. var materialCostSelfTotal float64 = 0 //材料费
  9315. var materialCostPartSelfTotal float64 = 0 //材料费
  9316. var westernMedicineCostTotal float64 = 0 //西药费
  9317. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9318. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9319. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9320. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9321. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9322. var checkCostTotal float64 = 0 //检查费
  9323. var checkCostSelfTotal float64 = 0 //检查费
  9324. var checkCostPartSelfTotal float64 = 0 //检查费
  9325. var laboratoryCostTotal float64 = 0 //化验费
  9326. var laboratoryCostSelfTotal float64 = 0 //化验费
  9327. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9328. var treatCostTotal float64 = 0 //治疗费用
  9329. var treatCostSelfTotal float64 = 0 //治疗费用
  9330. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9331. decimal.DivisionPrecision = 2
  9332. for _, item := range orderInfos {
  9333. if item.MedChrgitmType == "01" { //床位费
  9334. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9335. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9336. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9337. }
  9338. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9339. if item.MedChrgitmType == "03" { //检查费
  9340. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9341. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9342. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9343. }
  9344. } else {
  9345. if item.MedChrgitmType == "03" { //检查费
  9346. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9347. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9348. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9349. }
  9350. }
  9351. if item.MedChrgitmType == "04" { //化验费
  9352. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9353. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9354. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9355. }
  9356. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9357. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9358. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9359. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9360. }
  9361. if item.MedChrgitmType == "06" { //手术费
  9362. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9363. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9364. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9365. }
  9366. if item.MedChrgitmType == "08" { //材料费
  9367. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9368. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9369. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9370. }
  9371. if item.MedChrgitmType == "09" { //西药费
  9372. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9373. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9374. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9375. }
  9376. if item.MedChrgitmType == "11" { //中成费
  9377. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9378. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9379. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9380. }
  9381. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9382. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9383. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9384. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9385. }
  9386. }
  9387. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9388. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9389. var user_name string
  9390. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9391. if role.ID == 0 {
  9392. user_name = "管理员"
  9393. } else {
  9394. user_name = role.UserName
  9395. }
  9396. baseParams := models.BaseParams{
  9397. SecretKey: miConfig.SecretKey,
  9398. FixmedinsCode: miConfig.Code,
  9399. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9400. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9401. OrgName: miConfig.OrgName,
  9402. Doctor: user_name,
  9403. }
  9404. businessParams := models.BusinessParams{
  9405. PsnNo: order.PsnNo,
  9406. MdtrtId: order.MdtrtId,
  9407. SetlId: order.SetlId,
  9408. }
  9409. var res ResultEleven
  9410. var resEleven10265 ResultEleven10265
  9411. if config.IsOpen == 1 {
  9412. if miConfig.MdtrtareaAdmvs == "421300" {
  9413. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9414. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9415. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9416. resp, requestErr := http.Get(api)
  9417. if requestErr != nil {
  9418. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9419. return
  9420. }
  9421. body, ioErr := ioutil.ReadAll(resp.Body)
  9422. if ioErr != nil {
  9423. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9425. return
  9426. }
  9427. var respJSON map[string]interface{}
  9428. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9429. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9430. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9431. return
  9432. }
  9433. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9434. result, _ := json.Marshal(respJSON)
  9435. fmt.Println("log")
  9436. fmt.Println(string(result))
  9437. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9438. utils.ErrorLog("解析失败:%v", err)
  9439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9440. return
  9441. }
  9442. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9443. var api string
  9444. if miConfig.MdtrtareaAdmvs == "320921" {
  9445. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9446. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9447. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9448. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9449. } else {
  9450. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9451. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9452. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9453. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9454. }
  9455. resp, requestErr := http.Get(api)
  9456. if requestErr != nil {
  9457. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9458. return
  9459. }
  9460. body, ioErr := ioutil.ReadAll(resp.Body)
  9461. if ioErr != nil {
  9462. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9463. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9464. return
  9465. }
  9466. var respJSON map[string]interface{}
  9467. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9468. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9469. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9470. return
  9471. }
  9472. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9473. result, _ := json.Marshal(respJSON)
  9474. fmt.Println("log")
  9475. fmt.Println(string(result))
  9476. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9477. utils.ErrorLog("解析失败:%v", err)
  9478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9479. return
  9480. }
  9481. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9482. res.Output = resEleven10265.Output
  9483. res.ErrMsg = resEleven10265.ErrMsg
  9484. res.Cainfo = resEleven10265.Cainfo
  9485. res.WarnMsg = resEleven10265.WarnMsg
  9486. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9487. res.Infcode = infocode
  9488. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9489. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9490. saveLog(result, requestLog, "5203", "结算单")
  9491. var dat map[string]interface{}
  9492. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9493. fmt.Println(dat)
  9494. } else {
  9495. fmt.Println(err)
  9496. }
  9497. userJSONBytes, _ := json.Marshal(dat)
  9498. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9499. utils.ErrorLog("解析失败:%v", err)
  9500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9501. return
  9502. }
  9503. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9504. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9505. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9506. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9507. resp, requestErr := http.Get(api)
  9508. if requestErr != nil {
  9509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9510. return
  9511. }
  9512. body, ioErr := ioutil.ReadAll(resp.Body)
  9513. if ioErr != nil {
  9514. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9516. return
  9517. }
  9518. var respJSON map[string]interface{}
  9519. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9520. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9521. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9522. return
  9523. }
  9524. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9525. result, _ := json.Marshal(respJSON)
  9526. fmt.Println("log")
  9527. fmt.Println(string(result))
  9528. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9529. utils.ErrorLog("解析失败:%v", err)
  9530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9531. return
  9532. }
  9533. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9534. res.Output = resEleven10265.Output
  9535. res.ErrMsg = resEleven10265.ErrMsg
  9536. res.Cainfo = resEleven10265.Cainfo
  9537. res.WarnMsg = resEleven10265.WarnMsg
  9538. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9539. res.Infcode = infocode
  9540. } else {
  9541. result := service.Gdyb5203(baseParams, businessParams)
  9542. //service.Gdyb5204(baseParams, businessParams)
  9543. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9544. var dat map[string]interface{}
  9545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9546. fmt.Println(dat)
  9547. } else {
  9548. fmt.Println(err)
  9549. }
  9550. userJSONBytes, _ := json.Marshal(dat)
  9551. if miConfig.Code == "H15049901371" {
  9552. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9553. utils.ErrorLog("解析失败:%v", err)
  9554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9555. return
  9556. }
  9557. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9558. res.Output = resEleven10265.Output
  9559. res.ErrMsg = resEleven10265.ErrMsg
  9560. res.Cainfo = resEleven10265.Cainfo
  9561. res.WarnMsg = resEleven10265.WarnMsg
  9562. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9563. res.Infcode = infocode
  9564. } else {
  9565. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9566. utils.ErrorLog("解析失败:%v", err)
  9567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9568. return
  9569. }
  9570. }
  9571. }
  9572. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9573. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9574. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9575. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9576. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9577. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9578. var doctor_name string
  9579. if roles.ID == 0 {
  9580. doctor_name = "管理员"
  9581. } else {
  9582. doctor_name = roles.UserName
  9583. }
  9584. yiliao_leibie := ""
  9585. switch order.MedType {
  9586. case "11":
  9587. yiliao_leibie = "普通门诊"
  9588. break
  9589. case "12":
  9590. yiliao_leibie = "门诊挂号"
  9591. break
  9592. case "13":
  9593. yiliao_leibie = "急诊"
  9594. break
  9595. case "14":
  9596. yiliao_leibie = "门诊特殊病"
  9597. break
  9598. case "15":
  9599. yiliao_leibie = "门诊统筹"
  9600. break
  9601. case "16":
  9602. yiliao_leibie = "门诊慢性病"
  9603. break
  9604. case "21":
  9605. yiliao_leibie = "普通住院"
  9606. break
  9607. }
  9608. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9609. if res.Infcode == 0 {
  9610. c.ServeSuccessJSON(map[string]interface{}{
  9611. "diagnosis": name,
  9612. "order_infos": orderInfos,
  9613. "number": order.MdtrtId,
  9614. "date": order.SettleAccountsDate,
  9615. "charge_admin": charge_admin,
  9616. "printor_admin": printor_admin,
  9617. "info": res.Output.Setlinfo,
  9618. "order": order,
  9619. "bedCostTotal": bedCostTotal,
  9620. "bedCostSelfTotal": bedCostSelfTotal,
  9621. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9622. "operationCostTotal": operationCostTotal,
  9623. "operationCostSelfTotal": operationCostSelfTotal,
  9624. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9625. "otherCostTotal": otherCostTotal,
  9626. "otherCostSelfTotal": otherCostSelfTotal,
  9627. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9628. "materialCostTotal": materialCostTotal,
  9629. "materialCostSelfTotal": materialCostSelfTotal,
  9630. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9631. "westernMedicineCostTotal": westernMedicineCostTotal,
  9632. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9633. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9634. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9635. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9636. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9637. "checkCostTotal": checkCostTotal,
  9638. "checkCostSelfTotal": checkCostSelfTotal,
  9639. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9640. "laboratoryCostTotal": laboratoryCostTotal,
  9641. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9642. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9643. "treatCostTotal": treatCostTotal,
  9644. "treatCostSelfTotal": treatCostSelfTotal,
  9645. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9646. "doctor_info": doctor_info,
  9647. "doctor_code": adminRole_two.DoctorCode,
  9648. "doctor_name": doctor_name,
  9649. "health_card_no": order.PsnNo,
  9650. "department": departments.Name,
  9651. "yiliao_leibie": yiliao_leibie,
  9652. "after_money": order.AccountPrice,
  9653. "patient": patient,
  9654. "org_name": miConfig.OrgName,
  9655. "org_code": miConfig.Code,
  9656. "order_number": order.Number,
  9657. "his_hospital": his_hospital,
  9658. "his": his,
  9659. "dia_config": dia_config,
  9660. //"check_order_info": cus_slice,
  9661. })
  9662. }
  9663. }
  9664. }
  9665. func (c *HisApiController) CheckTreatment() {
  9666. patient_id, _ := c.GetInt64("patient_id")
  9667. id_card_no := c.GetString("id_card_no")
  9668. insutype := c.GetString("insutype")
  9669. med_type := c.GetString("med_type")
  9670. admin_user_id, _ := c.GetInt64("admin_user_id")
  9671. adminUser := c.GetAdminUserInfo()
  9672. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9673. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9674. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9675. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9676. if miConfig.MdtrtareaAdmvs == "421300" {
  9677. var res ResultTwo
  9678. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9679. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9680. "&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)
  9681. resp, requestErr := http.Get(api)
  9682. if requestErr != nil {
  9683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9684. return
  9685. }
  9686. body, ioErr := ioutil.ReadAll(resp.Body)
  9687. if ioErr != nil {
  9688. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9689. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9690. return
  9691. }
  9692. var respJSON map[string]interface{}
  9693. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9694. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9695. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9696. return
  9697. }
  9698. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9699. result, _ := json.Marshal(respJSON)
  9700. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9701. utils.ErrorLog("解析失败:%v", err)
  9702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9703. return
  9704. }
  9705. if res.Infcode == 0 {
  9706. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9707. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9708. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9709. resp, requestErr := http.Get(api)
  9710. if requestErr != nil {
  9711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. return
  9713. }
  9714. body, ioErr := ioutil.ReadAll(resp.Body)
  9715. if ioErr != nil {
  9716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9718. return
  9719. }
  9720. var respJSON map[string]interface{}
  9721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9724. return
  9725. }
  9726. var res Result2001
  9727. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9728. result2, _ := json.Marshal(respJSON)
  9729. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9730. utils.ErrorLog("解析失败:%v", err)
  9731. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9732. return
  9733. }
  9734. if res.Infcode == 0 {
  9735. c.ServeSuccessJSON(map[string]interface{}{
  9736. "msg": res.Output.Trtinfo,
  9737. })
  9738. }
  9739. } else {
  9740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9741. return
  9742. }
  9743. } else {
  9744. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9745. var dat map[string]interface{}
  9746. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9747. fmt.Println(dat)
  9748. } else {
  9749. fmt.Println(err)
  9750. }
  9751. userJSONBytes, _ := json.Marshal(dat)
  9752. var res ResultTwo
  9753. var res10265 ResultTwo10265
  9754. if miConfig.Code == "H15049901371" {
  9755. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9756. utils.ErrorLog("解析失败:%v", err)
  9757. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9758. return
  9759. }
  9760. res.ErrMsg = res10265.ErrMsg
  9761. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9762. res.Infcode = infocode
  9763. res.Output = res10265.Output
  9764. res.InfRefmsgid = res10265.InfRefmsgid
  9765. } else {
  9766. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9767. utils.ErrorLog("解析失败:%v", err)
  9768. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9769. return
  9770. }
  9771. }
  9772. var user_name string
  9773. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9774. if role.ID == 0 {
  9775. user_name = "xxx"
  9776. } else {
  9777. user_name = role.UserName
  9778. }
  9779. baseParams := models.BaseParams{
  9780. SecretKey: miConfig.SecretKey,
  9781. FixmedinsCode: miConfig.Code,
  9782. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9783. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9784. OrgName: miConfig.OrgName,
  9785. Doctor: user_name,
  9786. }
  9787. if config.IsOpen == 1 {
  9788. if miConfig.Code == "H15049901371" {
  9789. if med_type == "14" {
  9790. if insutype == "390" {
  9791. med_type = "9933"
  9792. } else if insutype == "310" {
  9793. med_type = "990502"
  9794. }
  9795. } else if med_type == "11" {
  9796. med_type = "11"
  9797. }
  9798. }
  9799. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9800. var dat map[string]interface{}
  9801. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9802. fmt.Println(dat)
  9803. } else {
  9804. fmt.Println(err)
  9805. }
  9806. var res Result2001
  9807. var res10265 Result2001Org10265
  9808. if miConfig.Code == "H15049901371" {
  9809. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9810. utils.ErrorLog("解析失败:%v", err)
  9811. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9812. return
  9813. }
  9814. res.ErrMsg = res10265.ErrMsg
  9815. res.Output = res10265.Output
  9816. res.InfRefmsgid = res10265.InfRefmsgid
  9817. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9818. res.Infcode = infocode
  9819. } else {
  9820. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9821. utils.ErrorLog("解析失败:%v", err)
  9822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9823. return
  9824. }
  9825. }
  9826. if res.Infcode == 0 {
  9827. c.ServeSuccessJSON(map[string]interface{}{
  9828. "msg": res.Output.Trtinfo,
  9829. })
  9830. }
  9831. }
  9832. }
  9833. }
  9834. //func (c *HisApiController) PutRecord() {
  9835. // id, _ := c.GetInt64("id")
  9836. // record_time := c.GetString("record_time")
  9837. // timeLayout := "2006-01-02"
  9838. // loc, _ := time.LoadLocation("Local")
  9839. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9840. // if err != nil {
  9841. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9842. // return
  9843. // }
  9844. // recordDateTime := theTime.Unix()
  9845. //
  9846. // adminInfo := c.GetAdminUserInfo()
  9847. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9848. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9849. //
  9850. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9851. //
  9852. // fmt.Println(miConfig.SecretKey)
  9853. //
  9854. // if patient == nil {
  9855. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9856. // return
  9857. // }
  9858. // if len(patient.IdCardNo) == 0 {
  9859. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9860. // return
  9861. // }
  9862. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9863. // if config.IsOpen == 1 {
  9864. // 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
  9865. // resp, requestErr := http.Get(api)
  9866. // if requestErr != nil {
  9867. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9868. // return
  9869. // }
  9870. // defer resp.Body.Close()
  9871. // body, ioErr := ioutil.ReadAll(resp.Body)
  9872. // if ioErr != nil {
  9873. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9874. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9875. // return
  9876. // }
  9877. // var respJSON map[string]interface{}
  9878. //
  9879. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9880. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9881. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9882. // return
  9883. // }
  9884. //
  9885. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9886. // userJSONBytes, _ := json.Marshal(userJSON)
  9887. // var res ResultTwo
  9888. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9889. // utils.ErrorLog("解析失败:%v", err)
  9890. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9891. // return
  9892. // }
  9893. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9894. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9895. // infoStr := string(Iinfos)
  9896. // idetinfoStr := string(Idetinfos)
  9897. //
  9898. // if res.Infcode == 0 {
  9899. // his := models.VMHisPatient{
  9900. // Status: 1,
  9901. // Ctime: time.Now().Unix(),
  9902. // Mtime: time.Now().Unix(),
  9903. // PsnNo: res.Output.Baseinfo.PsnNo,
  9904. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9905. // Certno: res.Output.Baseinfo.Certno,
  9906. // PsnName: res.Output.Baseinfo.PsnName,
  9907. // Gend: res.Output.Baseinfo.Gend,
  9908. // Naty: res.Output.Baseinfo.Naty,
  9909. // Brdy: res.Output.Baseinfo.Brdy,
  9910. // Age: res.Output.Baseinfo.Age,
  9911. // Iinfo: infoStr,
  9912. // Idetinfo: idetinfoStr,
  9913. // PatientId: patient.ID,
  9914. // RecordDate: theTime.Unix(),
  9915. // UserOrgId: adminInfo.CurrentOrgId,
  9916. // AdminUserId: adminInfo.AdminUser.Id,
  9917. // IsReturn: 1,
  9918. // }
  9919. //
  9920. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9921. // //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")
  9922. // //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")
  9923. //
  9924. // //var dat map[string]interface{}
  9925. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9926. // // fmt.Println(dat)
  9927. // //} else {
  9928. // // fmt.Println(err)
  9929. // //}
  9930. //
  9931. // var dat2 map[string]interface{}
  9932. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9933. // fmt.Println(dat2)
  9934. // } else {
  9935. // fmt.Println(err)
  9936. // }
  9937. //
  9938. // } else {
  9939. // adminUser := c.GetAdminUserInfo()
  9940. // errlog := &models.HisOrderError{
  9941. // UserOrgId: adminUser.CurrentOrgId,
  9942. // Ctime: time.Now().Unix(),
  9943. // Mtime: time.Now().Unix(),
  9944. // ErrMsg: res.ErrMsg,
  9945. // Status: 1,
  9946. // PatientId: id,
  9947. // RecordTime: recordDateTime,
  9948. // Stage: 1,
  9949. // }
  9950. // service.CreateErrMsgLog(errlog)
  9951. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9952. // return
  9953. // }
  9954. // }
  9955. //
  9956. //}
  9957. //func (c *HisApiController) GetUploadDiag() {
  9958. // id, _ := c.GetInt64("id")
  9959. // record_time := c.GetString("record_time")
  9960. //
  9961. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9962. // sick_type, _ := c.GetInt64("sick_type")
  9963. // reg_type, _ := c.GetInt64("reg_type")
  9964. //
  9965. // timeLayout := "2006-01-02"
  9966. // loc, _ := time.LoadLocation("Local")
  9967. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9968. // if err != nil {
  9969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9970. // return
  9971. // }
  9972. //
  9973. // var patientPrescription models.HisPrescriptionInfo
  9974. // recordDateTime := theTime.Unix()
  9975. // adminInfo := c.GetAdminUserInfo()
  9976. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9977. //
  9978. // if patientPrescription.ID == 0 {
  9979. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9980. // }
  9981. //
  9982. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9983. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9984. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9985. // sickConfig, _ := service.FindSickById(sick_type)
  9986. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9987. //
  9988. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9989. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9990. // "&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 +
  9991. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9992. // resp2, requestErr2 := http.Get(api2)
  9993. // if requestErr2 != nil {
  9994. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9995. // return
  9996. // }
  9997. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9998. // if ioErr2 != nil {
  9999. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  10000. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. // return
  10002. // }
  10003. // var respJSON2 map[string]interface{}
  10004. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  10005. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. // return
  10008. // }
  10009. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10010. // userJSONBytes2, _ := json.Marshal(respJSON2)
  10011. //
  10012. // var res2 ResultSix
  10013. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10014. // utils.ErrorLog("解析失败:%v", err)
  10015. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10016. // return
  10017. // }
  10018. // if res2.Infcode != 0 {
  10019. // adminUser := c.GetAdminUserInfo()
  10020. // errlog := &models.HisOrderError{
  10021. // UserOrgId: adminUser.CurrentOrgId,
  10022. // Ctime: time.Now().Unix(),
  10023. // Mtime: time.Now().Unix(),
  10024. // ErrMsg: res2.ErrMsg,
  10025. // Status: 1,
  10026. // PatientId: id,
  10027. // RecordTime: recordDateTime,
  10028. // Stage: 3,
  10029. // }
  10030. // service.CreateErrMsgLog(errlog)
  10031. //
  10032. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  10033. // return
  10034. // }
  10035. //
  10036. // c.ServeSuccessJSON(map[string]interface{}{
  10037. // "msg": "上传成功",
  10038. // })
  10039. //
  10040. //}
  10041. type QueryResult struct {
  10042. ID int64
  10043. Name string
  10044. Code string
  10045. List_type_code string
  10046. }
  10047. func (c *HisApiController) GetCheckCode() {
  10048. ids_str := c.GetString("ids")
  10049. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10050. ids_arr := strings.Split(ids_str, ",")
  10051. var queryResult []QueryResult
  10052. ids := make([]int64, 0)
  10053. for _, item := range ids_arr {
  10054. id, _ := strconv.ParseInt(item, 10, 64)
  10055. ids = append(ids, id)
  10056. }
  10057. if record_type == 1 {
  10058. drugs, _ := service.GetBatchDrugList(ids)
  10059. for _, item := range drugs {
  10060. result := QueryResult{
  10061. ID: item.ID,
  10062. Name: item.DrugName,
  10063. Code: item.MedicalInsuranceNumber,
  10064. List_type_code: "101",
  10065. }
  10066. queryResult = append(queryResult, result)
  10067. }
  10068. } else if record_type == 2 {
  10069. goods, _ := service.GetBatchGoodInformationList(ids)
  10070. for _, item := range goods {
  10071. result := QueryResult{
  10072. ID: item.ID,
  10073. Name: item.GoodName,
  10074. Code: item.MedicalInsuranceNumber,
  10075. List_type_code: "301",
  10076. }
  10077. queryResult = append(queryResult, result)
  10078. }
  10079. } else if record_type == 3 {
  10080. projects, _ := service.GetBathchMyPorjecgList(ids)
  10081. for _, item := range projects {
  10082. result := QueryResult{
  10083. ID: item.ID,
  10084. Name: item.ProjectName,
  10085. Code: item.MedicalCode,
  10086. List_type_code: "201",
  10087. }
  10088. queryResult = append(queryResult, result)
  10089. }
  10090. }
  10091. admin_user_id, _ := c.GetInt64("admin_user_id")
  10092. adminUser := c.GetAdminUserInfo()
  10093. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10094. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10095. var user_name string
  10096. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10097. if role.ID == 0 {
  10098. user_name = "xxx"
  10099. } else {
  10100. user_name = role.UserName
  10101. }
  10102. baseParams := &models.BaseParams{
  10103. SecretKey: miConfig.SecretKey,
  10104. FixmedinsCode: miConfig.Code,
  10105. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10106. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10107. OrgName: miConfig.OrgName,
  10108. Doctor: user_name,
  10109. }
  10110. if config.IsOpen == 1 {
  10111. for _, item := range queryResult {
  10112. var result string
  10113. if record_type == 1 {
  10114. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10115. } else if record_type == 2 {
  10116. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10117. } else if record_type == 3 {
  10118. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  10119. }
  10120. var dat map[string]interface{}
  10121. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10122. fmt.Println(dat)
  10123. } else {
  10124. fmt.Println(err)
  10125. }
  10126. userJSONBytes, _ := json.Marshal(dat)
  10127. var res ResultSix
  10128. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10129. utils.ErrorLog("解析失败:%v", err)
  10130. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10131. return
  10132. }
  10133. if res.Infcode == 0 {
  10134. if record_type == 1 {
  10135. service.UpdateBaseDrugById(item.ID)
  10136. } else if record_type == 2 {
  10137. service.UpdateGoodInformaitonByDetail(item.ID)
  10138. } else if record_type == 3 {
  10139. service.UpdateProjectById(item.ID)
  10140. }
  10141. c.ServeSuccessJSON(map[string]interface{}{
  10142. "failed_code": 0,
  10143. "msg": "目录对照成功",
  10144. })
  10145. } else {
  10146. c.ServeSuccessJSON(map[string]interface{}{
  10147. "failed_code": -10,
  10148. "msg": res.ErrMsg,
  10149. })
  10150. }
  10151. }
  10152. }
  10153. }
  10154. func (c *HisApiController) UnCheckCode() {
  10155. ids_str := c.GetString("ids")
  10156. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  10157. admin_user_id, _ := c.GetInt64("admin_user_id")
  10158. ids_arr := strings.Split(ids_str, ",")
  10159. var queryResult []QueryResult
  10160. ids := make([]int64, 0)
  10161. for _, item := range ids_arr {
  10162. id, _ := strconv.ParseInt(item, 10, 64)
  10163. ids = append(ids, id)
  10164. }
  10165. if record_type == 1 {
  10166. drugs, _ := service.GetBatchDrugList(ids)
  10167. for _, item := range drugs {
  10168. result := QueryResult{
  10169. ID: item.ID,
  10170. Name: item.DrugName,
  10171. Code: item.MedicalInsuranceNumber,
  10172. List_type_code: "101",
  10173. }
  10174. queryResult = append(queryResult, result)
  10175. }
  10176. } else if record_type == 2 {
  10177. goods, _ := service.GetBatchGoodInformationList(ids)
  10178. for _, item := range goods {
  10179. result := QueryResult{
  10180. ID: item.ID,
  10181. Name: item.GoodName,
  10182. Code: item.MedicalInsuranceNumber,
  10183. List_type_code: "301",
  10184. }
  10185. queryResult = append(queryResult, result)
  10186. }
  10187. } else if record_type == 3 {
  10188. projects, _ := service.GetBathchMyPorjecgList(ids)
  10189. for _, item := range projects {
  10190. result := QueryResult{
  10191. ID: item.ID,
  10192. Name: item.ProjectName,
  10193. Code: item.MedicalCode,
  10194. List_type_code: "201",
  10195. }
  10196. queryResult = append(queryResult, result)
  10197. }
  10198. }
  10199. adminUser := c.GetAdminUserInfo()
  10200. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10201. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10202. var user_name string
  10203. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10204. if role.ID == 0 {
  10205. user_name = "xxx"
  10206. } else {
  10207. user_name = role.UserName
  10208. }
  10209. baseParams := &models.BaseParams{
  10210. SecretKey: miConfig.SecretKey,
  10211. FixmedinsCode: miConfig.Code,
  10212. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  10213. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  10214. OrgName: miConfig.OrgName,
  10215. Doctor: user_name,
  10216. }
  10217. if config.IsOpen == 1 {
  10218. for _, item := range queryResult {
  10219. var result string
  10220. if record_type == 1 {
  10221. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10222. } else if record_type == 2 {
  10223. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10224. } else if record_type == 3 {
  10225. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  10226. }
  10227. var dat2 map[string]interface{}
  10228. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  10229. fmt.Println(dat2)
  10230. } else {
  10231. fmt.Println(err)
  10232. }
  10233. userJSONBytes, _ := json.Marshal(dat2)
  10234. var res ResultSix
  10235. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10236. utils.ErrorLog("解析失败:%v", err)
  10237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10238. return
  10239. }
  10240. if res.Infcode == 0 {
  10241. if record_type == 1 {
  10242. service.UpdateDrugByIdDetail(item.ID)
  10243. } else if record_type == 2 {
  10244. service.UpdateGoodInfoById(item.ID)
  10245. } else if record_type == 3 {
  10246. service.UpdateMyProjectById(item.ID)
  10247. }
  10248. c.ServeSuccessJSON(map[string]interface{}{
  10249. "failed_code": 0,
  10250. "msg": "撤销目录对照成功",
  10251. })
  10252. } else {
  10253. c.ServeSuccessJSON(map[string]interface{}{
  10254. "failed_code": -10,
  10255. "msg": res.ErrMsg,
  10256. })
  10257. }
  10258. }
  10259. }
  10260. }
  10261. func (c *HisApiController) GetPatientInfo() {
  10262. id_card_no := c.GetString("id_card_no")
  10263. admin_user_id, _ := c.GetInt64("admin_user_id")
  10264. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  10265. if patient.ID == 0 {
  10266. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  10267. return
  10268. }
  10269. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10270. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10271. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  10272. if config.IsOpen == 1 {
  10273. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  10274. var dat map[string]interface{}
  10275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10276. fmt.Println(dat)
  10277. } else {
  10278. fmt.Println(err)
  10279. }
  10280. userJSONBytes, _ := json.Marshal(dat)
  10281. var res ResultTwo
  10282. var res10265 ResultTwo10265
  10283. if miConfig.Code == "H15049901371" {
  10284. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10285. utils.ErrorLog("解析失败:%v", err)
  10286. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10287. return
  10288. }
  10289. res.ErrMsg = res10265.ErrMsg
  10290. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10291. res.Infcode = infocode
  10292. res.Output = res10265.Output
  10293. res.InfRefmsgid = res10265.InfRefmsgid
  10294. } else {
  10295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10296. utils.ErrorLog("解析失败:%v", err)
  10297. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10298. return
  10299. }
  10300. }
  10301. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10302. // utils.ErrorLog("解析失败:%v", err)
  10303. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10304. // return
  10305. //}
  10306. if res.Infcode != 0 {
  10307. c.ServeSuccessJSON(map[string]interface{}{
  10308. "failed_code": -10,
  10309. "msg": res.ErrMsg,
  10310. })
  10311. } else {
  10312. c.ServeSuccessJSON(map[string]interface{}{
  10313. "failed_code": 0,
  10314. "info": res,
  10315. })
  10316. }
  10317. }
  10318. }
  10319. func (c *HisApiController) PsnPutOnRecord() {
  10320. record_type, _ := c.GetInt64("type")
  10321. patient_id, _ := c.GetInt64("patient_id")
  10322. admin_user_id, _ := c.GetInt64("admin_user_id")
  10323. start_time := c.GetString("start_time")
  10324. end_time := c.GetString("end_time")
  10325. adminUser := c.GetAdminUserInfo()
  10326. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10327. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10328. var patients []*models.Patients
  10329. if record_type == 1 { //全部备案
  10330. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10331. patients = append(patients, patient...)
  10332. } else { //单个备案
  10333. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10334. patients = append(patients, patient)
  10335. }
  10336. var user_name string
  10337. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10338. if role.ID == 0 {
  10339. user_name = "xxx"
  10340. } else {
  10341. user_name = role.UserName
  10342. }
  10343. if config.IsOpen == 1 {
  10344. for _, item := range patients {
  10345. 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
  10346. resp, requestErr := http.Get(api)
  10347. if requestErr != nil {
  10348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10349. return
  10350. }
  10351. defer resp.Body.Close()
  10352. body, ioErr := ioutil.ReadAll(resp.Body)
  10353. if ioErr != nil {
  10354. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10356. return
  10357. }
  10358. var respJSON map[string]interface{}
  10359. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10360. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10362. return
  10363. }
  10364. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10365. userJSONBytes, _ := json.Marshal(userJSON)
  10366. var res ResultTwo
  10367. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10368. utils.ErrorLog("解析失败:%v", err)
  10369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10370. return
  10371. }
  10372. if res.Infcode == 0 {
  10373. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10374. var dat map[string]interface{}
  10375. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10376. fmt.Println(dat)
  10377. } else {
  10378. fmt.Println(err)
  10379. }
  10380. userJSONBytes, _ := json.Marshal(dat)
  10381. var res2 ResultThirteen
  10382. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10383. utils.ErrorLog("解析失败:%v", err)
  10384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10385. return
  10386. }
  10387. if res2.Infcode == 0 {
  10388. psnResult := &models.GdybPsnRecord{
  10389. UserOrgId: adminUser.CurrentOrgId,
  10390. PatientId: item.ID,
  10391. PsnNo: res.Output.Baseinfo.PsnNo,
  10392. Ctime: time.Now().Unix(),
  10393. Mtime: time.Now().Unix(),
  10394. Status: 1,
  10395. IsCancel: 1,
  10396. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10397. }
  10398. service.CreatePsnRecord(psnResult)
  10399. } else {
  10400. c.ServeSuccessJSON(map[string]interface{}{
  10401. "failed_code": -10,
  10402. "msg": res2.ErrMsg,
  10403. })
  10404. return
  10405. }
  10406. }
  10407. }
  10408. }
  10409. }
  10410. func (c *HisApiController) PsnUnPutOnRecord() {
  10411. id, _ := c.GetInt64("id")
  10412. //record_type, _ := c.GetInt64("type")
  10413. admin_user_id, _ := c.GetInt64("admin_user_id")
  10414. adminUser := c.GetAdminUserInfo()
  10415. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10416. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10417. var user_name string
  10418. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10419. if role.ID == 0 {
  10420. user_name = "xxx"
  10421. } else {
  10422. user_name = role.UserName
  10423. }
  10424. psn_record, _ := service.GetPsnRecordById(id)
  10425. if psn_record.ID == 0 {
  10426. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10427. return
  10428. }
  10429. if config.IsOpen == 1 {
  10430. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10431. var dat map[string]interface{}
  10432. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10433. fmt.Println(dat)
  10434. } else {
  10435. fmt.Println(err)
  10436. }
  10437. userJSONBytes, _ := json.Marshal(dat)
  10438. var res ResultFourteen
  10439. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10440. utils.ErrorLog("解析失败:%v", err)
  10441. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10442. return
  10443. }
  10444. if res.Infcode == 0 {
  10445. psn_record.IsCancel = 2
  10446. service.CreatePsnRecord(&psn_record)
  10447. } else {
  10448. c.ServeSuccessJSON(map[string]interface{}{
  10449. "failed_code": -10,
  10450. "msg": res.ErrMsg,
  10451. })
  10452. return
  10453. }
  10454. }
  10455. }
  10456. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10457. patient_id, _ := c.GetInt64("patient_id")
  10458. insutype_two := c.GetString("insutype")
  10459. psn_no := c.GetString("psn_no")
  10460. doctor_id, _ := c.GetInt64("doctor_id")
  10461. sick_id, _ := c.GetInt64("sick_id")
  10462. department_id, _ := c.GetInt64("department_id")
  10463. start_time := c.GetString("start_time")
  10464. end_time := c.GetString("end_time")
  10465. check_time := c.GetString("check_time")
  10466. adminUser := c.GetAdminUserInfo()
  10467. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10470. sick, _ := service.FindSickById(sick_id)
  10471. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10472. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10473. var res ResultTwo
  10474. var res10265 ResultTwo10265
  10475. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10476. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10477. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10478. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10479. "&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
  10480. resp, requestErr := http.Get(api)
  10481. if requestErr != nil {
  10482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10483. return
  10484. }
  10485. body, ioErr := ioutil.ReadAll(resp.Body)
  10486. if ioErr != nil {
  10487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10489. return
  10490. }
  10491. var respJSON map[string]interface{}
  10492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10495. return
  10496. }
  10497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10498. result, _ := json.Marshal(respJSON)
  10499. fmt.Println("log")
  10500. fmt.Println(string(result))
  10501. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10502. utils.ErrorLog("解析失败:%v", err)
  10503. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10504. return
  10505. }
  10506. res.ErrMsg = res10265.ErrMsg
  10507. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10508. res.Infcode = infocode
  10509. res.Output = res10265.Output
  10510. res.InfRefmsgid = res10265.InfRefmsgid
  10511. } else {
  10512. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10513. if miConfig.Code == "H15049901371" {
  10514. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10515. utils.ErrorLog("解析失败:%v", err)
  10516. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10517. return
  10518. }
  10519. res.ErrMsg = res10265.ErrMsg
  10520. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10521. res.Infcode = infocode
  10522. res.Output = res10265.Output
  10523. res.InfRefmsgid = res10265.InfRefmsgid
  10524. } else {
  10525. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10526. utils.ErrorLog("解析失败:%v", err)
  10527. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10528. return
  10529. }
  10530. }
  10531. }
  10532. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10533. infoStr := string(Iinfos)
  10534. var rf []*ResultFive
  10535. json.Unmarshal([]byte(infoStr), &rf)
  10536. var insuplc_admdvs string
  10537. var insutype string
  10538. var is390 int = 0
  10539. var is310 int = 0
  10540. var insutypes []*ResultFive
  10541. for _, item := range rf {
  10542. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10543. insutypes = append(insutypes, item)
  10544. }
  10545. }
  10546. if len(insutypes) == 1 {
  10547. insutype = insutypes[0].Insutype
  10548. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10549. } else {
  10550. for _, i := range insutypes {
  10551. if i.Insutype == "390" {
  10552. is390 = 1
  10553. }
  10554. if i.Insutype == "310" {
  10555. is310 = 1
  10556. }
  10557. }
  10558. }
  10559. if is390 == 1 {
  10560. insutype = "390"
  10561. }
  10562. if is310 == 1 {
  10563. insutype = "310"
  10564. }
  10565. if len(insutypes) == 2 {
  10566. insutype = insutype_two
  10567. }
  10568. if len(insutypes) == 0 {
  10569. insutype = "310"
  10570. }
  10571. insutype = insutype_two
  10572. fmt.Println(insutype)
  10573. for _, item := range rf {
  10574. fmt.Println(item.Insutype)
  10575. fmt.Println(insutype)
  10576. if item.Insutype == insutype {
  10577. fmt.Println(item.Insutype)
  10578. fmt.Println(insutype)
  10579. insuplc_admdvs = item.InsuplcAdmdvs
  10580. }
  10581. }
  10582. fmt.Println(insuplc_admdvs)
  10583. var res2 ResultThirteen
  10584. var res10265_2 ResultThirteen10265
  10585. if config.IsOpen == 1 {
  10586. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10587. } else {
  10588. 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)
  10589. var dat map[string]interface{}
  10590. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10591. fmt.Println(dat)
  10592. } else {
  10593. fmt.Println(err)
  10594. }
  10595. userJSONBytes, _ := json.Marshal(dat)
  10596. if miConfig.Code == "H15049901371" {
  10597. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10598. utils.ErrorLog("解析失败:%v", err)
  10599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10600. return
  10601. }
  10602. res2.ErrMsg = res10265_2.ErrMsg
  10603. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10604. res2.Infcode = infocode
  10605. res2.Output = res10265_2.Output
  10606. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10607. } else {
  10608. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10609. utils.ErrorLog("解析失败:%v", err)
  10610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10611. return
  10612. }
  10613. }
  10614. }
  10615. if res2.Infcode == 0 {
  10616. psnResult := &models.GdybPsnNcdsRecord{
  10617. UserOrgId: adminUser.CurrentOrgId,
  10618. PatientId: patient.ID,
  10619. PsnNo: psn_no,
  10620. DoctorId: doctor.AdminUserId,
  10621. DepartmentId: department_id,
  10622. SickType: sick_id,
  10623. Insutype: insutype,
  10624. Ctime: time.Now().Unix(),
  10625. Mtime: time.Now().Unix(),
  10626. Status: 1,
  10627. IsCancel: 1,
  10628. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10629. }
  10630. service.CreatePsnNCDSRecord(psnResult)
  10631. c.ServeSuccessJSON(map[string]interface{}{
  10632. "failed_code": 0,
  10633. "msg": "备案成功",
  10634. "result": psnResult,
  10635. })
  10636. } else {
  10637. c.ServeSuccessJSON(map[string]interface{}{
  10638. "failed_code": -10,
  10639. "msg": res2.ErrMsg,
  10640. })
  10641. return
  10642. }
  10643. }
  10644. }
  10645. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10646. id, _ := c.GetInt64("id")
  10647. admin_user_id, _ := c.GetInt64("admin_user_id")
  10648. adminUser := c.GetAdminUserInfo()
  10649. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10650. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10651. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10652. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10653. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10654. //var user_name string
  10655. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10656. //if role.ID == 0 {
  10657. // user_name = "xxx"
  10658. //} else {
  10659. // user_name = role.UserName
  10660. //}
  10661. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10662. if psn_record.ID == 0 {
  10663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10664. return
  10665. }
  10666. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10667. var res ResultTwo
  10668. var res10265 ResultTwo10265
  10669. if miConfig.Code == "H15049901371" {
  10670. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10671. utils.ErrorLog("解析失败:%v", err)
  10672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10673. return
  10674. }
  10675. res.ErrMsg = res10265.ErrMsg
  10676. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10677. res.Infcode = infocode
  10678. res.Output = res10265.Output
  10679. res.InfRefmsgid = res10265.InfRefmsgid
  10680. } else {
  10681. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10682. utils.ErrorLog("解析失败:%v", err)
  10683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10684. return
  10685. }
  10686. }
  10687. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10688. infoStr := string(Iinfos)
  10689. var rf []*ResultFive
  10690. json.Unmarshal([]byte(infoStr), &rf)
  10691. var insuplc_admdvs string
  10692. var insutype string
  10693. var is390 int = 0
  10694. var is310 int = 0
  10695. var insutypes []*ResultFive
  10696. for _, item := range rf {
  10697. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10698. insutypes = append(insutypes, item)
  10699. }
  10700. }
  10701. if len(insutypes) == 1 {
  10702. insutype = insutypes[0].Insutype
  10703. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10704. } else {
  10705. for _, i := range insutypes {
  10706. if i.Insutype == "390" {
  10707. is390 = 1
  10708. }
  10709. if i.Insutype == "310" {
  10710. is310 = 1
  10711. }
  10712. }
  10713. }
  10714. if is390 == 1 {
  10715. insutype = "390"
  10716. }
  10717. if is310 == 1 {
  10718. insutype = "310"
  10719. }
  10720. if len(insutypes) == 0 {
  10721. insutype = "310"
  10722. }
  10723. insutype = psn_record.Insutype
  10724. for _, item := range rf {
  10725. if item.Insutype == insutype {
  10726. insuplc_admdvs = item.InsuplcAdmdvs
  10727. }
  10728. }
  10729. if config.IsOpen == 1 {
  10730. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10731. var dat map[string]interface{}
  10732. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10733. fmt.Println(dat)
  10734. } else {
  10735. fmt.Println(err)
  10736. }
  10737. userJSONBytes, _ := json.Marshal(dat)
  10738. var res ResultFourteen
  10739. var res10265 ResultFourteen10265
  10740. if miConfig.Code == "H15049901371" {
  10741. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10742. utils.ErrorLog("解析失败:%v", err)
  10743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10744. return
  10745. }
  10746. res.ErrMsg = res10265.ErrMsg
  10747. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10748. res.Infcode = infocode
  10749. res.Output = res10265.Output
  10750. res.InfRefmsgid = res10265.InfRefmsgid
  10751. } else {
  10752. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10753. utils.ErrorLog("解析失败:%v", err)
  10754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10755. return
  10756. }
  10757. }
  10758. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10759. // utils.ErrorLog("解析失败:%v", err)
  10760. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10761. // return
  10762. //}
  10763. if res.Infcode == 0 {
  10764. psn_record.IsCancel = 2
  10765. service.CreatePsnNCDSRecord(&psn_record)
  10766. c.ServeSuccessJSON(map[string]interface{}{
  10767. "failed_code": 0,
  10768. "msg": "撤销备案成功",
  10769. })
  10770. } else {
  10771. c.ServeSuccessJSON(map[string]interface{}{
  10772. "failed_code": -10,
  10773. "msg": res.ErrMsg,
  10774. })
  10775. return
  10776. }
  10777. }
  10778. }
  10779. func (c *HisApiController) TestTest() {
  10780. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10781. fmt.Println(patient.Iinfo)
  10782. }
  10783. type CustomData struct {
  10784. MsgId string
  10785. PsnNo string
  10786. Info string
  10787. }
  10788. func (c *HisApiController) ReversalData() {
  10789. var customData []*CustomData
  10790. custom := &CustomData{
  10791. MsgId: "H44022900158202103301714472004",
  10792. PsnNo: "44020000001101329945",
  10793. Info: "2207",
  10794. }
  10795. customData = append(customData, custom)
  10796. custom1 := &CustomData{
  10797. MsgId: "H4402290015820210330172057803",
  10798. PsnNo: "44020000001101161813",
  10799. Info: "2207",
  10800. }
  10801. customData = append(customData, custom1)
  10802. custom2 := &CustomData{
  10803. MsgId: "H44022900158202103301705198813",
  10804. PsnNo: "44190000133097375417",
  10805. Info: "2207",
  10806. }
  10807. customData = append(customData, custom2)
  10808. custom3 := &CustomData{
  10809. MsgId: "H44022900158202103301715524756",
  10810. PsnNo: "44020000001100187221",
  10811. Info: "2207",
  10812. }
  10813. customData = append(customData, custom3)
  10814. custom4 := &CustomData{
  10815. MsgId: "H44022900158202103301730376224",
  10816. PsnNo: "44020000001101959155",
  10817. Info: "2207",
  10818. }
  10819. customData = append(customData, custom4)
  10820. custom5 := &CustomData{
  10821. MsgId: "H44022900158202103301748008725",
  10822. PsnNo: "44020000001104246641",
  10823. Info: "2207",
  10824. }
  10825. customData = append(customData, custom5)
  10826. custom6 := &CustomData{
  10827. MsgId: "H44022900158202103301718096755",
  10828. PsnNo: "44020000001102211860",
  10829. Info: "2207",
  10830. }
  10831. customData = append(customData, custom6)
  10832. custom7 := &CustomData{
  10833. MsgId: "H44022900158202103301736551640",
  10834. PsnNo: "44020000001102687718",
  10835. Info: "2207",
  10836. }
  10837. customData = append(customData, custom7)
  10838. custom8 := &CustomData{
  10839. MsgId: "H44022900158202103301743097676",
  10840. PsnNo: "44020000001102127785",
  10841. Info: "2207",
  10842. }
  10843. customData = append(customData, custom8)
  10844. custom9 := &CustomData{
  10845. MsgId: "H44022900158202103301712304203",
  10846. PsnNo: "44020000001101518097",
  10847. Info: "2207",
  10848. }
  10849. customData = append(customData, custom9)
  10850. custom10 := &CustomData{
  10851. MsgId: "H44022900158202103301738448785",
  10852. PsnNo: "44020000001100500813",
  10853. Info: "2207",
  10854. }
  10855. customData = append(customData, custom10)
  10856. custom11 := &CustomData{
  10857. MsgId: "H44022900158202103301732455843",
  10858. PsnNo: "44020000001102690557",
  10859. Info: "2207",
  10860. }
  10861. customData = append(customData, custom11)
  10862. custom12 := &CustomData{
  10863. MsgId: "H44022900158202103301745421708",
  10864. PsnNo: "44020000001102211928",
  10865. Info: "2207",
  10866. }
  10867. customData = append(customData, custom12)
  10868. custom1212 := &CustomData{
  10869. MsgId: "H440229001582021033017351627",
  10870. PsnNo: "44020000001102481733",
  10871. Info: "2207",
  10872. }
  10873. customData = append(customData, custom1212)
  10874. custom13 := &CustomData{
  10875. MsgId: "H44022900158202103301740327951",
  10876. PsnNo: "44020000001103174866",
  10877. Info: "2207",
  10878. }
  10879. customData = append(customData, custom13)
  10880. custom14 := &CustomData{
  10881. MsgId: "H4402290015820210330174922668",
  10882. PsnNo: "44020000001102927272",
  10883. Info: "2207",
  10884. }
  10885. customData = append(customData, custom14)
  10886. custom15 := &CustomData{
  10887. MsgId: "H44022900158202103301752362273",
  10888. PsnNo: "44020000001102942890",
  10889. Info: "2207",
  10890. }
  10891. customData = append(customData, custom15)
  10892. custom16 := &CustomData{
  10893. MsgId: "H44022900158202103301751082917",
  10894. PsnNo: "44020000001101662162",
  10895. Info: "2207",
  10896. }
  10897. customData = append(customData, custom16)
  10898. custom17 := &CustomData{
  10899. MsgId: "H44022900158202103301754147728",
  10900. PsnNo: "44020000000229014511",
  10901. Info: "2207",
  10902. }
  10903. customData = append(customData, custom17)
  10904. adminUser := c.GetAdminUserInfo()
  10905. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10906. for _, item := range customData {
  10907. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10908. fmt.Println(result)
  10909. }
  10910. }
  10911. //func (c *HisApiController) GetAllopatry() {
  10912. // year := c.GetString("year")
  10913. // month := c.GetString("month")
  10914. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10915. // adminUser := c.GetAdminUserInfo()
  10916. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10917. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10918. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10919. //
  10920. // var dat map[string]interface{}
  10921. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10922. // fmt.Println(dat)
  10923. // } else {
  10924. // fmt.Println(err)
  10925. // }
  10926. // userJSONBytes, _ := json.Marshal(dat)
  10927. // var res models.Result9001
  10928. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10929. // utils.ErrorLog("解析失败:%v", err)
  10930. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10931. // return
  10932. // }
  10933. //
  10934. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10935. // var dat2 map[string]interface{}
  10936. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10937. // fmt.Println(dat)
  10938. // } else {
  10939. // fmt.Println(err)
  10940. // }
  10941. // userJSONBytes2, _ := json.Marshal(dat2)
  10942. // var res2 models.Result3260
  10943. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10944. // utils.ErrorLog("解析失败:%v", err)
  10945. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10946. // return
  10947. // }
  10948. // if res2.Infcode == 0 {
  10949. // c.ServeSuccessJSON(map[string]interface{}{
  10950. // "list": res2.Output.Data,
  10951. // })
  10952. // return
  10953. // } else {
  10954. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10955. // return
  10956. // }
  10957. //
  10958. //}
  10959. //func (c *HisApiController) ComfirmAllopatry() {
  10960. // year := c.GetString("year")
  10961. // month := c.GetString("month")
  10962. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10963. // adminUser := c.GetAdminUserInfo()
  10964. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10965. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10966. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10967. // var dat map[string]interface{}
  10968. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10969. // fmt.Println(dat)
  10970. // } else {
  10971. // fmt.Println(err)
  10972. // }
  10973. // userJSONBytes, _ := json.Marshal(dat)
  10974. // var res models.Result9001
  10975. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10976. // utils.ErrorLog("解析失败:%v", err)
  10977. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10978. // return
  10979. // }
  10980. //
  10981. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10982. // var dat2 map[string]interface{}
  10983. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10984. // fmt.Println(dat)
  10985. // } else {
  10986. // fmt.Println(err)
  10987. // }
  10988. // userJSONBytes2, _ := json.Marshal(dat2)
  10989. // var res2 models.Result3260
  10990. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10991. // utils.ErrorLog("解析失败:%v", err)
  10992. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10993. // return
  10994. // }
  10995. //
  10996. // if res2.Infcode == 0 {
  10997. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10998. // var dat map[string]interface{}
  10999. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11000. // fmt.Println(dat)
  11001. // } else {
  11002. // fmt.Println(err)
  11003. // }
  11004. // userJSONBytes, _ := json.Marshal(dat)
  11005. // var res3 models.Result3261
  11006. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  11007. // utils.ErrorLog("解析失败:%v", err)
  11008. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11009. // return
  11010. // }
  11011. //
  11012. // if res3.Infcode == 0 {
  11013. // record := &models.HisYidiClearRecord{
  11014. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  11015. // Ctime: time.Now().Unix(),
  11016. // Mtime: time.Now().Unix(),
  11017. // Status: 1,
  11018. // MsgId: msgId,
  11019. // }
  11020. // service.SaveClearRecord(record)
  11021. // c.ServeSuccessJSON(map[string]interface{}{
  11022. // "msg": "提取成功",
  11023. // })
  11024. // }
  11025. // }
  11026. //}
  11027. func (c *HisApiController) RefundAllopatry() {
  11028. year := c.GetString("year")
  11029. month := c.GetString("month")
  11030. id, _ := c.GetInt64("id")
  11031. admin_user_id, _ := c.GetInt64("admin_user_id")
  11032. adminUser := c.GetAdminUserInfo()
  11033. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11034. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  11035. record, _ := service.GetClearRecordById(id)
  11036. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  11037. var dat map[string]interface{}
  11038. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  11039. fmt.Println(dat)
  11040. } else {
  11041. fmt.Println(err)
  11042. }
  11043. userJSONBytes, _ := json.Marshal(dat)
  11044. var empty ResultFourteen
  11045. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  11046. utils.ErrorLog("解析失败:%v", err)
  11047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11048. return
  11049. }
  11050. if empty.Infcode == 0 {
  11051. c.ServeSuccessJSON(map[string]interface{}{
  11052. "msg": "撤销成功",
  11053. })
  11054. return
  11055. }
  11056. }
  11057. func (c *HisApiController) ReversalOtherData() {
  11058. var customData []*CustomData
  11059. custom := &CustomData{
  11060. MsgId: "H44022900158202103301714472004",
  11061. PsnNo: "44020000001101329945",
  11062. Info: "2208",
  11063. }
  11064. customData = append(customData, custom)
  11065. custom1 := &CustomData{
  11066. MsgId: "H4402290015820210330172057803",
  11067. PsnNo: "44020000001101161813",
  11068. Info: "2208",
  11069. }
  11070. customData = append(customData, custom1)
  11071. custom2 := &CustomData{
  11072. MsgId: "H44022900158202103301705198813",
  11073. PsnNo: "44190000133097375417",
  11074. Info: "2208",
  11075. }
  11076. customData = append(customData, custom2)
  11077. custom3 := &CustomData{
  11078. MsgId: "H44022900158202103301715524756",
  11079. PsnNo: "44020000001100187221",
  11080. Info: "2208",
  11081. }
  11082. customData = append(customData, custom3)
  11083. custom4 := &CustomData{
  11084. MsgId: "H44022900158202103301730376224",
  11085. PsnNo: "44020000001101959155",
  11086. Info: "2208",
  11087. }
  11088. customData = append(customData, custom4)
  11089. custom5 := &CustomData{
  11090. MsgId: "H44022900158202103301748008725",
  11091. PsnNo: "44020000001104246641",
  11092. Info: "2208",
  11093. }
  11094. customData = append(customData, custom5)
  11095. custom6 := &CustomData{
  11096. MsgId: "H44022900158202103301718096755",
  11097. PsnNo: "44020000001102211860",
  11098. Info: "2208",
  11099. }
  11100. customData = append(customData, custom6)
  11101. custom7 := &CustomData{
  11102. MsgId: "H44022900158202103301736551640",
  11103. PsnNo: "44020000001102687718",
  11104. Info: "2208",
  11105. }
  11106. customData = append(customData, custom7)
  11107. custom8 := &CustomData{
  11108. MsgId: "H44022900158202103301743097676",
  11109. PsnNo: "44020000001102127785",
  11110. Info: "2208",
  11111. }
  11112. customData = append(customData, custom8)
  11113. custom9 := &CustomData{
  11114. MsgId: "H44022900158202103301712304203",
  11115. PsnNo: "44020000001101518097",
  11116. Info: "2208",
  11117. }
  11118. customData = append(customData, custom9)
  11119. custom10 := &CustomData{
  11120. MsgId: "H44022900158202103301738448785",
  11121. PsnNo: "44020000001100500813",
  11122. Info: "2208",
  11123. }
  11124. customData = append(customData, custom10)
  11125. custom11 := &CustomData{
  11126. MsgId: "H44022900158202103301732455843",
  11127. PsnNo: "44020000001102690557",
  11128. Info: "2208",
  11129. }
  11130. customData = append(customData, custom11)
  11131. custom12 := &CustomData{
  11132. MsgId: "H44022900158202103301745421708",
  11133. PsnNo: "44020000001102211928",
  11134. Info: "2208",
  11135. }
  11136. customData = append(customData, custom12)
  11137. custom1212 := &CustomData{
  11138. MsgId: "H440229001582021033017351627",
  11139. PsnNo: "44020000001102481733",
  11140. Info: "2208",
  11141. }
  11142. customData = append(customData, custom1212)
  11143. custom13 := &CustomData{
  11144. MsgId: "H44022900158202103301740327951",
  11145. PsnNo: "44020000001103174866",
  11146. Info: "2208",
  11147. }
  11148. customData = append(customData, custom13)
  11149. custom14 := &CustomData{
  11150. MsgId: "H4402290015820210330174922668",
  11151. PsnNo: "44020000001102927272",
  11152. Info: "2208",
  11153. }
  11154. customData = append(customData, custom14)
  11155. custom15 := &CustomData{
  11156. MsgId: "H44022900158202103301752362273",
  11157. PsnNo: "44020000001102942890",
  11158. Info: "2208",
  11159. }
  11160. customData = append(customData, custom15)
  11161. custom16 := &CustomData{
  11162. MsgId: "H44022900158202103301751082917",
  11163. PsnNo: "44020000001101662162",
  11164. Info: "2208",
  11165. }
  11166. customData = append(customData, custom16)
  11167. custom17 := &CustomData{
  11168. MsgId: "H44022900158202103301754147728",
  11169. PsnNo: "44020000000229014511",
  11170. Info: "2208",
  11171. }
  11172. customData = append(customData, custom17)
  11173. adminUser := c.GetAdminUserInfo()
  11174. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  11175. for _, item := range customData {
  11176. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  11177. fmt.Println(result)
  11178. }
  11179. }
  11180. func PathExists(path string) (bool, error) {
  11181. _, err := os.Stat(path)
  11182. if err == nil {
  11183. return true, nil
  11184. }
  11185. if os.IsNotExist(err) {
  11186. return false, nil
  11187. }
  11188. return false, err
  11189. }
  11190. //创建文件夹
  11191. func Mkdir(dir string) {
  11192. // 创建文件夹
  11193. exist, err := PathExists(dir)
  11194. if err != nil {
  11195. fmt.Println(err.Error())
  11196. } else {
  11197. if exist {
  11198. fmt.Println(dir + "文件夹已存在!")
  11199. } else {
  11200. // 文件夹名称,权限
  11201. err := os.Mkdir(dir, os.ModePerm)
  11202. if err != nil {
  11203. fmt.Println(dir+"文件夹创建失败:", err.Error())
  11204. } else {
  11205. fmt.Println(dir + "文件夹创建成功!")
  11206. }
  11207. }
  11208. }
  11209. }
  11210. //压缩文件
  11211. func Zip(srcFile string, destZip string) error {
  11212. zipfile, err := os.Create(destZip)
  11213. if err != nil {
  11214. return err
  11215. }
  11216. defer zipfile.Close()
  11217. archive := zip.NewWriter(zipfile)
  11218. defer archive.Close()
  11219. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  11220. if err != nil {
  11221. return err
  11222. }
  11223. header, err := zip.FileInfoHeader(info)
  11224. if err != nil {
  11225. return err
  11226. }
  11227. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  11228. // header.Name = path
  11229. if info.IsDir() {
  11230. header.Name += "/"
  11231. } else {
  11232. header.Method = zip.Deflate
  11233. }
  11234. writer, err := archive.CreateHeader(header)
  11235. if err != nil {
  11236. return err
  11237. }
  11238. if !info.IsDir() {
  11239. file, err := os.Open(path)
  11240. if err != nil {
  11241. return err
  11242. }
  11243. defer file.Close()
  11244. _, err = io.Copy(writer, file)
  11245. }
  11246. return err
  11247. })
  11248. return err
  11249. }
  11250. func ReadFile(filePath string) []byte {
  11251. f, err := os.Open(filePath)
  11252. if err != nil {
  11253. fmt.Println("read file fail", err)
  11254. return nil
  11255. }
  11256. defer f.Close()
  11257. fd, err := ioutil.ReadAll(f)
  11258. if err != nil {
  11259. fmt.Println("read to fd fail", err)
  11260. return nil
  11261. }
  11262. return fd
  11263. }
  11264. func saveLog(result string, request string, infno string, desc string) {
  11265. org_id, _ := beego.AppConfig.Int64("org_id")
  11266. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  11267. dir := miConfig.OrgName + "日志"
  11268. utils.Mkdir(dir)
  11269. month := time.Unix(1557042972, 0).Format("1")
  11270. year := time.Now().Format("2006")
  11271. month = time.Now().Format("01")
  11272. day := time.Now().Format("02")
  11273. hour := time.Now().Format("15")
  11274. min := time.Now().Format("04")
  11275. sec := time.Now().Format("05")
  11276. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  11277. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  11278. file_name := file + ".txt"
  11279. file_path := miConfig.OrgName + "日志" + "/" + file_name
  11280. exist, _ := utils.PathExists(file_path)
  11281. if exist { //存在
  11282. fmt.Println("存在")
  11283. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  11284. if err != nil {
  11285. fmt.Println("read fail")
  11286. }
  11287. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  11288. n, _ := f.Seek(0, 2)
  11289. _, err = f.WriteAt([]byte(content), n)
  11290. } else { //不存在
  11291. fmt.Println("文件不存在,创建文件")
  11292. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  11293. defer f.Close()
  11294. if err != nil {
  11295. } else {
  11296. _, err = f.Write([]byte("记录日志"))
  11297. }
  11298. }
  11299. }
  11300. type Charset string
  11301. const (
  11302. UTF8 = Charset("UTF-8")
  11303. GB18030 = Charset("GB18030")
  11304. )
  11305. func ConvertToString(src string, srcCode string, tagCode string) string {
  11306. srcCoder := mahonia.NewDecoder(srcCode)
  11307. srcResult := srcCoder.ConvertString(src)
  11308. tagCoder := mahonia.NewDecoder(tagCode)
  11309. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11310. result := string(cdata)
  11311. return result
  11312. }
  11313. func (c *HisApiController) ReadEleCard() {
  11314. id_card_type, _ := c.GetInt64("id_card_type")
  11315. admin_user_id, _ := c.GetInt64("admin_user_id")
  11316. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11317. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11318. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11319. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11320. var api string
  11321. if miConfig.MdtrtareaAdmvs == "320921" {
  11322. 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 +
  11323. "&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
  11324. fmt.Println(api)
  11325. } else {
  11326. 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 +
  11327. "&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
  11328. }
  11329. resp, requestErr := http.Get(api)
  11330. if requestErr != nil {
  11331. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11332. return
  11333. }
  11334. body, ioErr := ioutil.ReadAll(resp.Body)
  11335. if ioErr != nil {
  11336. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11338. return
  11339. }
  11340. var respJSON map[string]interface{}
  11341. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11342. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11344. return
  11345. }
  11346. var status string
  11347. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11348. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11349. var token string
  11350. var res ResultTwo //1101结果
  11351. var res10265 ResultTwo10265 //1101结果
  11352. if status == "0" { //读卡成功
  11353. var card_info string //卡信息
  11354. var busi_card_info string
  11355. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11356. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11357. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11358. fmt.Println(card_info)
  11359. fmt.Println(busi_card_info)
  11360. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11361. result, _ := json.Marshal(respJSON)
  11362. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11363. utils.ErrorLog("解析失败:%v", err)
  11364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11365. return
  11366. }
  11367. res.ErrMsg = res10265.ErrMsg
  11368. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11369. res.Infcode = infocode
  11370. res.Output = res10265.Output
  11371. res.InfRefmsgid = res10265.InfRefmsgid
  11372. if res.Infcode == 0 {
  11373. c.ServeSuccessJSON(map[string]interface{}{
  11374. "number": token,
  11375. })
  11376. }
  11377. } else {
  11378. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11379. return
  11380. }
  11381. } else { //读卡失败
  11382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11383. return
  11384. }
  11385. }
  11386. func DeleteExtraSpaceTwo(s string) string {
  11387. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11388. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11389. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11390. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11391. s2 := make([]byte, len(s1)) //定义字符数组切片
  11392. copy(s2, s1) //将字符串复制到切片
  11393. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11394. for len(spc_index) > 0 { //找到适配项
  11395. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11396. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11397. }
  11398. return string(s2)
  11399. }
  11400. func Remove0000(s string) string {
  11401. str := make([]rune, 0, len(s))
  11402. for _, v := range []rune(s) {
  11403. if v == 0 {
  11404. continue
  11405. }
  11406. str = append(str, v)
  11407. }
  11408. return string(str)
  11409. }
  11410. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11411. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11412. readCard := DllDef.MustFindProc("EcQuery")
  11413. pCardInfo := make([]byte, 8192)
  11414. pBusiCardInfo := make([]byte, 8192)
  11415. data := make(map[string]interface{})
  11416. //pData := make(map[string]interface{})
  11417. inputData := make(map[string]interface{})
  11418. inputData["orgId"] = code
  11419. inputData["businessType"] = "01101"
  11420. inputData["operatorId"] = operator_id
  11421. inputData["operatorName"] = operator_name
  11422. inputData["officeId"] = "001"
  11423. inputData["officeName"] = "血透室"
  11424. //
  11425. data["data"] = inputData
  11426. data["transType"] = "ec.query"
  11427. data["orgId"] = code
  11428. bytesData, _ := json.Marshal(data)
  11429. pCardInfo = bytesData
  11430. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11431. fmt.Println(ret2)
  11432. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11433. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11434. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11435. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11436. if ret2 != 0 {
  11437. return "", ""
  11438. }
  11439. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11440. }
  11441. func DeleteExtraSpace(s string) string {
  11442. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11443. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11444. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11445. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11446. s2 := make([]byte, len(s1)) //定义字符数组切片
  11447. copy(s2, s1) //将字符串复制到切片
  11448. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11449. for len(spc_index) > 0 { //找到适配项
  11450. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11451. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11452. }
  11453. return string(s2)
  11454. }