his_api_controller.go 449KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310
  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. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  50. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  51. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  52. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  53. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  54. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  55. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  56. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  57. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  58. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  59. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  60. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  61. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  62. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  63. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  64. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  65. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  66. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  67. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  68. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  69. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  70. //beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  71. //beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  72. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  73. beego.Router("/api/check", &HisApiController{}, "get:Check")
  74. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  75. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  76. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  77. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  78. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  79. }
  80. func (c *HisApiController) Get9001() {
  81. adminUser := c.GetAdminUserInfo()
  82. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  83. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  84. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  85. var dat map[string]interface{}
  86. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  87. fmt.Println(dat)
  88. } else {
  89. fmt.Println(err)
  90. }
  91. userJSONBytes, _ := json.Marshal(dat)
  92. var res models.Result9001
  93. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  94. utils.ErrorLog("解析失败:%v", err)
  95. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  96. return
  97. }
  98. }
  99. func (c *HisApiController) Check3101() {
  100. patient_id, _ := c.GetInt64("patient_id")
  101. his_patient_id, _ := c.GetInt64("his_patient_id")
  102. admin_user_id, _ := c.GetInt64("admin_user_id")
  103. adminUser := c.GetAdminUserInfo()
  104. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  105. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  106. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  107. record_time := c.GetString("record_time")
  108. trig_scen := c.GetString("trig_scen")
  109. timeLayout := "2006-01-02"
  110. loc, _ := time.LoadLocation("Local")
  111. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  112. if err != nil {
  113. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  114. return
  115. }
  116. recordDateTime := theTime.Unix()
  117. var patientPrescription models.HisPrescriptionInfo
  118. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  119. if patientPrescription.ID == 0 {
  120. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  121. }
  122. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  123. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  124. //
  125. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  126. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  127. var pp models.PublicParams
  128. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  129. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  130. pp.FixmedinsName = miConfig.OrgName
  131. pp.FixmedinsCode = miConfig.Code
  132. pp.RequestUrl = miConfig.Url
  133. pp.Cainfo = miConfig.Cainfo
  134. pp.SecretKey = miConfig.SecretKey
  135. pp.AccessKey = miConfig.AccessKey
  136. pp.OpterName = roles.UserName
  137. var config []*models.HisXtDiagnoseConfig
  138. for _, item := range diagnosis_ids {
  139. id, _ := strconv.ParseInt(item, 10, 64)
  140. diagnosisConfig, _ := service.FindDiagnoseById(id)
  141. config = append(config, &diagnosisConfig)
  142. }
  143. var pd models.PatientDtos
  144. pd.PatnID = his.PsnNo
  145. pd.PatnName = his.Name
  146. pd.Gend = his.Gend
  147. pd.Brdy = his.Brdy
  148. pd.Poolarea = his.InsuplcAdmdvs
  149. pd.CurrMdtrtID = his.Number
  150. var fed models.FsiEncounterDtos
  151. fed.MdtrtID = his.Number
  152. fed.MedinsID = miConfig.Code
  153. fed.MedinsName = miConfig.OrgName
  154. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  155. fed.MedMdtrtType = "1"
  156. fed.MedinsType = "1"
  157. fed.MedinsLv = "11"
  158. tm := time.Unix(his.RecordDate, 0)
  159. s_tm := tm.Format("2006-01-02 15:04:05")
  160. fed.AdmDate = s_tm
  161. fed.DscgDate = s_tm
  162. fed.DscgMainDiseCodg = config[0].CountryCode
  163. fed.DscgMainDiseName = config[0].CountryContentName
  164. //诊断信息
  165. var fdds []*models.FsiDiagnoseDtos
  166. for index, item := range config {
  167. if index == 0 {
  168. var fdd models.FsiDiagnoseDtos
  169. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  170. fdd.InoutDiseType = "1"
  171. fdd.MaindiseFlag = "1"
  172. fdd.DiseDate = s_tm
  173. fdd.DiasSrtNo = "1"
  174. fdd.DiseName = item.CountryContentName
  175. fdd.DiseCodg = item.CountryCode
  176. fdds = append(fdds, &fdd)
  177. } else {
  178. var fdd models.FsiDiagnoseDtos
  179. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  180. fdd.InoutDiseType = "1"
  181. fdd.MaindiseFlag = "1"
  182. fdd.DiseDate = s_tm
  183. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  184. fdd.DiseName = item.CountryContentName
  185. fdd.DiseCodg = item.CountryCode
  186. fdds = append(fdds, &fdd)
  187. }
  188. }
  189. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  190. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  191. fed.AdmDeptName = department.Name
  192. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  193. fed.DscgDeptName = department.Name
  194. fed.MedMdtrtType = "1"
  195. fed.MedType = "11"
  196. //if his.Insutype == "390" {
  197. // fed.MedType = "1402"
  198. //} else {
  199. // fed.MedType = "9933"
  200. //}
  201. var orders []*models.FsiOrderDtos
  202. if trig_scen == "2" {
  203. //处方医嘱信息
  204. for _, item := range prescriptions {
  205. for _, subItem := range item.HisDoctorAdviceInfo {
  206. var order models.FsiOrderDtos
  207. order.RxID = strconv.FormatInt(item.ID, 10)
  208. order.Rxno = strconv.FormatInt(item.ID, 10)
  209. order.LongDrordFlag = "0"
  210. order.HilistType = "1"
  211. order.ChrgType = "1"
  212. order.DrordBhvr = "-"
  213. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  214. order.HosplistName = subItem.BaseDrugLib.DrugName
  215. order.HilistLv = "1"
  216. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  217. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  220. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  222. order.OwnpayAmt = ""
  223. order.SelfpayAmt = ""
  224. order.Spec = ""
  225. order.SpecUnt = ""
  226. order.DrordBegnDate = s_tm
  227. order.DrordStopDate = ""
  228. order.DrordDrCodg = "1"
  229. order.DrordDeptName = department.Name
  230. order.DrordDrCodg = "1"
  231. order.DrordDrName = doctor_info.UserName
  232. order.DrordDrProfttl = ""
  233. order.CurrDrordFlag = "1"
  234. orders = append(orders, &order)
  235. }
  236. for _, subItem := range item.HisPrescriptionProject {
  237. if subItem.Type == 2 {
  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.HisProject.MedicalCode
  246. order.HosplistName = subItem.HisProject.ProjectName
  247. order.HilistLv = "1"
  248. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  249. order.HosplistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.Cnt = subItem.Count
  252. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  253. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  254. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  255. order.OwnpayAmt = ""
  256. order.SelfpayAmt = ""
  257. order.Spec = ""
  258. order.SpecUnt = ""
  259. order.DrordBegnDate = s_tm
  260. order.DrordStopDate = ""
  261. order.DrordDrCodg = "1"
  262. order.DrordDeptName = department.Name
  263. order.DrordDrCodg = "1"
  264. order.DrordDrName = doctor_info.UserName
  265. order.DrordDrProfttl = ""
  266. order.CurrDrordFlag = "1"
  267. orders = append(orders, &order)
  268. }
  269. if subItem.Type == 3 {
  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.GoodInfo.MedicalInsuranceNumber
  278. order.HosplistName = subItem.GoodInfo.GoodName
  279. order.HilistLv = "1"
  280. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  281. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  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. }
  302. }
  303. //处方医嘱信息
  304. }
  305. fed.MatnStas = "0"
  306. fed.MedfeeSumamt = "0"
  307. fed.OwnpayAmt = "0"
  308. fed.SelfpayAmt = "0"
  309. fed.AcctPayamt = "0"
  310. fed.MaAmt = "0"
  311. fed.HifpPayamt = "0"
  312. fed.SetlTotlnum = "1"
  313. fed.Insutype = his.Insutype
  314. fed.ReimFlag = "0"
  315. fed.OutSetlFlag = "0"
  316. var fopd []*models.FsiOperationDtosData
  317. data := make(map[string]interface{})
  318. data["fed"] = fed
  319. data["fdd"] = fdds
  320. data["fod"] = orders
  321. data["pd"] = pd
  322. data["pp"] = pp
  323. data["fopd"] = fopd
  324. data["trig_scen"] = trig_scen
  325. fmt.Println(data)
  326. fmt.Println(fed)
  327. fmt.Println(fdds)
  328. fmt.Println(orders)
  329. fmt.Println(pd)
  330. fmt.Println(pp)
  331. fmt.Println(fopd)
  332. client := &http.Client{}
  333. bytesData, _ := json.Marshal(data)
  334. var req *http.Request
  335. if miConfig.MdtrtareaAdmvs == "320921" {
  336. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  337. } else {
  338. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  339. }
  340. resp, _ := client.Do(req)
  341. defer resp.Body.Close()
  342. body, ioErr := ioutil.ReadAll(resp.Body)
  343. if ioErr != nil {
  344. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  346. return
  347. }
  348. var respJSON map[string]interface{}
  349. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  350. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  351. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  352. return
  353. }
  354. //手术操作集合
  355. //手术操作集合
  356. }
  357. func (c *HisApiController) Check3102() {
  358. patient_id, _ := c.GetInt64("patient_id")
  359. order_id, _ := c.GetInt64("order_id")
  360. his_patient_id, _ := c.GetInt64("his_patient_id")
  361. admin_user_id, _ := c.GetInt64("admin_user_id")
  362. trig_scen := c.GetString("trig_scen")
  363. adminUser := c.GetAdminUserInfo()
  364. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  365. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  366. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  367. record_time := c.GetString("record_time")
  368. order, _ := service.GetHisOrderByID(order_id)
  369. timeLayout := "2006-01-02"
  370. loc, _ := time.LoadLocation("Local")
  371. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  372. if err != nil {
  373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  374. return
  375. }
  376. recordDateTime := theTime.Unix()
  377. var patientPrescription models.HisPrescriptionInfo
  378. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  379. if patientPrescription.ID == 0 {
  380. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  381. }
  382. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  383. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  384. //
  385. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  386. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  387. var pp models.PublicParams
  388. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  389. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  390. pp.FixmedinsName = miConfig.OrgName
  391. pp.FixmedinsCode = miConfig.Code
  392. pp.RequestUrl = miConfig.Url
  393. pp.Cainfo = miConfig.Cainfo
  394. pp.SecretKey = miConfig.SecretKey
  395. pp.AccessKey = miConfig.AccessKey
  396. pp.OpterName = roles.UserName
  397. var config []*models.HisXtDiagnoseConfig
  398. for _, item := range diagnosis_ids {
  399. id, _ := strconv.ParseInt(item, 10, 64)
  400. diagnosisConfig, _ := service.FindDiagnoseById(id)
  401. config = append(config, &diagnosisConfig)
  402. }
  403. var pd models.PatientDtos
  404. pd.PatnID = his.PsnNo
  405. pd.PatnName = his.Name
  406. pd.Gend = his.Gend
  407. pd.Brdy = his.Brdy
  408. pd.Poolarea = his.InsuplcAdmdvs
  409. pd.CurrMdtrtID = his.Number
  410. var fed models.FsiEncounterDtos
  411. fed.MdtrtID = his.Number
  412. fed.MedinsID = miConfig.Code
  413. fed.MedinsName = miConfig.OrgName
  414. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  415. fed.MedMdtrtType = "1"
  416. fed.MedinsType = "1"
  417. fed.MedinsLv = "11"
  418. tm := time.Unix(his.RecordDate, 0)
  419. s_tm := tm.Format("2006-01-02 15:04:05")
  420. fed.AdmDate = s_tm
  421. fed.DscgDate = s_tm
  422. fed.DscgMainDiseCodg = config[0].CountryCode
  423. fed.DscgMainDiseName = config[0].CountryContentName
  424. //诊断信息
  425. var fdds []*models.FsiDiagnoseDtos
  426. for index, item := range config {
  427. if index == 0 {
  428. var fdd models.FsiDiagnoseDtos
  429. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  430. fdd.InoutDiseType = "1"
  431. fdd.MaindiseFlag = "1"
  432. fdd.DiseDate = s_tm
  433. fdd.DiasSrtNo = "1"
  434. fdd.DiseName = item.CountryContentName
  435. fdd.DiseCodg = item.CountryCode
  436. fdds = append(fdds, &fdd)
  437. } else {
  438. var fdd models.FsiDiagnoseDtos
  439. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  440. fdd.InoutDiseType = "1"
  441. fdd.MaindiseFlag = "1"
  442. fdd.DiseDate = s_tm
  443. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  444. fdd.DiseName = item.CountryContentName
  445. fdd.DiseCodg = item.CountryCode
  446. fdds = append(fdds, &fdd)
  447. }
  448. }
  449. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  450. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  451. fed.AdmDeptName = department.Name
  452. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  453. fed.DscgDeptName = department.Name
  454. fed.MedType = order.MedType
  455. //处方医嘱信息
  456. var orders []*models.FsiOrderDtos
  457. //for _, item := range prescriptions {
  458. // for _, subItem := range item.HisDoctorAdviceInfo {
  459. // var order models.FsiOrderDtos
  460. // order.RxID = strconv.FormatInt(item.ID, 10)
  461. // order.Rxno = strconv.FormatInt(item.ID, 10)
  462. // order.LongDrordFlag = "0"
  463. // order.HilistType = "1"
  464. // order.ChrgType = "1"
  465. // order.DrordBhvr = "-"
  466. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  467. // order.HosplistName = subItem.BaseDrugLib.DrugName
  468. // order.HilistLv = "1"
  469. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  470. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  473. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  475. // order.OwnpayAmt = ""
  476. // order.SelfpayAmt = ""
  477. // order.Spec = ""
  478. // order.SpecUnt = ""
  479. // order.DrordBegnDate = s_tm
  480. // order.DrordStopDate = ""
  481. // order.DrordDrCodg = "1"
  482. // order.DrordDeptName = department.Name
  483. // order.DrordDrCodg = "1"
  484. // order.DrordDrName = doctor_info.UserName
  485. // order.DrordDrProfttl = ""
  486. // order.CurrDrordFlag = "1"
  487. // orders = append(orders, &order)
  488. // }
  489. // for _, subItem := range item.HisPrescriptionProject {
  490. // if subItem.Type == 2 {
  491. // var order models.FsiOrderDtos
  492. // order.RxID = strconv.FormatInt(item.ID, 10)
  493. // order.Rxno = strconv.FormatInt(item.ID, 10)
  494. // order.LongDrordFlag = "0"
  495. // order.HilistType = "1"
  496. // order.ChrgType = "1"
  497. // order.DrordBhvr = "-"
  498. // order.HilistCode = subItem.HisProject.MedicalCode
  499. // order.HosplistName = subItem.HisProject.ProjectName
  500. // order.HilistLv = "1"
  501. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  502. // order.HosplistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.Cnt = subItem.Count
  505. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  506. //
  507. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  508. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  509. // order.OwnpayAmt = ""
  510. // order.SelfpayAmt = ""
  511. // order.Spec = ""
  512. // order.SpecUnt = ""
  513. // order.DrordBegnDate = s_tm
  514. // order.DrordStopDate = ""
  515. // order.DrordDrCodg = "1"
  516. // order.DrordDeptName = department.Name
  517. // order.DrordDrCodg = "1"
  518. // order.DrordDrName = doctor_info.UserName
  519. // order.DrordDrProfttl = ""
  520. // order.CurrDrordFlag = "1"
  521. // orders = append(orders, &order)
  522. //
  523. // }
  524. // if subItem.Type == 3 {
  525. //
  526. // var order models.FsiOrderDtos
  527. // order.RxID = strconv.FormatInt(item.ID, 10)
  528. // order.Rxno = strconv.FormatInt(item.ID, 10)
  529. // order.LongDrordFlag = "0"
  530. // order.HilistType = "1"
  531. // order.ChrgType = "1"
  532. // order.DrordBhvr = "-"
  533. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  534. // order.HosplistName = subItem.GoodInfo.GoodName
  535. // order.HilistLv = "1"
  536. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  537. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.Cnt = subItem.Count
  540. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  541. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  542. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  543. // order.OwnpayAmt = ""
  544. // order.SelfpayAmt = ""
  545. // order.Spec = ""
  546. // order.SpecUnt = ""
  547. // order.DrordBegnDate = s_tm
  548. // order.DrordStopDate = ""
  549. // order.DrordDrCodg = "1"
  550. // order.DrordDeptName = department.Name
  551. // order.DrordDrCodg = "1"
  552. // order.DrordDrName = doctor_info.UserName
  553. // order.DrordDrProfttl = ""
  554. // order.CurrDrordFlag = "1"
  555. // orders = append(orders, &order)
  556. //
  557. // }
  558. // }
  559. //}
  560. for _, item := range prescriptions {
  561. for _, subItem := range item.HisDoctorAdviceInfo {
  562. var order models.FsiOrderDtos
  563. order.RxID = strconv.FormatInt(item.ID, 10)
  564. order.Rxno = strconv.FormatInt(item.ID, 10)
  565. order.LongDrordFlag = "0"
  566. order.HilistType = "1"
  567. order.ChrgType = "1"
  568. order.DrordBhvr = "-"
  569. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  570. order.HosplistName = subItem.BaseDrugLib.DrugName
  571. order.HilistLv = "1"
  572. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  573. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  576. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  578. order.OwnpayAmt = ""
  579. order.SelfpayAmt = ""
  580. order.Spec = ""
  581. order.SpecUnt = ""
  582. order.DrordBegnDate = s_tm
  583. order.DrordStopDate = ""
  584. order.DrordDrCodg = "1"
  585. order.DrordDeptName = department.Name
  586. order.DrordDrCodg = "1"
  587. order.DrordDrName = doctor_info.UserName
  588. order.DrordDrProfttl = ""
  589. order.CurrDrordFlag = "1"
  590. orders = append(orders, &order)
  591. }
  592. for _, subItem := range item.HisPrescriptionProject {
  593. if subItem.Type == 2 {
  594. var order models.FsiOrderDtos
  595. order.RxID = strconv.FormatInt(item.ID, 10)
  596. order.Rxno = strconv.FormatInt(item.ID, 10)
  597. order.LongDrordFlag = "0"
  598. order.HilistType = "1"
  599. order.ChrgType = "1"
  600. order.DrordBhvr = "-"
  601. order.HilistCode = subItem.HisProject.MedicalCode
  602. order.HosplistName = subItem.HisProject.ProjectName
  603. order.HilistLv = "1"
  604. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  605. order.HosplistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.Cnt = subItem.Count
  608. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  609. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  610. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  611. order.OwnpayAmt = ""
  612. order.SelfpayAmt = ""
  613. order.Spec = ""
  614. order.SpecUnt = ""
  615. order.DrordBegnDate = s_tm
  616. order.DrordStopDate = ""
  617. order.DrordDrCodg = "1"
  618. order.DrordDeptName = department.Name
  619. order.DrordDrCodg = "1"
  620. order.DrordDrName = doctor_info.UserName
  621. order.DrordDrProfttl = ""
  622. order.CurrDrordFlag = "1"
  623. orders = append(orders, &order)
  624. }
  625. if subItem.Type == 3 {
  626. var order models.FsiOrderDtos
  627. order.RxID = strconv.FormatInt(item.ID, 10)
  628. order.Rxno = strconv.FormatInt(item.ID, 10)
  629. order.LongDrordFlag = "0"
  630. order.HilistType = "1"
  631. order.ChrgType = "1"
  632. order.DrordBhvr = "-"
  633. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  634. order.HosplistName = subItem.GoodInfo.GoodName
  635. order.HilistLv = "1"
  636. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  637. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.Cnt = subItem.Count
  640. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  641. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  642. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  643. order.OwnpayAmt = ""
  644. order.SelfpayAmt = ""
  645. order.Spec = ""
  646. order.SpecUnt = ""
  647. order.DrordBegnDate = s_tm
  648. order.DrordStopDate = ""
  649. order.DrordDrCodg = "1"
  650. order.DrordDeptName = department.Name
  651. order.DrordDrCodg = "1"
  652. order.DrordDrName = doctor_info.UserName
  653. order.DrordDrProfttl = ""
  654. order.CurrDrordFlag = "1"
  655. orders = append(orders, &order)
  656. }
  657. }
  658. }
  659. //处方医嘱信息
  660. fed.MatnStas = "0"
  661. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  662. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  663. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  664. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  665. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  666. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  667. fed.SetlTotlnum = "1"
  668. fed.Insutype = his.Insutype
  669. fed.ReimFlag = "0"
  670. fed.OutSetlFlag = "0"
  671. var fopd []*models.FsiOperationDtosData
  672. data := make(map[string]interface{})
  673. data["fed"] = fed
  674. data["fdd"] = fdds
  675. data["fod"] = orders
  676. data["pd"] = pd
  677. data["pp"] = pp
  678. data["fopd"] = fopd
  679. data["trig_scen"] = trig_scen
  680. client := &http.Client{}
  681. bytesData, _ := json.Marshal(data)
  682. var req *http.Request
  683. if miConfig.MdtrtareaAdmvs == "320921" {
  684. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  685. } else {
  686. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  687. }
  688. resp, _ := client.Do(req)
  689. defer resp.Body.Close()
  690. body, ioErr := ioutil.ReadAll(resp.Body)
  691. if ioErr != nil {
  692. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  694. return
  695. }
  696. var respJSON map[string]interface{}
  697. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  698. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  700. return
  701. }
  702. //手术操作集合
  703. //手术操作集合
  704. }
  705. func (c *HisApiController) Check() {
  706. psn_no := c.GetString("psn_no")
  707. in := c.GetString("in")
  708. mt := c.GetString("mt")
  709. baseParams := models.BaseParams{
  710. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  711. FixmedinsCode: "H15049901371",
  712. InsuplcAdmdvs: "150499",
  713. MdtrtareaAdmvs: "150499",
  714. OrgName: "赤峰费森血液透析中心",
  715. Doctor: "1111",
  716. }
  717. service.Gdyb2001(baseParams, psn_no, in, mt)
  718. }
  719. func (c *HisApiController) GetPsnNcdsInfo() {
  720. admin_user_id, _ := c.GetInt64("admin_user_id")
  721. patient_id, _ := c.GetInt64("patient_id")
  722. id, _ := c.GetInt64("id")
  723. adminUser := c.GetAdminUserInfo()
  724. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  725. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  726. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  727. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  728. psn_record, _ := service.GetPsnNCDSRecordById(id)
  729. //
  730. //if psn_record.ID == 0 {
  731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  732. // return
  733. //}
  734. var res Result5301
  735. var res10265 Result5301For10265
  736. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  737. psn_info, _ := service.GetPsnByPatientId(patient_id)
  738. var api string
  739. if miConfig.MdtrtareaAdmvs == "320921" {
  740. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  741. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  742. } else {
  743. 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 +
  744. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  745. }
  746. resp, requestErr := http.Get(api)
  747. if requestErr != nil {
  748. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  749. return
  750. }
  751. body, ioErr := ioutil.ReadAll(resp.Body)
  752. if ioErr != nil {
  753. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  755. return
  756. }
  757. var respJSON map[string]interface{}
  758. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  759. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  761. return
  762. }
  763. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  764. result, _ := json.Marshal(respJSON)
  765. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  766. utils.ErrorLog("解析失败:%v", err)
  767. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  768. return
  769. }
  770. res.ErrMsg = res10265.ErrMsg
  771. res.Output = res10265.Output
  772. res.InfRefmsgid = res10265.InfRefmsgid
  773. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  774. res.Infcode = infocode
  775. } else {
  776. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  777. var dat map[string]interface{}
  778. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  779. fmt.Println(dat)
  780. } else {
  781. fmt.Println(err)
  782. }
  783. userJSONBytes, _ := json.Marshal(dat)
  784. if miConfig.Code == "H15049901371" {
  785. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  786. utils.ErrorLog("解析失败:%v", err)
  787. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  788. return
  789. }
  790. res.InfRefmsgid = res10265.InfRefmsgid
  791. res.Output = res10265.Output
  792. res.ErrMsg = res10265.ErrMsg
  793. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  794. res.Infcode = infocode
  795. } else {
  796. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  797. utils.ErrorLog("解析失败:%v", err)
  798. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  799. return
  800. }
  801. }
  802. }
  803. if res.Infcode == 0 {
  804. c.ServeSuccessJSON(map[string]interface{}{
  805. "result": res.Output.Result,
  806. })
  807. }
  808. }
  809. func (c *HisApiController) CheckInsutype() {
  810. his_patient_id, _ := c.GetInt64("his_patient_id")
  811. admin_user_id, _ := c.GetInt64("admin_user_id")
  812. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  813. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  814. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  815. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  816. var dat map[string]interface{}
  817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  818. fmt.Println(dat)
  819. } else {
  820. fmt.Println(err)
  821. }
  822. userJSONBytes, _ := json.Marshal(dat)
  823. var res Result90100
  824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  825. utils.ErrorLog("解析失败:%v", err)
  826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  827. return
  828. }
  829. if res.Infcode != 0 {
  830. c.ServeSuccessJSON(map[string]interface{}{
  831. "failed_code": -10,
  832. "msg": res.ErrMsg,
  833. })
  834. return
  835. } else {
  836. fmt.Println(res)
  837. }
  838. }
  839. func (c *HisApiController) CheckCardPWD() {
  840. card_pwd := c.GetString("card_pwd")
  841. his_patient_id, _ := c.GetInt64("his_patient_id")
  842. admin_user_id, _ := c.GetInt64("admin_user_id")
  843. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  845. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  846. psn, _ := service.GetPsnByPatientId(his.PatientId)
  847. bas := strings.Split(psn.CardInfo, "|")
  848. basNumber := bas[2]
  849. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  850. var dat map[string]interface{}
  851. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  852. fmt.Println(dat)
  853. } else {
  854. fmt.Println(err)
  855. }
  856. userJSONBytes, _ := json.Marshal(dat)
  857. var res Result90991
  858. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  859. utils.ErrorLog("解析失败:%v", err)
  860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  861. return
  862. }
  863. if res.Infcode != 0 {
  864. c.ServeSuccessJSON(map[string]interface{}{
  865. "failed_code": -10,
  866. "msg": res.ErrMsg,
  867. })
  868. return
  869. } else {
  870. if res.Output.Result.SscnoCheckStat == "0" {
  871. var msg string
  872. switch res.Output.Result.CardStat {
  873. case "00":
  874. msg = "未激活"
  875. break
  876. case "10":
  877. msg = "激活"
  878. break
  879. case "20":
  880. msg = "窗口挂失"
  881. break
  882. case "21":
  883. msg = "电话挂失"
  884. break
  885. case "22":
  886. msg = "单位网上申报挂失"
  887. break
  888. case "23":
  889. msg = "保健办挂失"
  890. break
  891. case "24":
  892. msg = "个人网上挂失"
  893. break
  894. case "25":
  895. msg = "网上服务大厅挂失"
  896. break
  897. case "30":
  898. msg = "注销"
  899. break
  900. case "40":
  901. msg = "回收"
  902. break
  903. case "99":
  904. msg = "制卡中(无效卡)"
  905. break
  906. }
  907. c.ServeSuccessJSON(map[string]interface{}{
  908. "failed_code": -10,
  909. "msg": msg,
  910. })
  911. return
  912. } else {
  913. c.ServeSuccessJSON(map[string]interface{}{
  914. "msg": "校验成功",
  915. })
  916. return
  917. }
  918. }
  919. }
  920. func (c *HisApiController) CheckCardPWDTwo() {
  921. //card_pwd := c.GetString("card_pwd")
  922. //his_patient_id, _ := c.GetInt64("his_patient_id")
  923. admin_user_id, _ := c.GetInt64("admin_user_id")
  924. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  925. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  926. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  927. var dat map[string]interface{}
  928. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  929. fmt.Println(dat)
  930. } else {
  931. fmt.Println(err)
  932. }
  933. userJSONBytes, _ := json.Marshal(dat)
  934. var res Result90991
  935. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  936. utils.ErrorLog("解析失败:%v", err)
  937. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  938. return
  939. }
  940. if res.Infcode != 0 {
  941. c.ServeSuccessJSON(map[string]interface{}{
  942. "failed_code": -10,
  943. "msg": res.ErrMsg,
  944. })
  945. return
  946. } else {
  947. if res.Output.Result.SscnoCheckStat == "0" {
  948. var msg string
  949. switch res.Output.Result.CardStat {
  950. case "00":
  951. msg = "未激活"
  952. break
  953. case "10":
  954. msg = "激活"
  955. break
  956. case "20":
  957. msg = "窗口挂失"
  958. break
  959. case "21":
  960. msg = "电话挂失"
  961. break
  962. case "22":
  963. msg = "单位网上申报挂失"
  964. break
  965. case "23":
  966. msg = "保健办挂失"
  967. break
  968. case "24":
  969. msg = "个人网上挂失"
  970. break
  971. case "25":
  972. msg = "网上服务大厅挂失"
  973. break
  974. case "30":
  975. msg = "注销"
  976. break
  977. case "40":
  978. msg = "回收"
  979. break
  980. case "99":
  981. msg = "制卡中(无效卡)"
  982. break
  983. }
  984. c.ServeSuccessJSON(map[string]interface{}{
  985. "failed_code": -10,
  986. "msg": msg,
  987. })
  988. return
  989. } else {
  990. c.ServeSuccessJSON(map[string]interface{}{
  991. "msg": "校验成功",
  992. })
  993. return
  994. }
  995. }
  996. }
  997. func (c *HisApiController) ReadCard() {
  998. id_card_type, _ := c.GetInt64("id_card_type")
  999. admin_user_id, _ := c.GetInt64("admin_user_id")
  1000. certificates, _ := c.GetInt64("certificates")
  1001. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1002. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1003. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1004. switch id_card_type {
  1005. case 1:
  1006. if miConfig.MdtrtareaAdmvs == "421300" {
  1007. var res ResultTwo
  1008. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1009. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1010. "&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)
  1011. resp, requestErr := http.Get(api)
  1012. if requestErr != nil {
  1013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1014. return
  1015. }
  1016. body, ioErr := ioutil.ReadAll(resp.Body)
  1017. if ioErr != nil {
  1018. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1020. return
  1021. }
  1022. var respJSON map[string]interface{}
  1023. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1024. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1026. return
  1027. }
  1028. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1029. result, _ := json.Marshal(respJSON)
  1030. fmt.Println("log")
  1031. fmt.Println(string(result))
  1032. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1033. utils.ErrorLog("解析失败:%v", err)
  1034. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1035. return
  1036. }
  1037. if res.Infcode == 0 {
  1038. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1039. if err == gorm.ErrRecordNotFound {
  1040. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1041. return
  1042. } else if err != nil {
  1043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1044. return
  1045. } else {
  1046. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1047. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1048. infoStr := string(Iinfos)
  1049. idetinfoStr := string(Idetinfos)
  1050. psn := &models.HisPsn{
  1051. PsnNo: res.Output.Baseinfo.PsnNo,
  1052. Age: res.Output.Baseinfo.Age,
  1053. PatientId: patient.ID,
  1054. Certno: res.Output.Baseinfo.Certno,
  1055. Brdy: res.Output.Baseinfo.Brdy,
  1056. Gend: res.Output.Baseinfo.Gend,
  1057. Naty: res.Output.Baseinfo.Naty,
  1058. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1059. PsnName: res.Output.Baseinfo.PsnName,
  1060. Idetinfo: idetinfoStr,
  1061. Insuinfo: infoStr,
  1062. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1063. }
  1064. service.CreateHisPsn(psn)
  1065. c.ServeSuccessJSON(map[string]interface{}{
  1066. "patient": patient,
  1067. "number": res.Output.Baseinfo.Certno,
  1068. })
  1069. }
  1070. } else {
  1071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1072. return
  1073. }
  1074. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1075. var api string
  1076. if miConfig.MdtrtareaAdmvs == "320921" {
  1077. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1078. "&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
  1079. fmt.Println(api)
  1080. } else {
  1081. 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 +
  1082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1083. }
  1084. resp, requestErr := http.Get(api)
  1085. if requestErr != nil {
  1086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1087. return
  1088. }
  1089. body, ioErr := ioutil.ReadAll(resp.Body)
  1090. if ioErr != nil {
  1091. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return
  1094. }
  1095. var respJSON map[string]interface{}
  1096. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1097. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1099. return
  1100. }
  1101. var status string
  1102. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1103. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1104. //console.log()
  1105. fmt.Println("type===")
  1106. fmt.Println(card_type)
  1107. var token string
  1108. var res ResultTwo //1101结果
  1109. var res10265 ResultTwo10265 //1101结果
  1110. var card_info string //卡信息
  1111. var busi_card_info string
  1112. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1113. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1114. if status == "0" { //读卡成功
  1115. if card_type == "1" {
  1116. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1117. result, _ := json.Marshal(respJSON)
  1118. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1119. utils.ErrorLog("解析失败:%v", err)
  1120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1121. return
  1122. }
  1123. res.ErrMsg = res10265.ErrMsg
  1124. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1125. res.Infcode = infocode
  1126. res.Output = res10265.Output
  1127. res.InfRefmsgid = res10265.InfRefmsgid
  1128. } else {
  1129. //var card_info string //卡信息
  1130. //var busi_card_info string
  1131. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1132. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1133. //fmt.Println(card_info)
  1134. //fmt.Println(busi_card_info)
  1135. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1136. result, _ := json.Marshal(respJSON)
  1137. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1138. utils.ErrorLog("解析失败:%v", err)
  1139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1140. return
  1141. }
  1142. res.ErrMsg = res10265.ErrMsg
  1143. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1144. res.Infcode = infocode
  1145. res.Output = res10265.Output
  1146. res.InfRefmsgid = res10265.InfRefmsgid
  1147. }
  1148. if res.Infcode == 0 {
  1149. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1150. if err == gorm.ErrRecordNotFound {
  1151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1152. return
  1153. } else if err != nil {
  1154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1155. return
  1156. } else {
  1157. if card_type == "1" {
  1158. bas := strings.Split(card_info, "|")
  1159. basNumber := bas[2]
  1160. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1161. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1162. infoStr := string(Iinfos)
  1163. idetinfoStr := string(Idetinfos)
  1164. psn := &models.HisPsn{
  1165. PsnNo: res.Output.Baseinfo.PsnNo,
  1166. Age: res.Output.Baseinfo.Age,
  1167. PatientId: patient.ID,
  1168. Certno: res.Output.Baseinfo.Certno,
  1169. Brdy: res.Output.Baseinfo.Brdy,
  1170. Gend: res.Output.Baseinfo.Gend,
  1171. Naty: res.Output.Baseinfo.Naty,
  1172. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1173. PsnName: res.Output.Baseinfo.PsnName,
  1174. Idetinfo: idetinfoStr,
  1175. Insuinfo: infoStr,
  1176. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1177. CardInfo: card_info,
  1178. VerifyNumber: busi_card_info,
  1179. }
  1180. service.CreateHisPsn(psn)
  1181. var rf []*ResultFive
  1182. json.Unmarshal([]byte(infoStr), &rf)
  1183. var insutypes []*ResultFive
  1184. var insutype string
  1185. var is390 int = 0
  1186. var is310 int = 0
  1187. for _, item := range rf {
  1188. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1189. insutypes = append(insutypes, item)
  1190. }
  1191. }
  1192. if len(insutypes) == 1 {
  1193. insutype = insutypes[0].Insutype
  1194. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1195. } else {
  1196. for _, i := range insutypes {
  1197. if i.Insutype == "390" {
  1198. is390 = 1
  1199. }
  1200. if i.Insutype == "310" {
  1201. is310 = 1
  1202. }
  1203. }
  1204. }
  1205. if is390 == 1 {
  1206. insutype = "390"
  1207. }
  1208. if is310 == 1 {
  1209. insutype = "310"
  1210. }
  1211. if len(insutypes) == 0 {
  1212. insutype = "310"
  1213. }
  1214. c.ServeSuccessJSON(map[string]interface{}{
  1215. "patient": patient,
  1216. "number": basNumber,
  1217. "insutype": insutype,
  1218. })
  1219. } else {
  1220. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1221. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1222. infoStr := string(Iinfos)
  1223. idetinfoStr := string(Idetinfos)
  1224. psn := &models.HisPsn{
  1225. PsnNo: res.Output.Baseinfo.PsnNo,
  1226. Age: res.Output.Baseinfo.Age,
  1227. PatientId: patient.ID,
  1228. Certno: res.Output.Baseinfo.Certno,
  1229. Brdy: res.Output.Baseinfo.Brdy,
  1230. Gend: res.Output.Baseinfo.Gend,
  1231. Naty: res.Output.Baseinfo.Naty,
  1232. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1233. PsnName: res.Output.Baseinfo.PsnName,
  1234. Idetinfo: idetinfoStr,
  1235. Insuinfo: infoStr,
  1236. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1237. CardInfo: card_info,
  1238. VerifyNumber: token,
  1239. }
  1240. service.CreateHisPsn(psn)
  1241. c.ServeSuccessJSON(map[string]interface{}{
  1242. "patient": patient,
  1243. "number": token,
  1244. })
  1245. }
  1246. }
  1247. } else {
  1248. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1249. return
  1250. }
  1251. } else { //读卡失败
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1256. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1257. cardnum = DeleteExtraSpaceTwo(cardnum)
  1258. cardCode = DeleteExtraSpaceTwo(cardCode)
  1259. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1260. name = DeleteExtraSpaceTwo(name)
  1261. errmsg = DeleteExtraSpaceTwo(errmsg)
  1262. cardnum = Remove0000(cardnum)
  1263. cardCode = Remove0000(cardCode)
  1264. id_card_no = Remove0000(id_card_no)
  1265. name = Remove0000(name)
  1266. errmsg = Remove0000(errmsg)
  1267. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1268. result, _ := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1269. var dat map[string]interface{}
  1270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1271. fmt.Println(dat)
  1272. } else {
  1273. fmt.Println(err)
  1274. }
  1275. userJSONBytes, _ := json.Marshal(dat)
  1276. var res ResultTwo
  1277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. if res.Infcode == 0 {
  1283. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1284. if err == gorm.ErrRecordNotFound {
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1286. return
  1287. } else if err != nil {
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1289. return
  1290. } else {
  1291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1293. infoStr := string(Iinfos)
  1294. idetinfoStr := string(Idetinfos)
  1295. psn := &models.HisPsn{
  1296. PsnNo: res.Output.Baseinfo.PsnNo,
  1297. Age: res.Output.Baseinfo.Age,
  1298. PatientId: patient.ID,
  1299. Certno: res.Output.Baseinfo.Certno,
  1300. Brdy: res.Output.Baseinfo.Brdy,
  1301. Gend: res.Output.Baseinfo.Gend,
  1302. Naty: res.Output.Baseinfo.Naty,
  1303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1304. PsnName: res.Output.Baseinfo.PsnName,
  1305. Idetinfo: idetinfoStr,
  1306. Insuinfo: infoStr,
  1307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1308. CardInfo: basStr,
  1309. VerifyNumber: "",
  1310. }
  1311. service.CreateHisPsn(psn)
  1312. c.ServeSuccessJSON(map[string]interface{}{
  1313. "patient": patient,
  1314. "number": cardnum,
  1315. })
  1316. }
  1317. } else {
  1318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1319. return
  1320. }
  1321. } else {
  1322. if initFlag == 0 {
  1323. c.TestGetBasBaseInit()
  1324. }
  1325. basStr := c.GetBasBaseInfo()
  1326. if len(basStr) == 0 {
  1327. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1328. return
  1329. }
  1330. fmt.Println(basStr)
  1331. bas := strings.Split(basStr, "|")
  1332. basNumber := bas[1]
  1333. fmt.Println(basNumber)
  1334. card_sn := bas[3]
  1335. fmt.Println(card_sn)
  1336. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1337. var dat map[string]interface{}
  1338. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1339. fmt.Println(dat)
  1340. } else {
  1341. fmt.Println(err)
  1342. }
  1343. userJSONBytes, _ := json.Marshal(dat)
  1344. var res ResultTwo
  1345. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1346. utils.ErrorLog("解析失败:%v", err)
  1347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1348. return
  1349. }
  1350. if res.Infcode == 0 {
  1351. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1352. if err == gorm.ErrRecordNotFound {
  1353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1354. return
  1355. } else if err != nil {
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1357. return
  1358. } else {
  1359. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1360. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1361. infoStr := string(Iinfos)
  1362. idetinfoStr := string(Idetinfos)
  1363. psn := &models.HisPsn{
  1364. PsnNo: res.Output.Baseinfo.PsnNo,
  1365. Age: res.Output.Baseinfo.Age,
  1366. PatientId: patient.ID,
  1367. Certno: res.Output.Baseinfo.Certno,
  1368. Brdy: res.Output.Baseinfo.Brdy,
  1369. Gend: res.Output.Baseinfo.Gend,
  1370. Naty: res.Output.Baseinfo.Naty,
  1371. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1372. PsnName: res.Output.Baseinfo.PsnName,
  1373. Idetinfo: idetinfoStr,
  1374. Insuinfo: infoStr,
  1375. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1376. CardInfo: basStr,
  1377. VerifyNumber: "",
  1378. }
  1379. service.CreateHisPsn(psn)
  1380. c.ServeSuccessJSON(map[string]interface{}{
  1381. "patient": patient,
  1382. "number": basNumber,
  1383. })
  1384. }
  1385. } else {
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1387. return
  1388. }
  1389. break
  1390. }
  1391. case 2:
  1392. SFZStr := c.GetSFZBaseInfo()
  1393. id_card_str := strings.Split(SFZStr, "^")
  1394. id_card_number := id_card_str[0]
  1395. card_sn := ""
  1396. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1397. var dat map[string]interface{}
  1398. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1399. fmt.Println(dat)
  1400. } else {
  1401. fmt.Println(err)
  1402. }
  1403. userJSONBytes, _ := json.Marshal(dat)
  1404. var res ResultTwo
  1405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1406. utils.ErrorLog("解析失败:%v", err)
  1407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1408. return
  1409. }
  1410. if res.Infcode == 0 {
  1411. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1412. if err == gorm.ErrRecordNotFound {
  1413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1414. return
  1415. } else if err != nil {
  1416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1417. return
  1418. } else {
  1419. c.ServeSuccessJSON(map[string]interface{}{
  1420. "patient": patient,
  1421. "number": id_card_number,
  1422. })
  1423. }
  1424. } else {
  1425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1426. return
  1427. }
  1428. break
  1429. case 3:
  1430. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1431. var api string
  1432. if miConfig.MdtrtareaAdmvs == "320921" {
  1433. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1434. "&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
  1435. fmt.Println(api)
  1436. } else {
  1437. 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 +
  1438. "&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)
  1439. }
  1440. resp, requestErr := http.Get(api)
  1441. if requestErr != nil {
  1442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1443. return
  1444. }
  1445. body, ioErr := ioutil.ReadAll(resp.Body)
  1446. if ioErr != nil {
  1447. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1449. return
  1450. }
  1451. var respJSON map[string]interface{}
  1452. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1453. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1455. return
  1456. }
  1457. var status string
  1458. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1459. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1460. var token string
  1461. var res ResultTwo //1101结果
  1462. var res10265 ResultTwo10265 //1101结果
  1463. var card_info string //卡信息
  1464. var busi_card_info string
  1465. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1466. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1467. if status == "0" { //读卡成功
  1468. if card_type == "1" {
  1469. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1470. result, _ := json.Marshal(respJSON)
  1471. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1472. utils.ErrorLog("解析失败:%v", err)
  1473. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1474. return
  1475. }
  1476. res.ErrMsg = res10265.ErrMsg
  1477. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1478. res.Infcode = infocode
  1479. res.Output = res10265.Output
  1480. res.InfRefmsgid = res10265.InfRefmsgid
  1481. } else {
  1482. //var card_info string //卡信息
  1483. //var busi_card_info string
  1484. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1485. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1486. //fmt.Println(card_info)
  1487. //fmt.Println(busi_card_info)
  1488. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1489. result, _ := json.Marshal(respJSON)
  1490. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1491. utils.ErrorLog("解析失败:%v", err)
  1492. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1493. return
  1494. }
  1495. res.ErrMsg = res10265.ErrMsg
  1496. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1497. res.Infcode = infocode
  1498. res.Output = res10265.Output
  1499. res.InfRefmsgid = res10265.InfRefmsgid
  1500. }
  1501. if res.Infcode == 0 {
  1502. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1503. if err == gorm.ErrRecordNotFound {
  1504. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1505. return
  1506. } else if err != nil {
  1507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1508. return
  1509. } else {
  1510. if card_type == "1" {
  1511. bas := strings.Split(card_info, "|")
  1512. basNumber := bas[2]
  1513. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1514. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1515. infoStr := string(Iinfos)
  1516. idetinfoStr := string(Idetinfos)
  1517. psn := &models.HisPsn{
  1518. PsnNo: res.Output.Baseinfo.PsnNo,
  1519. Age: res.Output.Baseinfo.Age,
  1520. PatientId: patient.ID,
  1521. Certno: res.Output.Baseinfo.Certno,
  1522. Brdy: res.Output.Baseinfo.Brdy,
  1523. Gend: res.Output.Baseinfo.Gend,
  1524. Naty: res.Output.Baseinfo.Naty,
  1525. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1526. PsnName: res.Output.Baseinfo.PsnName,
  1527. Idetinfo: idetinfoStr,
  1528. Insuinfo: infoStr,
  1529. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1530. CardInfo: card_info,
  1531. VerifyNumber: busi_card_info,
  1532. }
  1533. service.CreateHisPsn(psn)
  1534. c.ServeSuccessJSON(map[string]interface{}{
  1535. "patient": patient,
  1536. "number": basNumber,
  1537. })
  1538. } else {
  1539. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1540. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1541. infoStr := string(Iinfos)
  1542. idetinfoStr := string(Idetinfos)
  1543. psn := &models.HisPsn{
  1544. PsnNo: res.Output.Baseinfo.PsnNo,
  1545. Age: res.Output.Baseinfo.Age,
  1546. PatientId: patient.ID,
  1547. Certno: res.Output.Baseinfo.Certno,
  1548. Brdy: res.Output.Baseinfo.Brdy,
  1549. Gend: res.Output.Baseinfo.Gend,
  1550. Naty: res.Output.Baseinfo.Naty,
  1551. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1552. PsnName: res.Output.Baseinfo.PsnName,
  1553. Idetinfo: idetinfoStr,
  1554. Insuinfo: infoStr,
  1555. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1556. CardInfo: card_info,
  1557. VerifyNumber: token,
  1558. }
  1559. service.CreateHisPsn(psn)
  1560. var rf []*ResultFive
  1561. json.Unmarshal([]byte(infoStr), &rf)
  1562. var insutypes []*ResultFive
  1563. var insutype string
  1564. var is390 int = 0
  1565. var is310 int = 0
  1566. for _, item := range rf {
  1567. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1568. insutypes = append(insutypes, item)
  1569. }
  1570. }
  1571. if len(insutypes) == 1 {
  1572. insutype = insutypes[0].Insutype
  1573. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1574. } else {
  1575. for _, i := range insutypes {
  1576. if i.Insutype == "390" {
  1577. is390 = 1
  1578. }
  1579. if i.Insutype == "310" {
  1580. is310 = 1
  1581. }
  1582. }
  1583. }
  1584. if is390 == 1 {
  1585. insutype = "390"
  1586. }
  1587. if is310 == 1 {
  1588. insutype = "310"
  1589. }
  1590. if len(insutypes) == 0 {
  1591. insutype = "310"
  1592. }
  1593. c.ServeSuccessJSON(map[string]interface{}{
  1594. "patient": patient,
  1595. "number": token,
  1596. "insutype": insutype,
  1597. })
  1598. }
  1599. }
  1600. } else {
  1601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1602. return
  1603. }
  1604. } else { //读卡失败
  1605. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1606. return
  1607. }
  1608. }
  1609. break
  1610. case 4:
  1611. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1612. var api string
  1613. if miConfig.MdtrtareaAdmvs == "320921" {
  1614. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1615. "&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
  1616. fmt.Println(api)
  1617. } else {
  1618. 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 +
  1619. "&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)
  1620. }
  1621. resp, requestErr := http.Get(api)
  1622. if requestErr != nil {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1624. return
  1625. }
  1626. body, ioErr := ioutil.ReadAll(resp.Body)
  1627. if ioErr != nil {
  1628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1630. return
  1631. }
  1632. var respJSON map[string]interface{}
  1633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1636. return
  1637. }
  1638. var status string
  1639. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1640. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1641. var token string
  1642. var res ResultTwo //1101结果
  1643. var res10265 ResultTwo10265 //1101结果
  1644. if status == "0" { //读卡成功
  1645. var card_info string //卡信息
  1646. var busi_card_info string
  1647. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1648. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1649. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1650. fmt.Println(card_info)
  1651. fmt.Println(busi_card_info)
  1652. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1653. result, _ := json.Marshal(respJSON)
  1654. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1655. utils.ErrorLog("解析失败:%v", err)
  1656. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1657. return
  1658. }
  1659. res.ErrMsg = res10265.ErrMsg
  1660. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1661. res.Infcode = infocode
  1662. res.Output = res10265.Output
  1663. res.InfRefmsgid = res10265.InfRefmsgid
  1664. if res.Infcode == 0 {
  1665. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1666. if err == gorm.ErrRecordNotFound {
  1667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1668. return
  1669. } else if err != nil {
  1670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1671. return
  1672. } else {
  1673. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1674. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1675. infoStr := string(Iinfos)
  1676. idetinfoStr := string(Idetinfos)
  1677. psn := &models.HisPsn{
  1678. PsnNo: res.Output.Baseinfo.PsnNo,
  1679. Age: res.Output.Baseinfo.Age,
  1680. PatientId: patient.ID,
  1681. Certno: res.Output.Baseinfo.Certno,
  1682. Brdy: res.Output.Baseinfo.Brdy,
  1683. Gend: res.Output.Baseinfo.Gend,
  1684. Naty: res.Output.Baseinfo.Naty,
  1685. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1686. PsnName: res.Output.Baseinfo.PsnName,
  1687. Idetinfo: idetinfoStr,
  1688. Insuinfo: infoStr,
  1689. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1690. CardInfo: card_info,
  1691. VerifyNumber: token,
  1692. }
  1693. service.CreateHisPsn(psn)
  1694. c.ServeSuccessJSON(map[string]interface{}{
  1695. "patient": patient,
  1696. "number": token,
  1697. })
  1698. }
  1699. } else {
  1700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1701. return
  1702. }
  1703. } else { //读卡失败
  1704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1705. return
  1706. }
  1707. }
  1708. break
  1709. }
  1710. }
  1711. var initFlag int64 = 0
  1712. func (c *HisApiController) TestGetBasBaseInit() {
  1713. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1714. Iinit := DllDef.MustFindProc("Init")
  1715. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1716. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1717. if ret != 0 {
  1718. fmt.Println("SSCard的报错原因:", err)
  1719. fmt.Println("SSCard的运算结果为:", ret)
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1721. return
  1722. }
  1723. result := int(ret)
  1724. fmt.Println("SSCard的运算结果为1:", result)
  1725. initFlag = 1
  1726. return
  1727. }
  1728. func (c *HisApiController) GetSFZBaseInfo() string {
  1729. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1730. readCard := DllDef.MustFindProc("ReadSFZ")
  1731. if readCard == nil {
  1732. fmt.Println("readcard is nil")
  1733. readCard = DllDef.MustFindProc("ReadSFZ")
  1734. }
  1735. str := make([]byte, 256)
  1736. str1 := make([]byte, 256)
  1737. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1738. fmt.Println(r)
  1739. return string(str)
  1740. }
  1741. func (c *HisApiController) GetBasBaseInfo() string {
  1742. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1743. readCard := DllDef.MustFindProc("ReadCardBas")
  1744. if readCard == nil {
  1745. fmt.Println("readcard is nil")
  1746. readCard = DllDef.MustFindProc("ReadCardBas")
  1747. }
  1748. str := make([]byte, 1024)
  1749. str1 := make([]byte, 1024)
  1750. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1751. fmt.Println(string(str1))
  1752. fmt.Println(string(str))
  1753. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1754. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1755. if ret2 != 0 {
  1756. return ""
  1757. }
  1758. return string(str)
  1759. }
  1760. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1761. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1762. readCard := DllDef.MustFindProc("read_cardinfo")
  1763. if readCard == nil {
  1764. fmt.Println("readcard is nil")
  1765. readCard = DllDef.MustFindProc("read_cardinfo")
  1766. }
  1767. str := make([]byte, 1024) //卡号
  1768. str1 := make([]byte, 1024) //卡识别码
  1769. str2 := make([]byte, 1024) //身份证号
  1770. str3 := make([]byte, 1024) //姓名
  1771. str4 := make([]byte, 1024) //错误信息
  1772. 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])))
  1773. fmt.Println(string(str1))
  1774. fmt.Println(string(str))
  1775. fmt.Println(string(str2))
  1776. fmt.Println(string(str3))
  1777. fmt.Println(string(str4))
  1778. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1779. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1780. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1781. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1782. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1783. if ret2 != 0 {
  1784. return "", "", "", "", ""
  1785. }
  1786. return string(str), string(str1), string(str2), string(str3), string(str4)
  1787. }
  1788. type CustomFundPay struct {
  1789. FundPayType string `json:"fund_pay_type"`
  1790. FundPayamt float64 `json:"fund_payamt"`
  1791. }
  1792. func (c *HisApiController) GetSettleList() {
  1793. order_id, _ := c.GetInt64("order_id")
  1794. admin_user_id, _ := c.GetInt64("admin_user_id")
  1795. order, _ := service.GetHisOrderByIDTwo(order_id)
  1796. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1797. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1798. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1799. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1800. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1801. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1802. if order.ID == 0 {
  1803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1804. return
  1805. }
  1806. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1807. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1808. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1809. fmt.Println(count)
  1810. var zero string
  1811. number := count + 1
  1812. if number >= 1000 {
  1813. zero = "0000" + strconv.FormatInt(number, 10)
  1814. } else if number >= 10000 {
  1815. zero = "000" + strconv.FormatInt(number, 10)
  1816. } else if number >= 100000 {
  1817. zero = "00" + strconv.FormatInt(number, 10)
  1818. } else if number >= 1000000 {
  1819. zero = "0" + strconv.FormatInt(number, 10)
  1820. } else {
  1821. zero = strconv.FormatInt(number, 10)
  1822. }
  1823. fmt.Println(zero)
  1824. struct4101 := service.Struct4101{
  1825. PsnNo: order.PsnNo,
  1826. MdtrtId: order.MdtrtId,
  1827. SetlId: order.SetlId,
  1828. PsnName: order.PsnName,
  1829. Gend: order.Gend,
  1830. Brdy: his.Brdy,
  1831. Age: his.Age,
  1832. Naty: order.Naty,
  1833. PatnCertType: "01",
  1834. Certno: order.Certno,
  1835. Prfs: "90",
  1836. ConerName: roles[0].UserName,
  1837. PatnRlts: "99",
  1838. ConerAddr: miConfig.OrgName,
  1839. ConerTel: admin.Mobile,
  1840. HiType: order.Insutype,
  1841. Insuplc: miConfig.InsuplcAdmdvs,
  1842. MaindiagFlag: "1",
  1843. BillCode: last_order.FaPiaoCode,
  1844. BillNo: zero,
  1845. BizSn: order.Number,
  1846. PsnSelfPay: order.PsnPartAmt,
  1847. PsnOwnPay: order.PsnPartAmt,
  1848. AcctPay: order.AcctPay,
  1849. PsnCashpay: order.PsnCashPay,
  1850. HiPaymtd: "1",
  1851. Hsorg: miConfig.InsuplcAdmdvs,
  1852. HsorgOpter: miConfig.InsuplcAdmdvs,
  1853. MedinsFillPsn: curRoles.UserName,
  1854. MedinsFillDept: depart.Name,
  1855. IptMedType: "2",
  1856. }
  1857. struct4101.SetlBegnDate = order.SetlTime
  1858. struct4101.SetlEndDate = order.SetlTime
  1859. time_arr := strings.Split(order.SetlTime, " ")
  1860. struct4101.AdmTime = time_arr[0]
  1861. struct4101.AdmEndTime = time_arr[0]
  1862. var rf []CustomFundPay
  1863. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1864. var tempFunPays []service.CustomStruct
  1865. for _, item := range rf {
  1866. var tempFunPay service.CustomStruct
  1867. tempFunPay.FundPayamt = item.FundPayamt
  1868. tempFunPay.FundPayType = item.FundPayType
  1869. tempFunPays = append(tempFunPays, tempFunPay)
  1870. }
  1871. struct4101.CustomStruct = tempFunPays
  1872. var tempDiaginfos []service.DiaginfoStructTwo
  1873. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1874. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1875. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1876. var config []*models.HisXtDiagnoseConfig
  1877. for _, item := range diagnosis_ids {
  1878. id, _ := strconv.ParseInt(item, 10, 64)
  1879. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1880. config = append(config, &diagnosisConfig)
  1881. }
  1882. for index, item := range config {
  1883. if index == 0 {
  1884. var tempDiaginfo service.DiaginfoStructTwo
  1885. tempDiaginfo.DiagCode = item.CountryCode
  1886. tempDiaginfo.DiagName = item.CountryContentName
  1887. tempDiaginfo.DiagType = "1"
  1888. tempDiaginfo.MaindiagFlag = "1"
  1889. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1890. } else {
  1891. var tempDiaginfo service.DiaginfoStructTwo
  1892. tempDiaginfo.DiagCode = item.CountryCode
  1893. tempDiaginfo.DiagName = item.CountryContentName
  1894. tempDiaginfo.DiagType = "2"
  1895. tempDiaginfo.MaindiagFlag = "0"
  1896. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1897. }
  1898. }
  1899. struct4101.Diseinfo = tempDiaginfos
  1900. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1901. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1902. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1903. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1904. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1905. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1906. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1907. var iteminfo service.IteminfoStruct
  1908. var bedCostTotal float64 = 0 //床位总费
  1909. var bedCostSelfTotal float64 = 0 //床位自费
  1910. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1911. var operationCostTotal float64 = 0 //手术费
  1912. var operationCostSelfTotal float64 = 0 //手术费
  1913. var operationCostPartSelfTotal float64 = 0 //手术费
  1914. var otherCostTotal float64 = 0 //其他费用
  1915. var otherCostSelfTotal float64 = 0 //其他费用
  1916. var otherCostPartSelfTotal float64 = 0 //其他费用
  1917. var materialCostTotal float64 = 0 //材料费
  1918. var materialCostSelfTotal float64 = 0 //材料费
  1919. var materialCostPartSelfTotal float64 = 0 //材料费
  1920. var westernMedicineCostTotal float64 = 0 //西药费
  1921. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1922. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1923. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1924. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1925. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1926. var checkCostTotal float64 = 0 //检查费
  1927. var checkCostSelfTotal float64 = 0 //检查费
  1928. var checkCostPartSelfTotal float64 = 0 //检查费
  1929. var laboratoryCostTotal float64 = 0 //化验费
  1930. var laboratoryCostSelfTotal float64 = 0 //化验费
  1931. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1932. var treatCostTotal float64 = 0 //治疗费用
  1933. var treatCostSelfTotal float64 = 0 //治疗费用
  1934. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1935. decimal.DivisionPrecision = 2
  1936. var bed_fulamt_ownpay_amt float64 = 0
  1937. var operation_fulamt_ownpay_amt float64 = 0
  1938. var other_fulamt_ownpay_amt float64 = 0
  1939. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1940. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1941. var check_fulamt_ownpay_amt float64 = 0
  1942. var material_fulamt_ownpay_amt float64 = 0
  1943. var laboratory_fulamt_ownpay_amt float64 = 0
  1944. var treat_fulamt_ownpay_amt float64 = 0
  1945. var bed_claa_sunmfee float64 = 0
  1946. var bed_clab_amt float64 = 0
  1947. var bed_other_amt float64 = 0
  1948. var operation_claa_sunmfee float64 = 0
  1949. var operation_clab_amt float64 = 0
  1950. var operation_other_amt float64 = 0
  1951. var other_claa_sunmfee float64 = 0
  1952. var other_clab_amt float64 = 0
  1953. var other_other_amt float64 = 0
  1954. var westernMedicine_claa_sunmfee float64 = 0
  1955. var westernMedicine_clab_amt float64 = 0
  1956. var westernMedicine_other_amt float64 = 0
  1957. var chineseTraditional_claa_sunmfee float64 = 0
  1958. var chineseTraditional_clab_amt float64 = 0
  1959. var chineseTraditional_other_amt float64 = 0
  1960. var check_claa_sunmfee float64 = 0
  1961. var check_clab_amt float64 = 0
  1962. var check_other_amt float64 = 0
  1963. var material_claa_sunmfee float64 = 0
  1964. var material_clab_amt float64 = 0
  1965. var material_other_amt float64 = 0
  1966. var laboratory_claa_sunmfee float64 = 0
  1967. var laboratory_clab_amt float64 = 0
  1968. var laboratory_other_amt float64 = 0
  1969. var treat_claa_sunmfee float64 = 0
  1970. var treat_clab_amt float64 = 0
  1971. var treat_other_amt float64 = 0
  1972. for _, item := range order.HisOrderInfo {
  1973. if item.MedChrgitmType == "01" { //床位费
  1974. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1975. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1976. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1978. if item.ChrgitmLv == "1" {
  1979. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1980. }
  1981. if item.ChrgitmLv == "2" {
  1982. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1983. }
  1984. if item.ChrgitmLv == "3" {
  1985. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1986. }
  1987. }
  1988. if item.MedChrgitmType == "03" { //检查费
  1989. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1990. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1991. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1993. if item.ChrgitmLv == "1" {
  1994. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1995. }
  1996. if item.ChrgitmLv == "2" {
  1997. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1998. }
  1999. if item.ChrgitmLv == "3" {
  2000. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2001. }
  2002. }
  2003. if item.MedChrgitmType == "04" { //化验费
  2004. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2005. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2006. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2008. if item.ChrgitmLv == "1" {
  2009. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2010. }
  2011. if item.ChrgitmLv == "2" {
  2012. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2013. }
  2014. if item.ChrgitmLv == "3" {
  2015. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2016. }
  2017. }
  2018. if item.MedChrgitmType == "05" { //治疗费
  2019. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2020. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2021. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2022. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2023. if item.ChrgitmLv == "1" {
  2024. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2025. }
  2026. if item.ChrgitmLv == "2" {
  2027. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2028. }
  2029. if item.ChrgitmLv == "3" {
  2030. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2031. }
  2032. }
  2033. if item.MedChrgitmType == "06" { //手术费
  2034. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2035. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2036. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2037. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2038. if item.ChrgitmLv == "1" {
  2039. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2040. }
  2041. if item.ChrgitmLv == "2" {
  2042. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2043. }
  2044. if item.ChrgitmLv == "3" {
  2045. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2046. }
  2047. }
  2048. if item.MedChrgitmType == "08" { //材料费
  2049. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2050. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2051. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2052. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2053. if item.ChrgitmLv == "1" {
  2054. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2055. }
  2056. if item.ChrgitmLv == "2" {
  2057. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2058. }
  2059. if item.ChrgitmLv == "3" {
  2060. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2061. }
  2062. }
  2063. if item.MedChrgitmType == "09" { //西药费
  2064. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2065. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2066. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2067. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2068. if item.ChrgitmLv == "1" {
  2069. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2070. }
  2071. if item.ChrgitmLv == "2" {
  2072. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2073. }
  2074. if item.ChrgitmLv == "3" {
  2075. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2076. }
  2077. }
  2078. if item.MedChrgitmType == "11" { //中成费
  2079. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2080. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2081. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2082. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2083. if item.ChrgitmLv == "1" {
  2084. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2085. }
  2086. if item.ChrgitmLv == "2" {
  2087. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2088. }
  2089. if item.ChrgitmLv == "3" {
  2090. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2091. }
  2092. }
  2093. if item.MedChrgitmType == "14" { //其他费
  2094. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2095. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2096. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2097. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2098. if item.ChrgitmLv == "1" {
  2099. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2100. }
  2101. if item.ChrgitmLv == "2" {
  2102. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2103. }
  2104. if item.ChrgitmLv == "3" {
  2105. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2106. }
  2107. }
  2108. }
  2109. var iteminfoStructs []service.IteminfoStruct
  2110. if bedCostTotal != 0 {
  2111. iteminfo.MedChrgitm = "01"
  2112. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2113. iteminfo.Amt = bedCostTotal
  2114. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2115. iteminfo.ClabAmt = bed_clab_amt
  2116. iteminfo.OthAmt = bed_other_amt
  2117. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2118. }
  2119. if checkCostTotal != 0 {
  2120. iteminfo.MedChrgitm = "03"
  2121. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2122. iteminfo.Amt = checkCostTotal
  2123. iteminfo.ClaaSumfee = check_claa_sunmfee
  2124. iteminfo.ClabAmt = check_clab_amt
  2125. iteminfo.OthAmt = check_other_amt
  2126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2127. }
  2128. if laboratoryCostTotal != 0 {
  2129. iteminfo.MedChrgitm = "04"
  2130. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2131. iteminfo.Amt = laboratoryCostTotal
  2132. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2133. iteminfo.ClabAmt = laboratory_clab_amt
  2134. iteminfo.OthAmt = laboratory_other_amt
  2135. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2136. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2137. }
  2138. if treatCostTotal != 0 {
  2139. iteminfo.MedChrgitm = "05"
  2140. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2141. iteminfo.Amt = treatCostTotal
  2142. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2143. iteminfo.ClabAmt = treat_clab_amt
  2144. iteminfo.OthAmt = treat_other_amt
  2145. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2146. //(struct4101.IteminfoStruct, iteminfo)
  2147. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2148. }
  2149. if operationCostTotal != 0 {
  2150. iteminfo.MedChrgitm = "06"
  2151. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2152. iteminfo.Amt = operationCostTotal
  2153. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2154. iteminfo.ClabAmt = operation_clab_amt
  2155. iteminfo.OthAmt = operation_other_amt
  2156. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2157. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2158. }
  2159. if materialCostTotal != 0 {
  2160. iteminfo.MedChrgitm = "08"
  2161. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2162. iteminfo.Amt = materialCostTotal
  2163. iteminfo.ClaaSumfee = material_claa_sunmfee
  2164. iteminfo.ClabAmt = material_clab_amt
  2165. iteminfo.OthAmt = material_other_amt
  2166. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2167. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2168. }
  2169. if westernMedicineCostTotal != 0 {
  2170. iteminfo.MedChrgitm = "09"
  2171. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2172. iteminfo.Amt = westernMedicineCostTotal
  2173. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2174. iteminfo.ClabAmt = westernMedicine_clab_amt
  2175. iteminfo.OthAmt = westernMedicine_other_amt
  2176. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2177. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2178. }
  2179. if chineseTraditionalMedicineCostTotal != 0 {
  2180. iteminfo.MedChrgitm = "11"
  2181. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2182. iteminfo.Amt = westernMedicineCostTotal
  2183. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2184. iteminfo.ClabAmt = westernMedicine_clab_amt
  2185. iteminfo.OthAmt = westernMedicine_other_amt
  2186. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2187. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2188. }
  2189. if otherCostTotal != 0 {
  2190. iteminfo.MedChrgitm = "14"
  2191. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2192. iteminfo.Amt = otherCostTotal
  2193. iteminfo.ClaaSumfee = other_claa_sunmfee
  2194. iteminfo.ClabAmt = other_clab_amt
  2195. iteminfo.OthAmt = other_other_amt
  2196. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2197. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2198. }
  2199. struct4101.IteminfoStruct = iteminfoStructs
  2200. struct4101.Ntly = "中国"
  2201. struct4101.AdmCaty = "A03.06"
  2202. var res ResultSeventeen
  2203. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2204. var resOther ResultSeventeenOther
  2205. var pp models.PublicParams
  2206. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2207. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2208. pp.FixmedinsName = miConfig.OrgName
  2209. pp.FixmedinsCode = miConfig.Code
  2210. pp.RequestUrl = miConfig.Url
  2211. pp.Cainfo = miConfig.Cainfo
  2212. pp.SecretKey = miConfig.SecretKey
  2213. pp.AccessKey = miConfig.AccessKey
  2214. pp.OpterName = curRoles.UserName
  2215. client := &http.Client{}
  2216. var req *http.Request
  2217. data := make(map[string]interface{})
  2218. data["struct4101"] = struct4101
  2219. data["pp"] = pp
  2220. bytesData, _ := json.Marshal(data)
  2221. if miConfig.MdtrtareaAdmvs == "320921" {
  2222. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2223. } else {
  2224. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2225. }
  2226. resp, _ := client.Do(req)
  2227. defer resp.Body.Close()
  2228. body, ioErr := ioutil.ReadAll(resp.Body)
  2229. if ioErr != nil {
  2230. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2231. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2232. return
  2233. }
  2234. var respJSON map[string]interface{}
  2235. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2236. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2238. return
  2239. }
  2240. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2241. userJSONBytes, _ := json.Marshal(respJSON)
  2242. fmt.Println("log")
  2243. fmt.Println(string(userJSONBytes))
  2244. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2245. utils.ErrorLog("解析失败:%v", err)
  2246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2247. return
  2248. }
  2249. res.InfRefmsgid = resOther.InfRefmsgid
  2250. res.Output = resOther.Output
  2251. res.ErrMsg = resOther.ErrMsg
  2252. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2253. res.Infcode = infocode
  2254. } else {
  2255. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2256. var dat map[string]interface{}
  2257. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2258. fmt.Println(dat)
  2259. } else {
  2260. fmt.Println(err)
  2261. }
  2262. userJSONBytes, _ := json.Marshal(dat)
  2263. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2264. utils.ErrorLog("解析失败:%v", err)
  2265. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2266. return
  2267. }
  2268. }
  2269. if res.Infcode != 0 {
  2270. c.ServeSuccessJSON(map[string]interface{}{
  2271. "failed_code": -10,
  2272. "msg": res.ErrMsg,
  2273. })
  2274. return
  2275. } else {
  2276. order.FaPiaoNumber = zero
  2277. order.FaPiaoCode = last_order.FaPiaoCode
  2278. service.UpdateOrder(order)
  2279. hisFundSettleListResult := &models.HisFundSettleListResult{
  2280. Number: res.Output.SetlListId,
  2281. Status: 1,
  2282. Ctime: time.Now().Unix(),
  2283. Mtime: time.Now().Unix(),
  2284. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2285. IsUpload: 1,
  2286. OrderId: order_id,
  2287. }
  2288. service.CreateUploadRecord(hisFundSettleListResult)
  2289. c.ServeSuccessJSON(map[string]interface{}{
  2290. "msg": "上传成功",
  2291. "result": hisFundSettleListResult,
  2292. })
  2293. return
  2294. }
  2295. }
  2296. func (c *HisApiController) GetSettleListHospital() {
  2297. order_id, _ := c.GetInt64("order_id")
  2298. admin_user_id, _ := c.GetInt64("admin_user_id")
  2299. order, _ := service.GetHisOrderByIDTwo(order_id)
  2300. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2301. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2302. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2303. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2304. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2305. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2306. if order.ID == 0 {
  2307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2308. return
  2309. }
  2310. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2311. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2312. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2313. fmt.Println(count)
  2314. var zero string
  2315. number := count + 1
  2316. if number >= 1000 {
  2317. zero = "0000" + strconv.FormatInt(number, 10)
  2318. } else if number >= 10000 {
  2319. zero = "000" + strconv.FormatInt(number, 10)
  2320. } else if number >= 100000 {
  2321. zero = "00" + strconv.FormatInt(number, 10)
  2322. } else if number >= 1000000 {
  2323. zero = "0" + strconv.FormatInt(number, 10)
  2324. } else {
  2325. zero = strconv.FormatInt(number, 10)
  2326. }
  2327. fmt.Println(zero)
  2328. struct4101 := service.Struct4101{
  2329. PsnNo: order.PsnNo,
  2330. MdtrtId: order.MdtrtId,
  2331. SetlId: order.SetlId,
  2332. PsnName: order.PsnName,
  2333. Gend: order.Gend,
  2334. Brdy: his.Brdy,
  2335. Age: int64(order.Age),
  2336. Naty: order.Naty,
  2337. PatnCertType: "01",
  2338. Certno: order.Certno,
  2339. Prfs: "90",
  2340. ConerName: roles[0].UserName,
  2341. PatnRlts: "99",
  2342. ConerAddr: miConfig.OrgName,
  2343. ConerTel: admin.Mobile,
  2344. HiType: order.Insutype,
  2345. Insuplc: miConfig.InsuplcAdmdvs,
  2346. MaindiagFlag: "1",
  2347. BillCode: last_order.FaPiaoCode,
  2348. BillNo: zero,
  2349. BizSn: order.Number,
  2350. PsnSelfPay: order.PsnPartAmt,
  2351. PsnOwnPay: order.PsnPartAmt,
  2352. AcctPay: order.AcctPay,
  2353. PsnCashpay: order.PsnCashPay,
  2354. HiPaymtd: "1",
  2355. Hsorg: miConfig.InsuplcAdmdvs,
  2356. HsorgOpter: miConfig.InsuplcAdmdvs,
  2357. MedinsFillPsn: curRoles.UserName,
  2358. MedinsFillDept: depart.Name,
  2359. IptMedType: "2",
  2360. AdmTime: his.InHosptialTime,
  2361. AdmEndTime: his.OutHosptialTime,
  2362. }
  2363. struct4101.SetlBegnDate = order.SetlTime
  2364. struct4101.SetlEndDate = order.SetlTime
  2365. var rf []CustomFundPay
  2366. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2367. var tempFunPays []service.CustomStruct
  2368. for _, item := range rf {
  2369. var tempFunPay service.CustomStruct
  2370. tempFunPay.FundPayamt = item.FundPayamt
  2371. tempFunPay.FundPayType = item.FundPayType
  2372. tempFunPays = append(tempFunPays, tempFunPay)
  2373. }
  2374. struct4101.CustomStruct = tempFunPays
  2375. var tempDiaginfos []service.DiaginfoStructTwo
  2376. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2377. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2378. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2379. var config []*models.HisXtDiagnoseConfig
  2380. for _, item := range diagnosis_ids {
  2381. id, _ := strconv.ParseInt(item, 10, 64)
  2382. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2383. config = append(config, &diagnosisConfig)
  2384. }
  2385. for index, item := range config {
  2386. if index == 0 {
  2387. var tempDiaginfo service.DiaginfoStructTwo
  2388. tempDiaginfo.DiagCode = item.CountryCode
  2389. tempDiaginfo.DiagName = item.CountryContentName
  2390. tempDiaginfo.DiagType = "1"
  2391. tempDiaginfo.MaindiagFlag = "1"
  2392. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2393. } else {
  2394. var tempDiaginfo service.DiaginfoStructTwo
  2395. tempDiaginfo.DiagCode = item.CountryCode
  2396. tempDiaginfo.DiagName = item.CountryContentName
  2397. tempDiaginfo.DiagType = "2"
  2398. tempDiaginfo.MaindiagFlag = "0"
  2399. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2400. }
  2401. }
  2402. struct4101.Diseinfo = tempDiaginfos
  2403. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2404. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2405. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2406. tempOpspdiseinfo2.OprnOprtCode = ""
  2407. tempOpspdiseinfo2.OprnOprtName = ""
  2408. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2409. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2410. var iteminfo service.IteminfoStruct
  2411. var bedCostTotal float64 = 0 //床位总费
  2412. var bedCostSelfTotal float64 = 0 //床位自费
  2413. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2414. var operationCostTotal float64 = 0 //手术费
  2415. var operationCostSelfTotal float64 = 0 //手术费
  2416. var operationCostPartSelfTotal float64 = 0 //手术费
  2417. var otherCostTotal float64 = 0 //其他费用
  2418. var otherCostSelfTotal float64 = 0 //其他费用
  2419. var otherCostPartSelfTotal float64 = 0 //其他费用
  2420. var materialCostTotal float64 = 0 //材料费
  2421. var materialCostSelfTotal float64 = 0 //材料费
  2422. var materialCostPartSelfTotal float64 = 0 //材料费
  2423. var westernMedicineCostTotal float64 = 0 //西药费
  2424. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2425. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2426. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2427. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2428. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2429. var checkCostTotal float64 = 0 //检查费
  2430. var checkCostSelfTotal float64 = 0 //检查费
  2431. var checkCostPartSelfTotal float64 = 0 //检查费
  2432. var laboratoryCostTotal float64 = 0 //化验费
  2433. var laboratoryCostSelfTotal float64 = 0 //化验费
  2434. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2435. var treatCostTotal float64 = 0 //治疗费用
  2436. var treatCostSelfTotal float64 = 0 //治疗费用
  2437. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2438. decimal.DivisionPrecision = 2
  2439. var bed_fulamt_ownpay_amt float64 = 0
  2440. var operation_fulamt_ownpay_amt float64 = 0
  2441. var other_fulamt_ownpay_amt float64 = 0
  2442. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2443. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2444. var check_fulamt_ownpay_amt float64 = 0
  2445. var material_fulamt_ownpay_amt float64 = 0
  2446. var laboratory_fulamt_ownpay_amt float64 = 0
  2447. var treat_fulamt_ownpay_amt float64 = 0
  2448. var bed_claa_sunmfee float64 = 0
  2449. var bed_clab_amt float64 = 0
  2450. var bed_other_amt float64 = 0
  2451. var operation_claa_sunmfee float64 = 0
  2452. var operation_clab_amt float64 = 0
  2453. var operation_other_amt float64 = 0
  2454. var other_claa_sunmfee float64 = 0
  2455. var other_clab_amt float64 = 0
  2456. var other_other_amt float64 = 0
  2457. var westernMedicine_claa_sunmfee float64 = 0
  2458. var westernMedicine_clab_amt float64 = 0
  2459. var westernMedicine_other_amt float64 = 0
  2460. var chineseTraditional_claa_sunmfee float64 = 0
  2461. var chineseTraditional_clab_amt float64 = 0
  2462. var chineseTraditional_other_amt float64 = 0
  2463. var check_claa_sunmfee float64 = 0
  2464. var check_clab_amt float64 = 0
  2465. var check_other_amt float64 = 0
  2466. var material_claa_sunmfee float64 = 0
  2467. var material_clab_amt float64 = 0
  2468. var material_other_amt float64 = 0
  2469. var laboratory_claa_sunmfee float64 = 0
  2470. var laboratory_clab_amt float64 = 0
  2471. var laboratory_other_amt float64 = 0
  2472. var treat_claa_sunmfee float64 = 0
  2473. var treat_clab_amt float64 = 0
  2474. var treat_other_amt float64 = 0
  2475. for _, item := range order.HisOrderInfo {
  2476. if item.MedChrgitmType == "01" { //床位费
  2477. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2478. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2479. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2480. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2481. if item.ChrgitmLv == "1" {
  2482. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2483. }
  2484. if item.ChrgitmLv == "2" {
  2485. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2486. }
  2487. if item.ChrgitmLv == "3" {
  2488. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2489. }
  2490. }
  2491. if item.MedChrgitmType == "03" { //检查费
  2492. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2493. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2494. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2495. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2496. if item.ChrgitmLv == "1" {
  2497. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2498. }
  2499. if item.ChrgitmLv == "2" {
  2500. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2501. }
  2502. if item.ChrgitmLv == "3" {
  2503. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2504. }
  2505. }
  2506. if item.MedChrgitmType == "04" { //化验费
  2507. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2508. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2509. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2510. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2511. if item.ChrgitmLv == "1" {
  2512. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2513. }
  2514. if item.ChrgitmLv == "2" {
  2515. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2516. }
  2517. if item.ChrgitmLv == "3" {
  2518. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2519. }
  2520. }
  2521. if item.MedChrgitmType == "05" { //治疗费
  2522. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2523. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2524. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2525. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2526. if item.ChrgitmLv == "1" {
  2527. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2528. }
  2529. if item.ChrgitmLv == "2" {
  2530. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2531. }
  2532. if item.ChrgitmLv == "3" {
  2533. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2534. }
  2535. }
  2536. if item.MedChrgitmType == "06" { //手术费
  2537. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2538. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2539. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2540. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2541. if item.ChrgitmLv == "1" {
  2542. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2543. }
  2544. if item.ChrgitmLv == "2" {
  2545. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2546. }
  2547. if item.ChrgitmLv == "3" {
  2548. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2549. }
  2550. }
  2551. if item.MedChrgitmType == "08" { //材料费
  2552. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2553. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2554. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2555. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2556. if item.ChrgitmLv == "1" {
  2557. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2558. }
  2559. if item.ChrgitmLv == "2" {
  2560. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2561. }
  2562. if item.ChrgitmLv == "3" {
  2563. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2564. }
  2565. }
  2566. if item.MedChrgitmType == "09" { //西药费
  2567. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2568. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2569. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2570. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2571. if item.ChrgitmLv == "1" {
  2572. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2573. }
  2574. if item.ChrgitmLv == "2" {
  2575. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2576. }
  2577. if item.ChrgitmLv == "3" {
  2578. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2579. }
  2580. }
  2581. if item.MedChrgitmType == "11" { //中成费
  2582. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2583. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2584. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2585. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2586. if item.ChrgitmLv == "1" {
  2587. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2588. }
  2589. if item.ChrgitmLv == "2" {
  2590. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2591. }
  2592. if item.ChrgitmLv == "3" {
  2593. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2594. }
  2595. }
  2596. if item.MedChrgitmType == "14" { //其他费
  2597. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2598. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2599. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2600. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2601. if item.ChrgitmLv == "1" {
  2602. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2603. }
  2604. if item.ChrgitmLv == "2" {
  2605. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2606. }
  2607. if item.ChrgitmLv == "3" {
  2608. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2609. }
  2610. }
  2611. }
  2612. var iteminfoStructs []service.IteminfoStruct
  2613. if bedCostTotal != 0 {
  2614. iteminfo.MedChrgitm = "01"
  2615. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2616. iteminfo.Amt = bedCostTotal
  2617. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2618. iteminfo.ClabAmt = bed_clab_amt
  2619. iteminfo.OthAmt = bed_other_amt
  2620. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2621. }
  2622. if checkCostTotal != 0 {
  2623. iteminfo.MedChrgitm = "03"
  2624. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2625. iteminfo.Amt = checkCostTotal
  2626. iteminfo.ClaaSumfee = check_claa_sunmfee
  2627. iteminfo.ClabAmt = check_clab_amt
  2628. iteminfo.OthAmt = check_other_amt
  2629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2630. }
  2631. if laboratoryCostTotal != 0 {
  2632. iteminfo.MedChrgitm = "04"
  2633. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2634. iteminfo.Amt = laboratoryCostTotal
  2635. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2636. iteminfo.ClabAmt = laboratory_clab_amt
  2637. iteminfo.OthAmt = laboratory_other_amt
  2638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2639. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2640. }
  2641. if treatCostTotal != 0 {
  2642. iteminfo.MedChrgitm = "05"
  2643. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2644. iteminfo.Amt = treatCostTotal
  2645. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2646. iteminfo.ClabAmt = treat_clab_amt
  2647. iteminfo.OthAmt = treat_other_amt
  2648. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2649. //(struct4101.IteminfoStruct, iteminfo)
  2650. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2651. }
  2652. if operationCostTotal != 0 {
  2653. iteminfo.MedChrgitm = "06"
  2654. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2655. iteminfo.Amt = operationCostTotal
  2656. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2657. iteminfo.ClabAmt = operation_clab_amt
  2658. iteminfo.OthAmt = operation_other_amt
  2659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2660. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2661. }
  2662. if materialCostTotal != 0 {
  2663. iteminfo.MedChrgitm = "08"
  2664. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2665. iteminfo.Amt = materialCostTotal
  2666. iteminfo.ClaaSumfee = material_claa_sunmfee
  2667. iteminfo.ClabAmt = material_clab_amt
  2668. iteminfo.OthAmt = material_other_amt
  2669. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2670. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2671. }
  2672. if westernMedicineCostTotal != 0 {
  2673. iteminfo.MedChrgitm = "09"
  2674. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2675. iteminfo.Amt = westernMedicineCostTotal
  2676. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2677. iteminfo.ClabAmt = westernMedicine_clab_amt
  2678. iteminfo.OthAmt = westernMedicine_other_amt
  2679. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2680. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2681. }
  2682. if chineseTraditionalMedicineCostTotal != 0 {
  2683. iteminfo.MedChrgitm = "11"
  2684. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2685. iteminfo.Amt = westernMedicineCostTotal
  2686. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2687. iteminfo.ClabAmt = westernMedicine_clab_amt
  2688. iteminfo.OthAmt = westernMedicine_other_amt
  2689. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2690. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2691. }
  2692. if otherCostTotal != 0 {
  2693. iteminfo.MedChrgitm = "14"
  2694. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2695. iteminfo.Amt = otherCostTotal
  2696. iteminfo.ClaaSumfee = other_claa_sunmfee
  2697. iteminfo.ClabAmt = other_clab_amt
  2698. iteminfo.OthAmt = other_other_amt
  2699. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2700. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2701. }
  2702. struct4101.IteminfoStruct = iteminfoStructs
  2703. struct4101.Ntly = "中国"
  2704. struct4101.AdmCaty = "A03.06"
  2705. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2706. fmt.Println(result)
  2707. var dat map[string]interface{}
  2708. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2709. fmt.Println(dat)
  2710. } else {
  2711. fmt.Println(err)
  2712. }
  2713. userJSONBytes, _ := json.Marshal(dat)
  2714. var res ResultSeventeen
  2715. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2716. utils.ErrorLog("解析失败:%v", err)
  2717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2718. return
  2719. }
  2720. if res.Infcode != 0 {
  2721. c.ServeSuccessJSON(map[string]interface{}{
  2722. "failed_code": -10,
  2723. "msg": res.ErrMsg,
  2724. })
  2725. return
  2726. } else {
  2727. order.FaPiaoNumber = zero
  2728. order.FaPiaoCode = last_order.FaPiaoCode
  2729. service.UpdateOrder(order)
  2730. hisFundSettleListResult := &models.HisFundSettleListResult{
  2731. Number: res.Output.SetlListId,
  2732. Status: 1,
  2733. Ctime: time.Now().Unix(),
  2734. Mtime: time.Now().Unix(),
  2735. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2736. IsUpload: 1,
  2737. OrderId: order_id,
  2738. }
  2739. service.CreateUploadRecord(hisFundSettleListResult)
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "上传成功",
  2742. "result": hisFundSettleListResult,
  2743. })
  2744. return
  2745. }
  2746. }
  2747. func (c *HisApiController) GetBatchSettleList() {
  2748. orders, _ := service.GetAllHisOrder(10106)
  2749. for _, item := range orders {
  2750. order_id := item.ID
  2751. order, _ := service.GetHisOrderByIDTwo(order_id)
  2752. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2753. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2754. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2755. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2756. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2757. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2758. if order.ID == 0 {
  2759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2760. return
  2761. }
  2762. if his.BalanceAccountsType == 2 {
  2763. continue
  2764. }
  2765. struct4101 := service.Struct4101{
  2766. PsnNo: order.PsnNo,
  2767. MdtrtId: order.MdtrtId,
  2768. SetlId: order.SetlId,
  2769. PsnName: order.PsnName,
  2770. Gend: order.Gend,
  2771. Brdy: his.Brdy,
  2772. Age: his.Age,
  2773. Naty: order.Naty,
  2774. PatnCertType: "01",
  2775. Certno: order.Certno,
  2776. Prfs: "90",
  2777. ConerName: roles[0].UserName,
  2778. PatnRlts: "99",
  2779. ConerAddr: miConfig.OrgName,
  2780. ConerTel: admin.Mobile,
  2781. HiType: order.Insutype,
  2782. Insuplc: his.InsuplcAdmdvs,
  2783. MaindiagFlag: "1",
  2784. BillCode: order.FaPiaoCode,
  2785. BillNo: order.FaPiaoNumber,
  2786. BizSn: order.Number,
  2787. PsnSelfPay: order.PsnPartAmt,
  2788. PsnOwnPay: order.PsnPartAmt,
  2789. AcctPay: order.AcctPay,
  2790. PsnCashpay: order.PsnCashPay,
  2791. HiPaymtd: "1",
  2792. Hsorg: his.InsuplcAdmdvs,
  2793. HsorgOpter: his.InsuplcAdmdvs,
  2794. MedinsFillPsn: curRoles.UserName,
  2795. MedinsFillDept: depart.Name,
  2796. IptMedType: "2",
  2797. }
  2798. struct4101.SetlBegnDate = order.SetlTime
  2799. struct4101.SetlEndDate = order.SetlTime
  2800. //if order.SettleType == 1 {
  2801. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2802. // dateStr := t.Format("2006-01-02")
  2803. // struct4101.SetlBegnDate = dateStr
  2804. // struct4101.SetlEndDate = dateStr
  2805. //} else {
  2806. // t := time.Unix(int64(order.SettleStartTime), 0)
  2807. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2808. // dateStartStr := t.Format("2006-01-02")
  2809. // dateEndStr := t2.Format("2006-01-02")
  2810. // struct4101.SetlBegnDate = dateStartStr
  2811. // struct4101.SetlEndDate = dateEndStr
  2812. //}
  2813. var rf []CustomFundPay
  2814. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2815. var tempFunPays []service.CustomStruct
  2816. var tempFunPay610100 service.CustomStruct
  2817. for _, item := range rf {
  2818. if item.FundPayType == "610100" {
  2819. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2820. tempFunPay610100.FundPayType = item.FundPayType
  2821. } else {
  2822. var tempFunPay service.CustomStruct
  2823. tempFunPay.FundPayamt = item.FundPayamt
  2824. tempFunPay.FundPayType = item.FundPayType
  2825. tempFunPays = append(tempFunPays, tempFunPay)
  2826. }
  2827. }
  2828. tempFunPays = append(tempFunPays, tempFunPay610100)
  2829. struct4101.CustomStruct = tempFunPays
  2830. var tempDiaginfos []service.DiaginfoStructTwo
  2831. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2832. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2833. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2834. var config []*models.HisXtDiagnoseConfig
  2835. for _, item := range diagnosis_ids {
  2836. id, _ := strconv.ParseInt(item, 10, 64)
  2837. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2838. config = append(config, &diagnosisConfig)
  2839. }
  2840. for index, item := range config {
  2841. if index == 0 {
  2842. var tempDiaginfo service.DiaginfoStructTwo
  2843. tempDiaginfo.DiagCode = item.CountryCode
  2844. tempDiaginfo.DiagName = item.CountryContentName
  2845. tempDiaginfo.DiagType = "1"
  2846. tempDiaginfo.MaindiagFlag = "1"
  2847. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2848. } else {
  2849. var tempDiaginfo service.DiaginfoStructTwo
  2850. tempDiaginfo.DiagCode = item.CountryCode
  2851. tempDiaginfo.DiagName = item.CountryContentName
  2852. tempDiaginfo.DiagType = "2"
  2853. tempDiaginfo.MaindiagFlag = "0"
  2854. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2855. }
  2856. }
  2857. struct4101.Diseinfo = tempDiaginfos
  2858. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2859. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2860. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2861. tempOpspdiseinfo2.OprnOprtCode = ""
  2862. tempOpspdiseinfo2.OprnOprtName = ""
  2863. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2864. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2865. var iteminfo service.IteminfoStruct
  2866. var bedCostTotal float64 = 0 //床位总费
  2867. var bedCostSelfTotal float64 = 0 //床位自费
  2868. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2869. var examineCostTotal float64 = 0 //诊查总费
  2870. var examineCostSelfTotal float64 = 0 //诊查自费
  2871. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2872. var nursingCostTotal float64 = 0 //护理总费
  2873. var nursingCostSelfTotal float64 = 0 //护理自费
  2874. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2875. var chineseMedicineCostTotal float64 = 0 //中成药
  2876. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2877. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2878. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2879. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2880. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2881. var registerCostTotal float64 = 0 //一般诊疗费
  2882. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2883. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2884. var operationCostTotal float64 = 0 //手术费
  2885. var operationCostSelfTotal float64 = 0 //手术费
  2886. var operationCostPartSelfTotal float64 = 0 //手术费
  2887. var otherCostTotal float64 = 0 //其他费用
  2888. var otherCostSelfTotal float64 = 0 //其他费用
  2889. var otherCostPartSelfTotal float64 = 0 //其他费用
  2890. var materialCostTotal float64 = 0 //材料费
  2891. var materialCostSelfTotal float64 = 0 //材料费
  2892. var materialCostPartSelfTotal float64 = 0 //材料费
  2893. var westernMedicineCostTotal float64 = 0 //西药费
  2894. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2895. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2896. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2897. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2898. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2899. var checkCostTotal float64 = 0 //检查费
  2900. var checkCostSelfTotal float64 = 0 //检查费
  2901. var checkCostPartSelfTotal float64 = 0 //检查费
  2902. var laboratoryCostTotal float64 = 0 //化验费
  2903. var laboratoryCostSelfTotal float64 = 0 //化验费
  2904. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2905. var treatCostTotal float64 = 0 //治疗费用
  2906. var treatCostSelfTotal float64 = 0 //治疗费用
  2907. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2908. decimal.DivisionPrecision = 2
  2909. var bed_fulamt_ownpay_amt float64 = 0
  2910. var examine_fulamt_ownpay_amt float64 = 0
  2911. var nursing_fulamt_ownpay_amt float64 = 0
  2912. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2913. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2914. var register_fulamt_ownpay_amt float64 = 0
  2915. var operation_fulamt_ownpay_amt float64 = 0
  2916. var other_fulamt_ownpay_amt float64 = 0
  2917. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2918. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2919. var check_fulamt_ownpay_amt float64 = 0
  2920. var material_fulamt_ownpay_amt float64 = 0
  2921. var laboratory_fulamt_ownpay_amt float64 = 0
  2922. var treat_fulamt_ownpay_amt float64 = 0
  2923. var bed_claa_sunmfee float64 = 0
  2924. var bed_clab_amt float64 = 0
  2925. var bed_other_amt float64 = 0
  2926. var examine_claa_sunmfee float64 = 0
  2927. var examine_clab_amt float64 = 0
  2928. var examine_other_amt float64 = 0
  2929. var nursing_claa_sunmfee float64 = 0
  2930. var nursing_clab_amt float64 = 0
  2931. var nursing_other_amt float64 = 0
  2932. var chinese_medicine_claa_sunmfee float64 = 0
  2933. var chinese_medicine_clab_amt float64 = 0
  2934. var chinese_medicine_other_amt float64 = 0
  2935. var commonly_treatment_claa_sunmfee float64 = 0
  2936. var commonly_treatment_clab_amt float64 = 0
  2937. var commonly_treatment_other_amt float64 = 0
  2938. var operation_claa_sunmfee float64 = 0
  2939. var operation_clab_amt float64 = 0
  2940. var operation_other_amt float64 = 0
  2941. var other_claa_sunmfee float64 = 0
  2942. var other_clab_amt float64 = 0
  2943. var other_other_amt float64 = 0
  2944. var westernMedicine_claa_sunmfee float64 = 0
  2945. var westernMedicine_clab_amt float64 = 0
  2946. var westernMedicine_other_amt float64 = 0
  2947. var chineseTraditional_claa_sunmfee float64 = 0
  2948. var chineseTraditional_clab_amt float64 = 0
  2949. var chineseTraditional_other_amt float64 = 0
  2950. var check_claa_sunmfee float64 = 0
  2951. var check_clab_amt float64 = 0
  2952. var check_other_amt float64 = 0
  2953. var material_claa_sunmfee float64 = 0
  2954. var material_clab_amt float64 = 0
  2955. var material_other_amt float64 = 0
  2956. var laboratory_claa_sunmfee float64 = 0
  2957. var laboratory_clab_amt float64 = 0
  2958. var laboratory_other_amt float64 = 0
  2959. var treat_claa_sunmfee float64 = 0
  2960. var treat_clab_amt float64 = 0
  2961. var treat_other_amt float64 = 0
  2962. var register_claa_sunmfee float64 = 0
  2963. var register_clab_amt float64 = 0
  2964. var register_other_amt float64 = 0
  2965. for _, item := range order.HisOrderInfo {
  2966. if item.MedChrgitmType == "01" { //床位费
  2967. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2968. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2969. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2970. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2971. if item.ChrgitmLv == "1" {
  2972. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2973. }
  2974. if item.ChrgitmLv == "2" {
  2975. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2976. }
  2977. if item.ChrgitmLv == "3" {
  2978. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2979. }
  2980. }
  2981. if item.MedChrgitmType == "02" { //诊查
  2982. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2983. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2984. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2985. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2986. if item.ChrgitmLv == "1" {
  2987. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2988. }
  2989. if item.ChrgitmLv == "2" {
  2990. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2991. }
  2992. if item.ChrgitmLv == "3" {
  2993. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2994. }
  2995. }
  2996. if item.MedChrgitmType == "03" { //检查费
  2997. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2998. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2999. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3000. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3001. if item.ChrgitmLv == "1" {
  3002. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3003. }
  3004. if item.ChrgitmLv == "2" {
  3005. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3006. }
  3007. if item.ChrgitmLv == "3" {
  3008. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3009. }
  3010. }
  3011. if item.MedChrgitmType == "04" { //化验费
  3012. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3013. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3014. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3015. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3016. if item.ChrgitmLv == "1" {
  3017. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3018. }
  3019. if item.ChrgitmLv == "2" {
  3020. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3021. }
  3022. if item.ChrgitmLv == "3" {
  3023. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3024. }
  3025. }
  3026. if item.MedChrgitmType == "05" { //治疗费
  3027. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3028. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3029. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3030. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3031. if item.ChrgitmLv == "1" {
  3032. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3033. }
  3034. if item.ChrgitmLv == "2" {
  3035. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3036. }
  3037. if item.ChrgitmLv == "3" {
  3038. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3039. }
  3040. }
  3041. if item.MedChrgitmType == "06" { //手术费
  3042. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3043. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3044. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3045. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3046. if item.ChrgitmLv == "1" {
  3047. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3048. }
  3049. if item.ChrgitmLv == "2" {
  3050. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3051. }
  3052. if item.ChrgitmLv == "3" {
  3053. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3054. }
  3055. }
  3056. if item.MedChrgitmType == "07" { //手术费
  3057. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3058. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3059. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3060. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3061. if item.ChrgitmLv == "1" {
  3062. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3063. }
  3064. if item.ChrgitmLv == "2" {
  3065. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3066. }
  3067. if item.ChrgitmLv == "3" {
  3068. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3069. }
  3070. }
  3071. if item.MedChrgitmType == "08" { //材料费
  3072. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3073. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3074. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3075. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3076. if item.ChrgitmLv == "1" {
  3077. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3078. }
  3079. if item.ChrgitmLv == "2" {
  3080. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3081. }
  3082. if item.ChrgitmLv == "3" {
  3083. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3084. }
  3085. }
  3086. if item.MedChrgitmType == "09" { //西药费
  3087. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3088. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3089. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3090. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3091. if item.ChrgitmLv == "1" {
  3092. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3093. }
  3094. if item.ChrgitmLv == "2" {
  3095. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3096. }
  3097. if item.ChrgitmLv == "3" {
  3098. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3099. }
  3100. }
  3101. if item.MedChrgitmType == "10" { //中药饮片
  3102. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3103. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3104. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3105. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3106. if item.ChrgitmLv == "1" {
  3107. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3108. }
  3109. if item.ChrgitmLv == "2" {
  3110. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3111. }
  3112. if item.ChrgitmLv == "3" {
  3113. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3114. }
  3115. }
  3116. if item.MedChrgitmType == "11" { //中成费
  3117. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3118. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3119. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3120. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3121. if item.ChrgitmLv == "1" {
  3122. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3123. }
  3124. if item.ChrgitmLv == "2" {
  3125. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3126. }
  3127. if item.ChrgitmLv == "3" {
  3128. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3129. }
  3130. }
  3131. if item.MedChrgitmType == "12" { //中成费
  3132. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3133. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3134. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3135. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3136. if item.ChrgitmLv == "1" {
  3137. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3138. }
  3139. if item.ChrgitmLv == "2" {
  3140. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3141. }
  3142. if item.ChrgitmLv == "3" {
  3143. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3144. }
  3145. }
  3146. if item.MedChrgitmType == "13" { //中成费
  3147. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3148. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3149. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3150. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3151. if item.ChrgitmLv == "1" {
  3152. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3153. }
  3154. if item.ChrgitmLv == "2" {
  3155. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3156. }
  3157. if item.ChrgitmLv == "3" {
  3158. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3159. }
  3160. }
  3161. if item.MedChrgitmType == "14" { //其他费
  3162. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3163. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3164. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3165. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3166. if item.ChrgitmLv == "1" {
  3167. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3168. }
  3169. if item.ChrgitmLv == "2" {
  3170. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3171. }
  3172. if item.ChrgitmLv == "3" {
  3173. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3174. }
  3175. }
  3176. }
  3177. var iteminfoStructs []service.IteminfoStruct
  3178. if bedCostTotal != 0 {
  3179. iteminfo.MedChrgitm = "01"
  3180. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3181. iteminfo.Amt = bedCostTotal
  3182. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3183. iteminfo.ClabAmt = bed_clab_amt
  3184. iteminfo.OthAmt = bed_other_amt
  3185. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3186. }
  3187. if examineCostTotal != 0 {
  3188. iteminfo.MedChrgitm = "02"
  3189. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3190. iteminfo.Amt = examineCostTotal
  3191. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3192. iteminfo.ClabAmt = examine_clab_amt
  3193. iteminfo.OthAmt = examine_other_amt
  3194. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3195. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3196. }
  3197. if checkCostTotal != 0 {
  3198. iteminfo.MedChrgitm = "03"
  3199. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3200. iteminfo.Amt = checkCostTotal
  3201. iteminfo.ClaaSumfee = check_claa_sunmfee
  3202. iteminfo.ClabAmt = check_clab_amt
  3203. iteminfo.OthAmt = check_other_amt
  3204. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3205. }
  3206. if laboratoryCostTotal != 0 {
  3207. iteminfo.MedChrgitm = "04"
  3208. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3209. iteminfo.Amt = laboratoryCostTotal
  3210. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3211. iteminfo.ClabAmt = laboratory_clab_amt
  3212. iteminfo.OthAmt = laboratory_other_amt
  3213. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3214. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3215. }
  3216. if treatCostTotal != 0 {
  3217. iteminfo.MedChrgitm = "05"
  3218. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3219. iteminfo.Amt = treatCostTotal
  3220. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3221. iteminfo.ClabAmt = treat_clab_amt
  3222. iteminfo.OthAmt = treat_other_amt
  3223. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3224. //(struct4101.IteminfoStruct, iteminfo)
  3225. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3226. }
  3227. if operationCostTotal != 0 {
  3228. iteminfo.MedChrgitm = "06"
  3229. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3230. iteminfo.Amt = operationCostTotal
  3231. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3232. iteminfo.ClabAmt = operation_clab_amt
  3233. iteminfo.OthAmt = operation_other_amt
  3234. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3235. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3236. }
  3237. if nursingCostTotal != 0 {
  3238. iteminfo.MedChrgitm = "07"
  3239. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3240. iteminfo.Amt = nursingCostTotal
  3241. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3242. iteminfo.ClabAmt = nursing_clab_amt
  3243. iteminfo.OthAmt = nursing_other_amt
  3244. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3245. }
  3246. if materialCostTotal != 0 {
  3247. iteminfo.MedChrgitm = "08"
  3248. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3249. iteminfo.Amt = materialCostTotal
  3250. iteminfo.ClaaSumfee = material_claa_sunmfee
  3251. iteminfo.ClabAmt = material_clab_amt
  3252. iteminfo.OthAmt = material_other_amt
  3253. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3254. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3255. }
  3256. if westernMedicineCostTotal != 0 {
  3257. iteminfo.MedChrgitm = "09"
  3258. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3259. iteminfo.Amt = westernMedicineCostTotal
  3260. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3261. iteminfo.ClabAmt = westernMedicine_clab_amt
  3262. iteminfo.OthAmt = westernMedicine_other_amt
  3263. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3264. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3265. }
  3266. if chineseMedicineCostTotal != 0 {
  3267. iteminfo.MedChrgitm = "10"
  3268. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3269. iteminfo.Amt = chineseMedicineCostTotal
  3270. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3271. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3272. iteminfo.OthAmt = chinese_medicine_other_amt
  3273. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3274. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3275. }
  3276. if chineseTraditionalMedicineCostTotal != 0 {
  3277. iteminfo.MedChrgitm = "11"
  3278. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3279. iteminfo.Amt = westernMedicineCostTotal
  3280. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3281. iteminfo.ClabAmt = westernMedicine_clab_amt
  3282. iteminfo.OthAmt = westernMedicine_other_amt
  3283. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3284. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3285. }
  3286. if commonlyTreatmentCostTotal != 0 {
  3287. iteminfo.MedChrgitm = "12"
  3288. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3289. iteminfo.Amt = commonlyTreatmentCostTotal
  3290. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3291. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3292. iteminfo.OthAmt = commonly_treatment_other_amt
  3293. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3294. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3295. }
  3296. if registerCostTotal != 0 {
  3297. iteminfo.MedChrgitm = "13"
  3298. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3299. iteminfo.Amt = registerCostTotal
  3300. iteminfo.ClaaSumfee = register_claa_sunmfee
  3301. iteminfo.ClabAmt = register_clab_amt
  3302. iteminfo.OthAmt = register_other_amt
  3303. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3304. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3305. }
  3306. if otherCostTotal != 0 {
  3307. iteminfo.MedChrgitm = "14"
  3308. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3309. iteminfo.Amt = otherCostTotal
  3310. iteminfo.ClaaSumfee = other_claa_sunmfee
  3311. iteminfo.ClabAmt = other_clab_amt
  3312. iteminfo.OthAmt = other_other_amt
  3313. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3314. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3315. }
  3316. struct4101.IteminfoStruct = iteminfoStructs
  3317. struct4101.Ntly = "中国"
  3318. struct4101.AdmCaty = "A03.06"
  3319. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3320. fmt.Println(result)
  3321. var dat map[string]interface{}
  3322. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3323. fmt.Println(dat)
  3324. } else {
  3325. fmt.Println(err)
  3326. }
  3327. userJSONBytes, _ := json.Marshal(dat)
  3328. var res ResultSeventeen
  3329. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3330. utils.ErrorLog("解析失败:%v", err)
  3331. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3332. adminUser := c.GetAdminUserInfo()
  3333. errlog := &models.HisOrderError{
  3334. UserOrgId: adminUser.CurrentOrgId,
  3335. Ctime: time.Now().Unix(),
  3336. Mtime: time.Now().Unix(),
  3337. ErrMsg: res.ErrMsg + "解析失败",
  3338. Status: 1,
  3339. PatientId: order_id,
  3340. Stage: 10106,
  3341. }
  3342. service.CreateErrMsgLog(errlog)
  3343. continue
  3344. }
  3345. if res.Infcode != 0 {
  3346. adminUser := c.GetAdminUserInfo()
  3347. errlog := &models.HisOrderError{
  3348. UserOrgId: adminUser.CurrentOrgId,
  3349. Ctime: time.Now().Unix(),
  3350. Mtime: time.Now().Unix(),
  3351. ErrMsg: res.ErrMsg,
  3352. Status: 1,
  3353. PatientId: order_id,
  3354. Stage: 10106,
  3355. }
  3356. service.CreateErrMsgLog(errlog)
  3357. continue
  3358. } else {
  3359. hisFundSettleListResult := &models.HisFundSettleListResult{
  3360. Number: res.Output.SetlListId,
  3361. Status: 1,
  3362. Ctime: time.Now().Unix(),
  3363. Mtime: time.Now().Unix(),
  3364. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3365. IsUpload: 1,
  3366. OrderId: order_id,
  3367. }
  3368. service.CreateUploadRecord(hisFundSettleListResult)
  3369. continue
  3370. }
  3371. }
  3372. }
  3373. func (c *HisApiController) GetOrgInfo() {
  3374. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3375. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3376. }
  3377. func (c *HisApiController) GetHisPatientInfo() {
  3378. medical_insurance_card := c.GetString("medical_insurance_card")
  3379. id_card_type, _ := c.GetInt64("id_card_type")
  3380. id_card := c.GetString("id_card")
  3381. adminInfo := c.GetAdminUserInfo()
  3382. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3383. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3384. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3385. IdCardNo := ""
  3386. if id_card_type == 1 {
  3387. IdCardNo = medical_insurance_card
  3388. } else if id_card_type == 2 {
  3389. IdCardNo = id_card
  3390. }
  3391. if config.IsOpen == 1 {
  3392. 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
  3393. resp, requestErr := http.Get(api)
  3394. if requestErr != nil {
  3395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3396. return
  3397. }
  3398. defer resp.Body.Close()
  3399. body, ioErr := ioutil.ReadAll(resp.Body)
  3400. if ioErr != nil {
  3401. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3403. return
  3404. }
  3405. var respJSON map[string]interface{}
  3406. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3407. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3408. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3409. return
  3410. }
  3411. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3412. userJSONBytes, _ := json.Marshal(userJSON)
  3413. var res ResultTwo
  3414. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3415. utils.ErrorLog("解析失败:%v", err)
  3416. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3417. return
  3418. }
  3419. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3420. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3421. infoStr := string(Iinfos)
  3422. idetinfoStr := string(Idetinfos)
  3423. if res.Infcode == 0 {
  3424. his := models.VMHisPatient{
  3425. Status: 1,
  3426. Ctime: time.Now().Unix(),
  3427. Mtime: time.Now().Unix(),
  3428. PsnNo: res.Output.Baseinfo.PsnNo,
  3429. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3430. Certno: res.Output.Baseinfo.Certno,
  3431. PsnName: res.Output.Baseinfo.PsnName,
  3432. Gend: res.Output.Baseinfo.Gend,
  3433. Naty: res.Output.Baseinfo.Naty,
  3434. Brdy: res.Output.Baseinfo.Brdy,
  3435. Age: res.Output.Baseinfo.Age,
  3436. Iinfo: infoStr,
  3437. Idetinfo: idetinfoStr,
  3438. UserOrgId: adminInfo.CurrentOrgId,
  3439. IsReturn: 1,
  3440. IdCardType: id_card_type,
  3441. }
  3442. c.ServeSuccessJSON(map[string]interface{}{
  3443. "info": his,
  3444. })
  3445. } else {
  3446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3447. return
  3448. }
  3449. }
  3450. }
  3451. //func GetBasBaseInfo() (jsonStr string, err error) {
  3452. //
  3453. // handle := syscall.NewLazyDLL("SSCard.dll")
  3454. // add := handle.NewProc("ReadCardBas")
  3455. // str := make([]byte, 1024)
  3456. // str1 := make([]byte, 1024)
  3457. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3458. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3459. //
  3460. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3461. //
  3462. // fmt.Println("> Add(4,5)的结果为:", ret)
  3463. // handle.Release()
  3464. //
  3465. // return "", nil
  3466. //
  3467. //}
  3468. //func GetQRBaseInfo() (jsonStr string, err error) {
  3469. // handle := syscall.LoadDLL("SSCard.dll")
  3470. // ReadCardBas := handle.FindProc("GetQRBase")
  3471. //
  3472. // str := make([]byte, 256)
  3473. // str1 := make([]byte, 256)
  3474. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3475. //
  3476. // fmt.Println(string(str))
  3477. // fmt.Println(r)
  3478. // return string(str), nil
  3479. //}
  3480. //func CardInit() int {
  3481. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3482. // add := DllTestDef.MustFindProc("Init")
  3483. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3484. // if err != nil {
  3485. // fmt.Println("SSCard的运算结果为:", ret)
  3486. // }
  3487. // result := int(ret)
  3488. // return result
  3489. //}
  3490. //func CardInit() int {
  3491. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3492. // if err != nil {
  3493. // fmt.Println("SSCard的运算结果为:", ret)
  3494. // }
  3495. // fmt.Println(err)
  3496. // result := int(ret)
  3497. // return result
  3498. //}
  3499. func IntPtr(n int) uintptr {
  3500. return uintptr(n)
  3501. }
  3502. func StrPtr(s string) uintptr {
  3503. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3504. }
  3505. type Result2001 struct {
  3506. Cainfo interface{} `json:"cainfo"`
  3507. ErrMsg string `json:"err_msg"`
  3508. InfRefmsgid string `json:"inf_refmsgid"`
  3509. Infcode int64 `json:"infcode"`
  3510. Output struct {
  3511. Trtinfo struct {
  3512. PsnNo string `json:"psn_no"`
  3513. TrtChkType string `json:"trt_chk_type"`
  3514. FundPayType string `json:"fund_pay_type"`
  3515. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3516. Begndate string `json:"begndate"`
  3517. Enddate string `json:"enddate"`
  3518. TrtChkRslt string `json:"trt_chk_rslt"`
  3519. } `json:"trtinfo"`
  3520. } `json:"output"`
  3521. RefmsgTime string `json:"refmsg_time"`
  3522. RespondTime string `json:"respond_time"`
  3523. Signtype interface{} `json:"signtype"`
  3524. WarnMsg interface{} `json:"warn_msg"`
  3525. }
  3526. type Result2001Org10265 struct {
  3527. Cainfo interface{} `json:"cainfo"`
  3528. ErrMsg string `json:"err_msg"`
  3529. InfRefmsgid string `json:"inf_refmsgid"`
  3530. Infcode string `json:"infcode"`
  3531. Output struct {
  3532. Trtinfo struct {
  3533. PsnNo string `json:"psn_no"`
  3534. TrtChkType string `json:"trt_chk_type"`
  3535. FundPayType string `json:"fund_pay_type"`
  3536. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3537. Begndate string `json:"begndate"`
  3538. Enddate string `json:"enddate"`
  3539. TrtChkRslt string `json:"trt_chk_rslt"`
  3540. } `json:"trtinfo"`
  3541. } `json:"output"`
  3542. RefmsgTime string `json:"refmsg_time"`
  3543. RespondTime string `json:"respond_time"`
  3544. Signtype interface{} `json:"signtype"`
  3545. WarnMsg interface{} `json:"warn_msg"`
  3546. }
  3547. type ResultTwo struct {
  3548. ErrMsg string `json:"err_msg"`
  3549. InfRefmsgid string `json:"inf_refmsgid"`
  3550. Infcode int64 `json:"infcode"`
  3551. Output struct {
  3552. Baseinfo struct {
  3553. Age float64 `json:"age"`
  3554. Brdy string `json:"brdy"`
  3555. Certno string `json:"certno"`
  3556. Gend string `json:"gend"`
  3557. Naty string `json:"naty"`
  3558. PsnCertType string `json:"psn_cert_type"`
  3559. PsnName string `json:"psn_name"`
  3560. PsnNo string `json:"psn_no"`
  3561. } `json:"baseinfo"`
  3562. Idetinfo []interface{} `json:"idetinfo"`
  3563. Iinfo []struct {
  3564. Balc float64 `json:"balc"`
  3565. CvlservFlag string `json:"cvlserv_flag"`
  3566. EmpName string `json:"emp_name"`
  3567. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3568. Insutype string `json:"insutype"`
  3569. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3570. PausInsuDate string `json:"paus_insu_date"`
  3571. PsnInsuDate string `json:"psn_insu_date"`
  3572. PsnInsuStas string `json:"psn_insu_stas"`
  3573. PsnType string `json:"psn_type"`
  3574. } `json:"insuinfo"`
  3575. } `json:"output"`
  3576. RefmsgTime string `json:"refmsg_time"`
  3577. RespondTime string `json:"respond_time"`
  3578. Signtype interface{} `json:"signtype"`
  3579. WarnInfo interface{} `json:"warn_info"`
  3580. }
  3581. type ResultTwo10265 struct {
  3582. ErrMsg string `json:"err_msg"`
  3583. InfRefmsgid string `json:"inf_refmsgid"`
  3584. Infcode string `json:"infcode"`
  3585. Output struct {
  3586. Baseinfo struct {
  3587. Age float64 `json:"age"`
  3588. Brdy string `json:"brdy"`
  3589. Certno string `json:"certno"`
  3590. Gend string `json:"gend"`
  3591. Naty string `json:"naty"`
  3592. PsnCertType string `json:"psn_cert_type"`
  3593. PsnName string `json:"psn_name"`
  3594. PsnNo string `json:"psn_no"`
  3595. } `json:"baseinfo"`
  3596. Idetinfo []interface{} `json:"idetinfo"`
  3597. Iinfo []struct {
  3598. Balc float64 `json:"balc"`
  3599. CvlservFlag string `json:"cvlserv_flag"`
  3600. EmpName string `json:"emp_name"`
  3601. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3602. Insutype string `json:"insutype"`
  3603. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3604. PausInsuDate string `json:"paus_insu_date"`
  3605. PsnInsuDate string `json:"psn_insu_date"`
  3606. PsnInsuStas string `json:"psn_insu_stas"`
  3607. PsnType string `json:"psn_type"`
  3608. } `json:"insuinfo"`
  3609. } `json:"output"`
  3610. RefmsgTime string `json:"refmsg_time"`
  3611. RespondTime string `json:"respond_time"`
  3612. Signtype interface{} `json:"signtype"`
  3613. WarnInfo interface{} `json:"warn_info"`
  3614. }
  3615. type ResultThree struct {
  3616. Cainfo interface{} `json:"cainfo"`
  3617. ErrMsg string `json:"err_msg"`
  3618. InfRefmsgid string `json:"inf_refmsgid"`
  3619. Infcode int64 `json:"infcode"`
  3620. Output struct {
  3621. Data struct {
  3622. IptOtpNo string `json:"ipt_otp_no"`
  3623. MdtrtID string `json:"mdtrt_id"`
  3624. PsnNo string `json:"psn_no"`
  3625. } `json:"data"`
  3626. } `json:"output"`
  3627. RefmsgTime string `json:"refmsg_time"`
  3628. RespondTime string `json:"respond_time"`
  3629. Signtype interface{} `json:"signtype"`
  3630. WarnMsg interface{} `json:"warn_msg"`
  3631. }
  3632. type ResultThree10265 struct {
  3633. Cainfo interface{} `json:"cainfo"`
  3634. ErrMsg string `json:"err_msg"`
  3635. InfRefmsgid string `json:"inf_refmsgid"`
  3636. Infcode string `json:"infcode"`
  3637. Output struct {
  3638. Data struct {
  3639. IptOtpNo string `json:"ipt_otp_no"`
  3640. MdtrtID string `json:"mdtrt_id"`
  3641. PsnNo string `json:"psn_no"`
  3642. } `json:"data"`
  3643. } `json:"output"`
  3644. RefmsgTime string `json:"refmsg_time"`
  3645. RespondTime string `json:"respond_time"`
  3646. Signtype interface{} `json:"signtype"`
  3647. WarnMsg interface{} `json:"warn_msg"`
  3648. }
  3649. type ResultFour struct {
  3650. Cainfo string `json:"cainfo"`
  3651. ErrMsg string `json:"err_msg"`
  3652. InfRefmsgid string `json:"inf_refmsgid"`
  3653. Infcode int64 `json:"infcode"`
  3654. Output struct {
  3655. Result []struct {
  3656. BasMednFlag string `json:"bas_medn_flag"`
  3657. ChldMedcFlag string `json:"chld_medc_flag"`
  3658. ChrgitmLv string `json:"chrgitm_lv"`
  3659. Cnt float64 `json:"cnt"`
  3660. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3661. DrtReimFlag string `json:"drt_reim_flag"`
  3662. FeedetlSn string `json:"feedetl_sn"`
  3663. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3664. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3665. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3666. ListSpItemFlag string `json:"list_sp_item_flag"`
  3667. LmtUsedFlag string `json:"lmt_used_flag"`
  3668. MedChrgitmType string `json:"med_chrgitm_type"`
  3669. Memo string `json:"memo"`
  3670. OverlmtAmt float64 `json:"overlmt_amt"`
  3671. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3672. Pric float64 `json:"pric"`
  3673. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3674. SelfpayProp float64 `json:"selfpay_prop"`
  3675. } `json:"result"`
  3676. } `json:"output"`
  3677. RefmsgTime string `json:"refmsg_time"`
  3678. RespondTime string `json:"respond_time"`
  3679. Signtype string `json:"signtype"`
  3680. WarnMsg string `json:"warn_msg"`
  3681. }
  3682. type ResultFour10265 struct {
  3683. Cainfo string `json:"cainfo"`
  3684. ErrMsg string `json:"err_msg"`
  3685. InfRefmsgid string `json:"inf_refmsgid"`
  3686. Infcode string `json:"infcode"`
  3687. Output struct {
  3688. Result []struct {
  3689. BasMednFlag string `json:"bas_medn_flag"`
  3690. ChldMedcFlag string `json:"chld_medc_flag"`
  3691. ChrgitmLv string `json:"chrgitm_lv"`
  3692. Cnt float64 `json:"cnt"`
  3693. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3694. DrtReimFlag string `json:"drt_reim_flag"`
  3695. FeedetlSn string `json:"feedetl_sn"`
  3696. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3697. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3698. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3699. ListSpItemFlag string `json:"list_sp_item_flag"`
  3700. LmtUsedFlag string `json:"lmt_used_flag"`
  3701. MedChrgitmType string `json:"med_chrgitm_type"`
  3702. Memo string `json:"memo"`
  3703. OverlmtAmt float64 `json:"overlmt_amt"`
  3704. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3705. Pric float64 `json:"pric"`
  3706. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3707. SelfpayProp float64 `json:"selfpay_prop"`
  3708. } `json:"result"`
  3709. } `json:"output"`
  3710. RefmsgTime string `json:"refmsg_time"`
  3711. RespondTime string `json:"respond_time"`
  3712. Signtype string `json:"signtype"`
  3713. WarnMsg string `json:"warn_msg"`
  3714. }
  3715. type ResultFive struct {
  3716. Balc float64 `json:"balc"`
  3717. CvlservFlag string `json:"cvlserv_flag"`
  3718. EmpName string `json:"emp_name"`
  3719. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3720. Insutype string `json:"insutype"`
  3721. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3722. PausInsuDate string `json:"paus_insu_date"`
  3723. PsnInsuDate string `json:"psn_insu_date"`
  3724. PsnInsuStas string `json:"psn_insu_stas"`
  3725. PsnType string `json:"psn_type"`
  3726. }
  3727. type ResultSix struct {
  3728. Cainfo interface{} `json:"cainfo"`
  3729. ErrMsg string `json:"err_msg"`
  3730. InfRefmsgid string `json:"inf_refmsgid"`
  3731. Infcode int64 `json:"infcode"`
  3732. Output struct {
  3733. } `json:"output"`
  3734. RefmsgTime string `json:"refmsg_time"`
  3735. RespondTime string `json:"respond_time"`
  3736. Signtype interface{} `json:"signtype"`
  3737. WarnMsg interface{} `json:"warn_msg"`
  3738. }
  3739. type ResultSix10265 struct {
  3740. Cainfo interface{} `json:"cainfo"`
  3741. ErrMsg string `json:"err_msg"`
  3742. InfRefmsgid string `json:"inf_refmsgid"`
  3743. Infcode string `json:"infcode"`
  3744. Output struct {
  3745. } `json:"output"`
  3746. RefmsgTime string `json:"refmsg_time"`
  3747. RespondTime string `json:"respond_time"`
  3748. Signtype interface{} `json:"signtype"`
  3749. WarnMsg interface{} `json:"warn_msg"`
  3750. }
  3751. type ResultSeven struct {
  3752. Cainfo string `json:"cainfo"`
  3753. ErrMsg string `json:"err_msg"`
  3754. InfRefmsgid string `json:"inf_refmsgid"`
  3755. Infcode int64 `json:"infcode"`
  3756. Output struct {
  3757. Setldetail []interface{} `json:"setldetail"`
  3758. Setlinfo struct {
  3759. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3760. AcctPay float64 `json:"acct_pay"`
  3761. ActPayDedc float64 `json:"act_pay_dedc"`
  3762. Age float64 `json:"age"`
  3763. Balc float64 `json:"balc"`
  3764. Brdy string `json:"brdy"`
  3765. Certno string `json:"certno"`
  3766. ClrOptins string `json:"clr_optins"`
  3767. ClrType string `json:"clr_type"`
  3768. ClrWay string `json:"clr_way"`
  3769. CvlservFlag string `json:"cvlserv_flag"`
  3770. CvlservPay float64 `json:"cvlserv_pay"`
  3771. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3772. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3773. Gend string `json:"gend"`
  3774. HifesPay float64 `json:"hifes_pay"`
  3775. HifmiPay float64 `json:"hifmi_pay"`
  3776. HifpPay float64 `json:"hifp_pay"`
  3777. HospPartAmt float64 `json:"hosp_part_amt"`
  3778. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3779. Insutype string `json:"insutype"`
  3780. MafPay float64 `json:"maf_pay"`
  3781. MdtrtCertType string `json:"mdtrt_cert_type"`
  3782. HifobPay float64 `json:"hifob_pay"`
  3783. MdtrtID string `json:"mdtrt_id"`
  3784. MedType string `json:"med_type"`
  3785. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3786. MedinsSetlID string `json:"medins_setl_id"`
  3787. Naty string `json:"naty"`
  3788. OthPay float64 `json:"oth_pay"`
  3789. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3790. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3791. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3792. PsnCashPay float64 `json:"psn_cash_pay"`
  3793. PsnCertType string `json:"psn_cert_type"`
  3794. PsnName string `json:"psn_name"`
  3795. PsnNo string `json:"psn_no"`
  3796. PsnPartAmt float64 `json:"psn_part_amt"`
  3797. PsnType string `json:"psn_type"`
  3798. SetlID string `json:"setl_id"`
  3799. SetlTime string `json:"setl_time"`
  3800. } `json:"setlinfo"`
  3801. } `json:"output"`
  3802. RefmsgTime string `json:"refmsg_time"`
  3803. RespondTime string `json:"respond_time"`
  3804. Signtype interface{} `json:"signtype"`
  3805. WarnMsg interface{} `json:"warn_msg"`
  3806. }
  3807. type ResultSeven10265 struct {
  3808. Cainfo string `json:"cainfo"`
  3809. ErrMsg string `json:"err_msg"`
  3810. InfRefmsgid string `json:"inf_refmsgid"`
  3811. Infcode string `json:"infcode"`
  3812. Output struct {
  3813. Setldetail []interface{} `json:"setldetail"`
  3814. Setlinfo struct {
  3815. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3816. AcctPay float64 `json:"acct_pay"`
  3817. ActPayDedc float64 `json:"act_pay_dedc"`
  3818. Age float64 `json:"age"`
  3819. Balc float64 `json:"balc"`
  3820. Brdy string `json:"brdy"`
  3821. Certno string `json:"certno"`
  3822. ClrOptins string `json:"clr_optins"`
  3823. ClrType string `json:"clr_type"`
  3824. ClrWay string `json:"clr_way"`
  3825. CvlservFlag string `json:"cvlserv_flag"`
  3826. CvlservPay float64 `json:"cvlserv_pay"`
  3827. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3828. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3829. Gend string `json:"gend"`
  3830. HifesPay float64 `json:"hifes_pay"`
  3831. HifmiPay float64 `json:"hifmi_pay"`
  3832. HifpPay float64 `json:"hifp_pay"`
  3833. HospPartAmt float64 `json:"hosp_part_amt"`
  3834. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3835. Insutype string `json:"insutype"`
  3836. MafPay float64 `json:"maf_pay"`
  3837. MdtrtCertType string `json:"mdtrt_cert_type"`
  3838. HifobPay float64 `json:"hifob_pay"`
  3839. MdtrtID string `json:"mdtrt_id"`
  3840. MedType string `json:"med_type"`
  3841. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3842. MedinsSetlID string `json:"medins_setl_id"`
  3843. Naty string `json:"naty"`
  3844. OthPay float64 `json:"oth_pay"`
  3845. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3846. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3847. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3848. PsnCashPay float64 `json:"psn_cash_pay"`
  3849. PsnCertType string `json:"psn_cert_type"`
  3850. PsnName string `json:"psn_name"`
  3851. PsnNo string `json:"psn_no"`
  3852. PsnPartAmt float64 `json:"psn_part_amt"`
  3853. PsnType string `json:"psn_type"`
  3854. SetlID string `json:"setl_id"`
  3855. SetlTime string `json:"setl_time"`
  3856. } `json:"setlinfo"`
  3857. } `json:"output"`
  3858. RefmsgTime string `json:"refmsg_time"`
  3859. RespondTime string `json:"respond_time"`
  3860. Signtype interface{} `json:"signtype"`
  3861. WarnMsg interface{} `json:"warn_msg"`
  3862. }
  3863. type ResultEight struct {
  3864. Cainfo string `json:"cainfo"`
  3865. ErrMsg string `json:"err_msg"`
  3866. InfRefmsgid string `json:"inf_refmsgid"`
  3867. Infcode int64 `json:"infcode"`
  3868. Output struct {
  3869. Stmtinfo struct {
  3870. SetlOptins string `json:"setl_optins"`
  3871. StmtRslt string `json:"stmt_rslt"`
  3872. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3873. } `json:"stmtinfo"`
  3874. } `json:"output"`
  3875. RefmsgTime string `json:"refmsg_time"`
  3876. RespondTime string `json:"respond_time"`
  3877. Signtype interface{} `json:"signtype"`
  3878. WarnMsg interface{} `json:"warn_msg"`
  3879. }
  3880. type ResultEightFor10188 struct {
  3881. Cainfo string `json:"cainfo"`
  3882. ErrMsg string `json:"err_msg"`
  3883. InfRefmsgid string `json:"inf_refmsgid"`
  3884. Infcode string `json:"infcode"`
  3885. Output struct {
  3886. Stmtinfo struct {
  3887. SetlOptins string `json:"setl_optins"`
  3888. StmtRslt string `json:"stmt_rslt"`
  3889. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3890. } `json:"stmtinfo"`
  3891. } `json:"output"`
  3892. RefmsgTime string `json:"refmsg_time"`
  3893. RespondTime string `json:"respond_time"`
  3894. Signtype interface{} `json:"signtype"`
  3895. WarnMsg interface{} `json:"warn_msg"`
  3896. }
  3897. type ResultNine struct {
  3898. Cainfo string `json:"cainfo"`
  3899. ErrMsg string `json:"err_msg"`
  3900. InfRefmsgid string `json:"inf_refmsgid"`
  3901. Infcode int64 `json:"infcode"`
  3902. Output struct {
  3903. FileQuryNo string `json:"file_qury_no"`
  3904. } `json:"output"`
  3905. RefmsgTime string `json:"refmsg_time"`
  3906. RespondTime string `json:"respond_time"`
  3907. Signtype interface{} `json:"signtype"`
  3908. WarnMsg interface{} `json:"warn_msg"`
  3909. }
  3910. type ResultTen struct {
  3911. Cainfo string `json:"cainfo"`
  3912. ErrMsg string `json:"err_msg"`
  3913. InfRefmsgid string `json:"inf_refmsgid"`
  3914. Infcode int64 `json:"infcode"`
  3915. Output struct {
  3916. DldEndtime string `json:"dld_endtime"`
  3917. FileQuryNo string `json:"file_qury_no"`
  3918. Filename string `json:"filename"`
  3919. } `json:"output"`
  3920. RefmsgTime string `json:"refmsg_time"`
  3921. RespondTime string `json:"respond_time"`
  3922. Signtype interface{} `json:"signtype"`
  3923. WarnMsg interface{} `json:"warn_msg"`
  3924. }
  3925. //type Autogenerated struct {
  3926. // Output struct {
  3927. // Setlinfo struct {
  3928. // SetlTime string `json:"setl_time"`
  3929. // CvlservPay float64 `json:"cvlserv_pay"`
  3930. // Year string `json:"year"`
  3931. // MedType string `json:"med_type"`
  3932. // PsnPay float64 `json:"psn_pay"`
  3933. // OpterID string `json:"opter_id"`
  3934. // Begndate string `json:"begndate"`
  3935. // FlxempeFlag string `json:"flxempe_flag"`
  3936. // HifmiPay float64 `json:"hifmi_pay"`
  3937. // PsnNo string `json:"psn_no"`
  3938. // ActPayDedc float64 `json:"act_pay_dedc"`
  3939. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3940. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3941. // ClrWay string `json:"clr_way"`
  3942. // OthPay float64 `json:"oth_pay"`
  3943. // Gend string `json:"gend"`
  3944. // MdtrtID string `json:"mdtrt_id"`
  3945. // AcctPay float64 `json:"acct_pay"`
  3946. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3947. // Insutype string `json:"insutype"`
  3948. // Invono interface{} `json:"invono"`
  3949. // Enddate string `json:"enddate"`
  3950. // CashPayamt float64 `json:"cash_payamt"`
  3951. // PsnType string `json:"psn_type"`
  3952. // FixmedinsName string `json:"fixmedins_name"`
  3953. // HifpPay float64 `json:"hifp_pay"`
  3954. // NewFlag interface{} `json:"new_flag"`
  3955. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3956. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3957. // PayLoc string `json:"pay_loc"`
  3958. // ClrType string `json:"clr_type"`
  3959. // RefdSetlFlag string `json:"refd_setl_flag"`
  3960. // CvlservFlag string `json:"cvlserv_flag"`
  3961. // EmpName string `json:"emp_name"`
  3962. // Brdy string `json:"brdy"`
  3963. // Naty string `json:"naty"`
  3964. // Certno string `json:"certno"`
  3965. // DiseCode string `json:"dise_code"`
  3966. // FixmedinsCode string `json:"fixmedins_code"`
  3967. // DedcHospLv string `json:"dedc_hosp_lv"`
  3968. // OpterName string `json:"opter_name"`
  3969. // Balc float64 `json:"balc"`
  3970. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3971. // PsnCertType string `json:"psn_cert_type"`
  3972. // HifobPay float64 `json:"hifob_pay"`
  3973. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3974. // HifesPay float64 `json:"hifes_pay"`
  3975. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3976. // OptTime string `json:"opt_time"`
  3977. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3978. // SetlID string `json:"setl_id"`
  3979. // MafPay float64 `json:"maf_pay"`
  3980. // PsnName string `json:"psn_name"`
  3981. // InsuOptins interface{} `json:"insu_optins"`
  3982. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3983. // ClrOptins string `json:"clr_optins"`
  3984. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3985. // DiseName string `json:"dise_name"`
  3986. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3987. // Age float64 `json:"age"`
  3988. // DtrtCertType string `json:"dtrt_cert_type"`
  3989. // HospLv string `json:"hosp_lv"`
  3990. // } `json:"setlinfo"`
  3991. // Setldetail []struct {
  3992. // FundPayType string `json:"fund_pay_type"`
  3993. // FundPayamt float64 `json:"fund_payamt"`
  3994. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3995. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3996. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3997. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3998. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3999. // } `json:"setldetail"`
  4000. // } `json:"output"`
  4001. // Infcode int `json:"infcode"`
  4002. // WarnMsg interface{} `json:"warn_msg"`
  4003. // Cainfo interface{} `json:"cainfo"`
  4004. // ErrMsg interface{} `json:"err_msg"`
  4005. // RefmsgTime string `json:"refmsg_time"`
  4006. // Signtype interface{} `json:"signtype"`
  4007. // RespondTime string `json:"respond_time"`
  4008. // InfRefmsgid string `json:"inf_refmsgid"`
  4009. //}
  4010. type ResultEleven struct {
  4011. Cainfo string `json:"cainfo"`
  4012. ErrMsg string `json:"err_msg"`
  4013. InfRefmsgid string `json:"inf_refmsgid"`
  4014. Infcode int64 `json:"infcode"`
  4015. Output struct {
  4016. Setlinfo struct {
  4017. SetlTime string `json:"setl_time"`
  4018. CvlservPay float64 `json:"cvlserv_pay"`
  4019. Year string `json:"year"`
  4020. MedType string `json:"med_type"`
  4021. PsnPay float64 `json:"psn_pay"`
  4022. OpterID string `json:"opter_id"`
  4023. Begndate string `json:"begndate"`
  4024. FlxempeFlag string `json:"flxempe_flag"`
  4025. HifmiPay float64 `json:"hifmi_pay"`
  4026. PsnNo string `json:"psn_no"`
  4027. ActPayDedc float64 `json:"act_pay_dedc"`
  4028. MedinsSetlID interface{} `json:"medins_setl_id"`
  4029. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4030. ClrWay string `json:"clr_way"`
  4031. OthPay float64 `json:"oth_pay"`
  4032. Gend string `json:"gend"`
  4033. MdtrtID string `json:"mdtrt_id"`
  4034. AcctPay float64 `json:"acct_pay"`
  4035. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4036. Insutype string `json:"insutype"`
  4037. Invono interface{} `json:"invono"`
  4038. Enddate string `json:"enddate"`
  4039. CashPayamt float64 `json:"cash_payamt"`
  4040. PsnType string `json:"psn_type"`
  4041. FixmedinsName string `json:"fixmedins_name"`
  4042. HifpPay float64 `json:"hifp_pay"`
  4043. NewFlag interface{} `json:"new_flag"`
  4044. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4045. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4046. PayLoc string `json:"pay_loc"`
  4047. ClrType string `json:"clr_type"`
  4048. RefdSetlFlag string `json:"refd_setl_flag"`
  4049. CvlservFlag string `json:"cvlserv_flag"`
  4050. EmpName string `json:"emp_name"`
  4051. Brdy string `json:"brdy"`
  4052. Naty string `json:"naty"`
  4053. Certno string `json:"certno"`
  4054. DiseCode string `json:"dise_code"`
  4055. FixmedinsCode string `json:"fixmedins_code"`
  4056. DedcHospLv string `json:"dedc_hosp_lv"`
  4057. OpterName string `json:"opter_name"`
  4058. Balc float64 `json:"balc"`
  4059. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4060. PsnCertType string `json:"psn_cert_type"`
  4061. HifobPay float64 `json:"hifob_pay"`
  4062. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4063. HifesPay float64 `json:"hifes_pay"`
  4064. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4065. OptTime string `json:"opt_time"`
  4066. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4067. SetlID string `json:"setl_id"`
  4068. MafPay float64 `json:"maf_pay"`
  4069. PsnName string `json:"psn_name"`
  4070. InsuOptins interface{} `json:"insu_optins"`
  4071. PrefFundPay interface{} `json:"pref_fund_pay"`
  4072. ClrOptins string `json:"clr_optins"`
  4073. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4074. DiseName string `json:"dise_name"`
  4075. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4076. Age float64 `json:"age"`
  4077. DtrtCertType string `json:"dtrt_cert_type"`
  4078. HospLv string `json:"hosp_lv"`
  4079. } `json:"setlinfo"`
  4080. } `json:"output"`
  4081. RefmsgTime string `json:"refmsg_time"`
  4082. RespondTime string `json:"respond_time"`
  4083. Signtype interface{} `json:"signtype"`
  4084. WarnMsg interface{} `json:"warn_msg"`
  4085. }
  4086. type ResultEleven10265 struct {
  4087. Cainfo string `json:"cainfo"`
  4088. ErrMsg string `json:"err_msg"`
  4089. InfRefmsgid string `json:"inf_refmsgid"`
  4090. Infcode string `json:"infcode"`
  4091. Output struct {
  4092. Setlinfo struct {
  4093. SetlTime string `json:"setl_time"`
  4094. CvlservPay float64 `json:"cvlserv_pay"`
  4095. Year string `json:"year"`
  4096. MedType string `json:"med_type"`
  4097. PsnPay float64 `json:"psn_pay"`
  4098. OpterID string `json:"opter_id"`
  4099. Begndate string `json:"begndate"`
  4100. FlxempeFlag string `json:"flxempe_flag"`
  4101. HifmiPay float64 `json:"hifmi_pay"`
  4102. PsnNo string `json:"psn_no"`
  4103. ActPayDedc float64 `json:"act_pay_dedc"`
  4104. MedinsSetlID interface{} `json:"medins_setl_id"`
  4105. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4106. ClrWay string `json:"clr_way"`
  4107. OthPay float64 `json:"oth_pay"`
  4108. Gend string `json:"gend"`
  4109. MdtrtID string `json:"mdtrt_id"`
  4110. AcctPay float64 `json:"acct_pay"`
  4111. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4112. Insutype string `json:"insutype"`
  4113. Invono interface{} `json:"invono"`
  4114. Enddate string `json:"enddate"`
  4115. CashPayamt float64 `json:"cash_payamt"`
  4116. PsnType string `json:"psn_type"`
  4117. FixmedinsName string `json:"fixmedins_name"`
  4118. HifpPay float64 `json:"hifp_pay"`
  4119. NewFlag interface{} `json:"new_flag"`
  4120. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4121. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4122. PayLoc string `json:"pay_loc"`
  4123. ClrType string `json:"clr_type"`
  4124. RefdSetlFlag string `json:"refd_setl_flag"`
  4125. CvlservFlag string `json:"cvlserv_flag"`
  4126. EmpName string `json:"emp_name"`
  4127. Brdy string `json:"brdy"`
  4128. Naty string `json:"naty"`
  4129. Certno string `json:"certno"`
  4130. DiseCode string `json:"dise_code"`
  4131. FixmedinsCode string `json:"fixmedins_code"`
  4132. DedcHospLv string `json:"dedc_hosp_lv"`
  4133. OpterName string `json:"opter_name"`
  4134. Balc float64 `json:"balc"`
  4135. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4136. PsnCertType string `json:"psn_cert_type"`
  4137. HifobPay float64 `json:"hifob_pay"`
  4138. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4139. HifesPay float64 `json:"hifes_pay"`
  4140. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4141. OptTime string `json:"opt_time"`
  4142. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4143. SetlID string `json:"setl_id"`
  4144. MafPay float64 `json:"maf_pay"`
  4145. PsnName string `json:"psn_name"`
  4146. InsuOptins interface{} `json:"insu_optins"`
  4147. PrefFundPay interface{} `json:"pref_fund_pay"`
  4148. ClrOptins string `json:"clr_optins"`
  4149. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4150. DiseName string `json:"dise_name"`
  4151. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4152. Age float64 `json:"age"`
  4153. DtrtCertType string `json:"dtrt_cert_type"`
  4154. HospLv string `json:"hosp_lv"`
  4155. } `json:"setlinfo"`
  4156. } `json:"output"`
  4157. RefmsgTime string `json:"refmsg_time"`
  4158. RespondTime string `json:"respond_time"`
  4159. Signtype interface{} `json:"signtype"`
  4160. WarnMsg interface{} `json:"warn_msg"`
  4161. }
  4162. type ResultTwelve struct {
  4163. Cainfo string `json:"cainfo"`
  4164. ErrMsg string `json:"err_msg"`
  4165. InfRefmsgid string `json:"inf_refmsgid"`
  4166. Infcode int64 `json:"infcode"`
  4167. Output struct {
  4168. MdtrtId string `json:"mdtrt_id"`
  4169. ChrgBchno string `json:"chrg_bchno"`
  4170. PsnNo string `json:"psn_no"`
  4171. } `json:"output"`
  4172. RefmsgTime string `json:"refmsg_time"`
  4173. RespondTime string `json:"respond_time"`
  4174. Signtype interface{} `json:"signtype"`
  4175. WarnMsg interface{} `json:"warn_msg"`
  4176. }
  4177. type ResultThirteen struct {
  4178. ErrMsg string `json:"err_msg"`
  4179. InfRefmsgid string `json:"inf_refmsgid"`
  4180. Infcode int64 `json:"infcode"`
  4181. Output struct {
  4182. Result struct {
  4183. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4184. } `json:"result"`
  4185. } `json:"output"`
  4186. RefmsgTime string `json:"refmsg_time"`
  4187. RespondTime string `json:"respond_time"`
  4188. Signtype interface{} `json:"signtype"`
  4189. WarnInfo interface{} `json:"warn_info"`
  4190. }
  4191. type ResultThirteen10265 struct {
  4192. ErrMsg string `json:"err_msg"`
  4193. InfRefmsgid string `json:"inf_refmsgid"`
  4194. Infcode string `json:"infcode"`
  4195. Output struct {
  4196. Result struct {
  4197. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4198. } `json:"result"`
  4199. } `json:"output"`
  4200. RefmsgTime string `json:"refmsg_time"`
  4201. RespondTime string `json:"respond_time"`
  4202. Signtype interface{} `json:"signtype"`
  4203. WarnInfo interface{} `json:"warn_info"`
  4204. }
  4205. type ResultFourteen struct {
  4206. ErrMsg string `json:"err_msg"`
  4207. InfRefmsgid string `json:"inf_refmsgid"`
  4208. Infcode int64 `json:"infcode"`
  4209. Output struct {
  4210. } `json:"output"`
  4211. RefmsgTime string `json:"refmsg_time"`
  4212. RespondTime string `json:"respond_time"`
  4213. Signtype interface{} `json:"signtype"`
  4214. WarnInfo interface{} `json:"warn_info"`
  4215. }
  4216. type ResultFourteen10265 struct {
  4217. ErrMsg string `json:"err_msg"`
  4218. InfRefmsgid string `json:"inf_refmsgid"`
  4219. Infcode string `json:"infcode"`
  4220. Output struct {
  4221. } `json:"output"`
  4222. RefmsgTime string `json:"refmsg_time"`
  4223. RespondTime string `json:"respond_time"`
  4224. Signtype interface{} `json:"signtype"`
  4225. WarnInfo interface{} `json:"warn_info"`
  4226. }
  4227. type ResultSixteen struct {
  4228. Cainfo string `json:"cainfo"`
  4229. ErrMsg string `json:"err_msg"`
  4230. InfRefmsgid string `json:"inf_refmsgid"`
  4231. Infcode int64 `json:"infcode"`
  4232. Output struct {
  4233. Setldetail []interface{} `json:"setldetail"`
  4234. Setlinfo struct {
  4235. MdtrtID string `json:"mdtrt_id"`
  4236. SetlID string `json:"setl_id"`
  4237. ClrOptins string `json:"clr_optins"`
  4238. SetlTime string `json:"setl_time"`
  4239. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4240. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4241. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4242. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4243. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4244. ActPayDedc float64 `json:"act_pay_dedc"`
  4245. HifpPay float64 `json:"hifp_pay"`
  4246. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4247. Lfpay float64 `json:"selfpay"`
  4248. CvlservPay float64 `json:"cvlserv_pay"`
  4249. HifesPay float64 `json:"hifes_pay"`
  4250. HifmiPay float64 `json:"hifmi_pay"`
  4251. HifobPay float64 `json:"hifob_pay"`
  4252. MafPay float64 `json:"maf_pay"`
  4253. OthPay float64 `json:"oth_pay"`
  4254. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4255. PsnPartAmt float64 `json:"psn_part_amt"`
  4256. AcctPay float64 `json:"acct_pay"`
  4257. Balc float64 `json:"balc"`
  4258. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4259. HospPartAmt float64 `json:"hosp_part_amt"`
  4260. MedinsSetlID string `json:"medins_setl_id"`
  4261. PdnCashPay string `json:"pdn_cash_pay"`
  4262. } `json:"setlinfo"`
  4263. } `json:"output"`
  4264. RefmsgTime string `json:"refmsg_time"`
  4265. RespondTime string `json:"respond_time"`
  4266. Signtype interface{} `json:"signtype"`
  4267. WarnMsg interface{} `json:"warn_msg"`
  4268. }
  4269. type ResultSixteen10265 struct {
  4270. Cainfo string `json:"cainfo"`
  4271. ErrMsg string `json:"err_msg"`
  4272. InfRefmsgid string `json:"inf_refmsgid"`
  4273. Infcode string `json:"infcode"`
  4274. Output struct {
  4275. Setldetail []interface{} `json:"setldetail"`
  4276. Setlinfo struct {
  4277. MdtrtID string `json:"mdtrt_id"`
  4278. SetlID string `json:"setl_id"`
  4279. ClrOptins string `json:"clr_optins"`
  4280. SetlTime string `json:"setl_time"`
  4281. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4282. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4283. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4284. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4285. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4286. ActPayDedc float64 `json:"act_pay_dedc"`
  4287. HifpPay float64 `json:"hifp_pay"`
  4288. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4289. Lfpay float64 `json:"selfpay"`
  4290. CvlservPay float64 `json:"cvlserv_pay"`
  4291. HifesPay float64 `json:"hifes_pay"`
  4292. HifmiPay float64 `json:"hifmi_pay"`
  4293. HifobPay float64 `json:"hifob_pay"`
  4294. MafPay float64 `json:"maf_pay"`
  4295. OthPay float64 `json:"oth_pay"`
  4296. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4297. PsnPartAmt float64 `json:"psn_part_amt"`
  4298. AcctPay float64 `json:"acct_pay"`
  4299. Balc float64 `json:"balc"`
  4300. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4301. HospPartAmt float64 `json:"hosp_part_amt"`
  4302. MedinsSetlID string `json:"medins_setl_id"`
  4303. PdnCashPay string `json:"pdn_cash_pay"`
  4304. } `json:"setlinfo"`
  4305. } `json:"output"`
  4306. RefmsgTime string `json:"refmsg_time"`
  4307. RespondTime string `json:"respond_time"`
  4308. Signtype interface{} `json:"signtype"`
  4309. WarnMsg interface{} `json:"warn_msg"`
  4310. }
  4311. type ResultSeventeen struct {
  4312. ErrMsg string `json:"err_msg"`
  4313. InfRefmsgid string `json:"inf_refmsgid"`
  4314. Infcode int64 `json:"infcode"`
  4315. Output struct {
  4316. SetlListId string `json:"setl_list_id"`
  4317. } `json:"output"`
  4318. RefmsgTime string `json:"refmsg_time"`
  4319. RespondTime string `json:"respond_time"`
  4320. Signtype string `json:"signtype"`
  4321. WarnInfo string `json:"warn_info"`
  4322. }
  4323. type ResultSeventeenOther struct {
  4324. ErrMsg string `json:"err_msg"`
  4325. InfRefmsgid string `json:"inf_refmsgid"`
  4326. Infcode string `json:"infcode"`
  4327. Output struct {
  4328. SetlListId string `json:"setl_list_id"`
  4329. } `json:"output"`
  4330. RefmsgTime string `json:"refmsg_time"`
  4331. RespondTime string `json:"respond_time"`
  4332. Signtype string `json:"signtype"`
  4333. WarnInfo string `json:"warn_info"`
  4334. }
  4335. type Result90991 struct {
  4336. ErrMsg string `json:"err_msg"`
  4337. InfRefmsgid string `json:"inf_refmsgid"`
  4338. Infcode int64 `json:"infcode"`
  4339. Output struct {
  4340. Result struct {
  4341. PsnNo string `json:"psn_no"`
  4342. CardStat string `json:"card_stat"`
  4343. Certno string `json:"certno"`
  4344. PsnName string `json:"psn_name"`
  4345. CheckStat string `json:"check_stat"`
  4346. SscnoCheckStat string `json:"sscno_check_stat"`
  4347. } `json:"result"`
  4348. } `json:"output"`
  4349. RefmsgTime string `json:"refmsg_time"`
  4350. RespondTime string `json:"respond_time"`
  4351. Signtype interface{} `json:"signtype"`
  4352. WarnInfo interface{} `json:"warn_info"`
  4353. }
  4354. type Result90100 struct {
  4355. ErrMsg string `json:"err_msg"`
  4356. InfRefmsgid string `json:"inf_refmsgid"`
  4357. Infcode int64 `json:"infcode"`
  4358. Output struct {
  4359. PoolareaNo string `json:"poolarea_no"`
  4360. PoolareaNoName string `json:"poolarea_no_name"`
  4361. Insutype string `json:"insutype"`
  4362. InsutypeName string `json:"insutype_name"`
  4363. ClctType string `json:"clct_type"`
  4364. ClctTypeName string `json:"clct_type_name"`
  4365. ClctFlag string `json:"clct_flag"`
  4366. ClctFlagName string `json:"clct_flag_name"`
  4367. AccrymBegn string `json:"accrym_begn"`
  4368. AccrymEnd string `json:"accrym_end"`
  4369. ClctTime string `json:"clct_time"`
  4370. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4371. } `json:"output"`
  4372. RefmsgTime string `json:"refmsg_time"`
  4373. RespondTime string `json:"respond_time"`
  4374. Signtype interface{} `json:"signtype"`
  4375. WarnInfo interface{} `json:"warn_info"`
  4376. }
  4377. type Custom struct {
  4378. DetItemFeeSumamt string
  4379. Cut string
  4380. FeedetlSn string
  4381. Price string
  4382. MedListCodg string
  4383. Type int64
  4384. AdviceId int64
  4385. ProjectId int64
  4386. ItemId int64
  4387. }
  4388. type Result5301 struct {
  4389. ErrMsg string `json:"err_msg"`
  4390. InfRefmsgid string `json:"inf_refmsgid"`
  4391. Infcode int64 `json:"infcode"`
  4392. Output struct {
  4393. Result []struct {
  4394. OpspDiseCode string `json:"opsp_dise_code"`
  4395. OpspDiseName string `json:"opsp_dise_name"`
  4396. Begndate string `json:"begndate"`
  4397. Enddate string `json:"enddate"`
  4398. } `json:"feedetail"`
  4399. } `json:"output"`
  4400. RefmsgTime string `json:"refmsg_time"`
  4401. RespondTime string `json:"respond_time"`
  4402. Signtype interface{} `json:"signtype"`
  4403. WarnInfo interface{} `json:"warn_info"`
  4404. }
  4405. type Result5301For10265 struct {
  4406. ErrMsg string `json:"err_msg"`
  4407. InfRefmsgid string `json:"inf_refmsgid"`
  4408. Infcode string `json:"infcode"`
  4409. Output struct {
  4410. Result []struct {
  4411. OpspDiseCode string `json:"opsp_dise_code"`
  4412. OpspDiseName string `json:"opsp_dise_name"`
  4413. Begndate string `json:"begndate"`
  4414. Enddate string `json:"enddate"`
  4415. } `json:"feedetail"`
  4416. } `json:"output"`
  4417. RefmsgTime string `json:"refmsg_time"`
  4418. RespondTime string `json:"respond_time"`
  4419. Signtype interface{} `json:"signtype"`
  4420. WarnInfo interface{} `json:"warn_info"`
  4421. }
  4422. //获取个人信息----挂号-----上传就诊信息
  4423. func (c *HisApiController) GetRegisterInfo() {
  4424. id, _ := c.GetInt64("id")
  4425. record_time := c.GetString("record_time")
  4426. settlementValue, _ := c.GetInt64("settlement_value")
  4427. medical_insurance_card := c.GetString("medical_insurance_card")
  4428. name := c.GetString("name")
  4429. id_card_type, _ := c.GetInt64("id_card_type")
  4430. certificates, _ := c.GetInt64("certificates")
  4431. medical_care, _ := c.GetInt64("medical_care")
  4432. birthday := c.GetString("birthday")
  4433. id_card := c.GetString("id_card")
  4434. register_type, _ := c.GetInt64("register")
  4435. doctor, _ := c.GetInt64("doctor")
  4436. department, _ := c.GetInt64("department")
  4437. gender, _ := c.GetInt64("sex")
  4438. registration_fee, _ := c.GetFloat("registration_fee")
  4439. medical_expenses, _ := c.GetFloat("medical_expenses")
  4440. social_type, _ := c.GetInt64("social_type")
  4441. med_type := c.GetString("social_type")
  4442. admin_user_id, _ := c.GetInt64("admin_user_id")
  4443. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4444. timeLayout := "2006-01-02"
  4445. loc, _ := time.LoadLocation("Local")
  4446. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4447. birthUnix := birthdays.Unix()
  4448. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4449. if err != nil {
  4450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4451. return
  4452. }
  4453. recordDateTime := theTime.Unix()
  4454. adminInfo := c.GetAdminUserInfo()
  4455. var patient service.Patients
  4456. if id == 0 {
  4457. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4458. } else {
  4459. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4460. }
  4461. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4462. if patientPrescription.ID == 0 {
  4463. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4464. }
  4465. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4466. if patient.ID == 0 {
  4467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4468. return
  4469. }
  4470. if len(patient.IdCardNo) == 0 {
  4471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4472. return
  4473. }
  4474. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4475. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4476. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4477. //就诊结算未完成,不能进行二次挂号
  4478. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4479. if len(his) >= 1 {
  4480. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4481. if len(his) >= 1 && order.ID == 0 {
  4482. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4483. return
  4484. }
  4485. }
  4486. //var register_log string
  4487. if config.IsOpen == 1 {
  4488. var res ResultTwo
  4489. var res10265 ResultTwo10265
  4490. var PsnNo string
  4491. var PsnCertType string
  4492. var Certno string
  4493. var PsnName string
  4494. var Gend string
  4495. var Naty string
  4496. var Brdy string
  4497. var Age float64
  4498. var infoStr string
  4499. var idetinfoStr string
  4500. var infocode int64
  4501. var verify_number string
  4502. fmt.Println(verify_number)
  4503. if miConfig.MdtrtareaAdmvs == "421300" {
  4504. psn_info, _ := service.GetPsnByPatientId(id)
  4505. PsnNo = psn_info.PsnNo
  4506. PsnCertType = psn_info.PsnCertType
  4507. Certno = psn_info.Certno
  4508. PsnName = psn_info.PsnName
  4509. Gend = psn_info.Gend
  4510. Naty = psn_info.Naty
  4511. Brdy = psn_info.Brdy
  4512. Age = psn_info.Age
  4513. infoStr = psn_info.Insuinfo
  4514. idetinfoStr = psn_info.Idetinfo
  4515. infocode = 0
  4516. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4517. psn_info, _ := service.GetPsnByPatientId(id)
  4518. PsnNo = psn_info.PsnNo
  4519. PsnCertType = psn_info.PsnCertType
  4520. Certno = psn_info.Certno
  4521. PsnName = psn_info.PsnName
  4522. Gend = psn_info.Gend
  4523. Naty = psn_info.Naty
  4524. Brdy = psn_info.Brdy
  4525. Age = psn_info.Age
  4526. infoStr = psn_info.Insuinfo
  4527. idetinfoStr = psn_info.Idetinfo
  4528. infocode = 0
  4529. verify_number = psn_info.VerifyNumber
  4530. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4531. psn_info, _ := service.GetPsnByPatientId(id)
  4532. PsnNo = psn_info.PsnNo
  4533. PsnCertType = psn_info.PsnCertType
  4534. Certno = psn_info.Certno
  4535. PsnName = psn_info.PsnName
  4536. Gend = psn_info.Gend
  4537. Naty = psn_info.Naty
  4538. Brdy = psn_info.Brdy
  4539. Age = psn_info.Age
  4540. infoStr = psn_info.Insuinfo
  4541. idetinfoStr = psn_info.Idetinfo
  4542. infocode = 0
  4543. verify_number = psn_info.VerifyNumber
  4544. } else {
  4545. var result string
  4546. var requestLog string
  4547. if miConfig.UserOrgId == 10138 {
  4548. 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)
  4549. } else {
  4550. 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)
  4551. }
  4552. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4553. if miConfig.Code == "H15049901371" {
  4554. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4555. utils.ErrorLog("解析失败:%v", err)
  4556. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4557. return
  4558. }
  4559. res.ErrMsg = res10265.ErrMsg
  4560. res.Output = res10265.Output
  4561. res.InfRefmsgid = res10265.InfRefmsgid
  4562. } else {
  4563. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4564. utils.ErrorLog("解析失败:%v", err)
  4565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4566. return
  4567. }
  4568. }
  4569. PsnNo = res.Output.Baseinfo.PsnNo
  4570. PsnCertType = res.Output.Baseinfo.PsnCertType
  4571. Certno = res.Output.Baseinfo.Certno
  4572. PsnName = res.Output.Baseinfo.PsnName
  4573. Gend = res.Output.Baseinfo.Gend
  4574. Naty = res.Output.Baseinfo.Naty
  4575. Brdy = res.Output.Baseinfo.Brdy
  4576. Age = res.Output.Baseinfo.Age
  4577. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4578. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4579. infoStr = string(Iinfos)
  4580. idetinfoStr = string(Idetinfos)
  4581. if miConfig.Code == "H15049901371" {
  4582. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4583. } else {
  4584. infocode = res.Infcode
  4585. }
  4586. }
  4587. if infocode == 0 {
  4588. his := models.VMHisPatient{
  4589. Name: name,
  4590. Gender: gender,
  4591. Birthday: birthUnix,
  4592. MedicalTreatmentType: medical_care,
  4593. IdType: certificates,
  4594. IdCardNo: id_card,
  4595. BalanceAccountsType: settlementValue,
  4596. SocialType: social_type,
  4597. MedicalInsuranceNumber: medical_insurance_card,
  4598. RegisterType: register_type,
  4599. RegisterCost: registration_fee,
  4600. TreatmentCost: medical_expenses,
  4601. Status: 1,
  4602. Ctime: time.Now().Unix(),
  4603. Mtime: time.Now().Unix(),
  4604. PsnNo: PsnNo,
  4605. PsnCertType: PsnCertType,
  4606. Certno: Certno,
  4607. PsnName: PsnName,
  4608. Gend: Gend,
  4609. Naty: Naty,
  4610. Brdy: Brdy,
  4611. Age: Age,
  4612. Iinfo: infoStr,
  4613. Idetinfo: idetinfoStr,
  4614. PatientId: patient.ID,
  4615. RecordDate: theTime.Unix(),
  4616. UserOrgId: adminInfo.CurrentOrgId,
  4617. AdminUserId: admin_user_id,
  4618. IsReturn: 1,
  4619. IdCardType: id_card_type,
  4620. Doctor: doctor,
  4621. Departments: department,
  4622. }
  4623. timestamp := time.Now().Unix()
  4624. tempTime := time.Unix(timestamp, 0)
  4625. timeFormat := tempTime.Format("20060102150405")
  4626. chrgBchno := rand.Intn(100000) + 10000
  4627. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4628. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4629. department, _ := service.GetDepartMentDetail(department)
  4630. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4631. IdCardNo := ""
  4632. if id_card_type == 1 {
  4633. // IdCardNo = medical_insurance_card
  4634. IdCardNo = patient.IdCardNo
  4635. } else {
  4636. IdCardNo = patient.IdCardNo
  4637. }
  4638. var rf []*ResultFive
  4639. json.Unmarshal([]byte(his.Iinfo), &rf)
  4640. var insutypes []*ResultFive
  4641. var insutype string
  4642. var insuplc_admdvs_temp string
  4643. var is390 int = 0
  4644. var is310 int = 0
  4645. for _, item := range rf {
  4646. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4647. insutypes = append(insutypes, item)
  4648. }
  4649. }
  4650. if len(insutypes) == 1 {
  4651. insutype = insutypes[0].Insutype
  4652. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4653. } else {
  4654. for _, i := range insutypes {
  4655. if i.Insutype == "390" {
  4656. is390 = 1
  4657. }
  4658. if i.Insutype == "310" {
  4659. is310 = 1
  4660. }
  4661. }
  4662. }
  4663. if is390 == 1 {
  4664. insutype = "390"
  4665. }
  4666. if is310 == 1 {
  4667. insutype = "310"
  4668. }
  4669. if len(insutypes) == 0 {
  4670. insutype = "310"
  4671. }
  4672. if len(insutypes) == 2 {
  4673. insutype = med_type
  4674. }
  4675. if len(med_type) > 0 {
  4676. insutype = med_type
  4677. }
  4678. //for _, item := range rf {
  4679. // if item.Insutype == insutype {
  4680. // insuplc_admdvs = item.InsuplcAdmdvs
  4681. // }
  4682. //}
  4683. var infocode int64
  4684. var resThree ResultThree
  4685. var resThree10265 ResultThree10265
  4686. if len(insuplc_admdvs) == 0 {
  4687. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4688. } else {
  4689. insuplc_admdvs_temp = insuplc_admdvs
  4690. }
  4691. if miConfig.MdtrtareaAdmvs == "421300" {
  4692. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4693. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4694. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4695. "&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
  4696. resp, requestErr := http.Get(api)
  4697. if requestErr != nil {
  4698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4699. return
  4700. }
  4701. body, ioErr := ioutil.ReadAll(resp.Body)
  4702. if ioErr != nil {
  4703. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4704. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4705. return
  4706. }
  4707. var respJSON map[string]interface{}
  4708. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4709. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4710. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4711. return
  4712. }
  4713. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4714. result, _ := json.Marshal(respJSON)
  4715. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4716. utils.ErrorLog("解析失败:%v", err)
  4717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4718. return
  4719. }
  4720. infocode = resThree.Infcode
  4721. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4722. psn_info, _ := service.GetPsnByPatientId(id)
  4723. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4724. var cert_no string
  4725. if id_card_type == 3 {
  4726. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4727. cert_no = IdCardNo
  4728. } else if id_card_type == 4 {
  4729. cert_no = IdCardNo
  4730. psn_info.VerifyNumber = psn_info.VerifyNumber
  4731. } else {
  4732. bas := strings.Split(psn_info.CardInfo, "|")
  4733. cert_no = bas[2]
  4734. }
  4735. var api string
  4736. if miConfig.MdtrtareaAdmvs == "320921" {
  4737. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4738. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4739. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4740. } else {
  4741. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4742. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4743. "&insuplc_admdvs=" + insuplc_admdvs_temp + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&dept_code=" + department.Number + "&dept=" + department.Name + "&doctor_id=" + doctor_id + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&verify_number=" + psn_info.VerifyNumber + "&cainfo=" + miConfig.Cainfo
  4744. }
  4745. resp, requestErr := http.Get(api)
  4746. if requestErr != nil {
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. body, ioErr := ioutil.ReadAll(resp.Body)
  4751. if ioErr != nil {
  4752. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. var respJSON map[string]interface{}
  4757. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4758. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4760. return
  4761. }
  4762. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4763. result, _ := json.Marshal(respJSON)
  4764. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4765. utils.ErrorLog("解析失败:%v", err)
  4766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4767. return
  4768. }
  4769. resThree.ErrMsg = resThree10265.ErrMsg
  4770. resThree.Output = resThree10265.Output
  4771. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4772. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4773. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4774. result, requestLog := service.FJyb2201(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  4775. saveLog(result, requestLog, "2201", "挂号")
  4776. if miConfig.Code == "H15049901371" {
  4777. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4778. utils.ErrorLog("解析失败:%v", err)
  4779. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4780. return
  4781. }
  4782. resThree.ErrMsg = resThree10265.ErrMsg
  4783. resThree.Output = resThree10265.Output
  4784. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4785. } else {
  4786. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4787. utils.ErrorLog("解析失败:%v", err)
  4788. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4789. return
  4790. }
  4791. }
  4792. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4793. } else {
  4794. result, requestLog := service.Gdyb2201A(res.Output.Baseinfo.PsnNo, insutype, IdCardNo, miConfig.OrgName, roles.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, doctor_info.UserName, record_time)
  4795. saveLog(result, requestLog, "2201A", "挂号")
  4796. if miConfig.Code == "H15049901371" {
  4797. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4798. utils.ErrorLog("解析失败:%v", err)
  4799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4800. return
  4801. }
  4802. resThree.ErrMsg = resThree10265.ErrMsg
  4803. resThree.Output = resThree10265.Output
  4804. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4805. } else {
  4806. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4807. utils.ErrorLog("解析失败:%v", err)
  4808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4809. return
  4810. }
  4811. }
  4812. if miConfig.Code == "H15049901371" {
  4813. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4814. } else {
  4815. infocode = resThree.Infcode
  4816. }
  4817. }
  4818. if infocode != 0 {
  4819. adminUser := c.GetAdminUserInfo()
  4820. errlog := &models.HisOrderError{
  4821. UserOrgId: adminUser.CurrentOrgId,
  4822. Ctime: time.Now().Unix(),
  4823. Mtime: time.Now().Unix(),
  4824. ErrMsg: resThree.ErrMsg,
  4825. Status: 1,
  4826. PatientId: id,
  4827. RecordTime: recordDateTime,
  4828. Stage: 2,
  4829. }
  4830. service.CreateErrMsgLog(errlog)
  4831. c.ServeSuccessJSON(map[string]interface{}{
  4832. "failed_code": -10,
  4833. "msg": resThree.ErrMsg,
  4834. })
  4835. return
  4836. }
  4837. his.Number = resThree.Output.Data.MdtrtID
  4838. his.PsnNo = resThree.Output.Data.PsnNo
  4839. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4840. his.IdCardNo = patient.IdCardNo
  4841. his.PhoneNumber = patient.Phone
  4842. his.UserOrgId = adminInfo.CurrentOrgId
  4843. his.Insutype = insutype
  4844. his.Ctime = time.Now().Unix()
  4845. his.Mtime = time.Now().Unix()
  4846. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4847. his.Status = 1
  4848. service.UpdateHisPatientStatus(&his)
  4849. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4850. c.ServeSuccessJSON(map[string]interface{}{
  4851. "his_info": his,
  4852. })
  4853. } else {
  4854. adminUser := c.GetAdminUserInfo()
  4855. errlog := &models.HisOrderError{
  4856. UserOrgId: adminUser.CurrentOrgId,
  4857. Ctime: time.Now().Unix(),
  4858. Mtime: time.Now().Unix(),
  4859. ErrMsg: res.ErrMsg,
  4860. Status: 1,
  4861. PatientId: id,
  4862. RecordTime: recordDateTime,
  4863. Stage: 1,
  4864. }
  4865. service.CreateErrMsgLog(errlog)
  4866. c.ServeSuccessJSON(map[string]interface{}{
  4867. "failed_code": -10,
  4868. "msg": res.ErrMsg,
  4869. })
  4870. return
  4871. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4872. }
  4873. }
  4874. }
  4875. //上传明细----预结算----确认订单
  4876. func (c *HisApiController) GetUploadInfo() {
  4877. id, _ := c.GetInt64("id")
  4878. record_time := c.GetString("record_time")
  4879. his_patient_id, _ := c.GetInt64("his_patient_id")
  4880. order_id, _ := c.GetInt64("order_id")
  4881. pay_way, _ := c.GetInt64("pay_way")
  4882. pay_price, _ := c.GetFloat("pay_price")
  4883. pay_card_no := c.GetString("pay_card_no")
  4884. token := c.GetString("token")
  4885. discount_price, _ := c.GetFloat("discount_price")
  4886. preferential_price, _ := c.GetFloat("preferential_price")
  4887. reality_price, _ := c.GetFloat("reality_price")
  4888. found_price, _ := c.GetFloat("found_price")
  4889. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4890. private_price, _ := c.GetFloat("private_price")
  4891. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4892. admin_user_id, _ := c.GetInt64("admin_user_id")
  4893. fapiao_code := c.GetString("fapiao_code")
  4894. fapiao_number := c.GetString("fapiao_number")
  4895. diagnosis_id := c.GetString("diagnosis")
  4896. sick_type, _ := c.GetInt64("sick_type")
  4897. reg_type, _ := c.GetInt64("p_type")
  4898. begin_time := c.GetString("begin_time")
  4899. id_str := c.GetString("ids")
  4900. ids_arr := strings.Split(id_str, ",")
  4901. timeLayout := "2006-01-02"
  4902. loc, _ := time.LoadLocation("Local")
  4903. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4904. if err != nil {
  4905. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4906. return
  4907. }
  4908. recordDateTime := theTime.Unix()
  4909. adminUser := c.GetAdminUserInfo()
  4910. var tempOrder models.HisOrder
  4911. tempOrder, _ = service.GetHisOrderByID(order_id)
  4912. var prescriptions []*models.HisPrescription
  4913. var start_time int64
  4914. var end_time int64
  4915. //押金模块
  4916. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4917. tmp_decimal := c.GetString("tmp_decimal")
  4918. var decimal float64 //本次使用的押金
  4919. var errmsg error
  4920. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4921. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4922. return
  4923. }
  4924. if len(tmp_decimal) > 0 {
  4925. if tmp_decimal[0] == 45 {
  4926. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4927. return
  4928. }
  4929. }
  4930. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4931. fmt.Println(errs)
  4932. decimal = tt
  4933. //if adminUser.CurrentOrgId == 10106{
  4934. // if len(fapiao_code) == 0{
  4935. // fapiao_code = "144072080589"
  4936. // }
  4937. // if len(fapiao_number) == 0{
  4938. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4939. // if order.ID == 0{
  4940. // fapiao_number = "00001520"
  4941. // }else{
  4942. // //fapiao_code = "00001520"
  4943. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4944. // var zero string
  4945. // if fpNumber >= 1000{
  4946. // zero = "0000" + strconv.Itoa(fpNumber)
  4947. // }else if fpNumber >= 10000{
  4948. // zero = "000" + strconv.Itoa(fpNumber)
  4949. // } else if fpNumber >= 100000{
  4950. // zero = "00" + strconv.Itoa(fpNumber)
  4951. // } else if fpNumber >= 1000000{
  4952. // zero = "0" + strconv.Itoa(fpNumber)
  4953. // }else {
  4954. // zero = strconv.Itoa(fpNumber)
  4955. // }
  4956. // fapiao_number = zero
  4957. // }
  4958. // }
  4959. //}
  4960. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4961. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4962. var patientPrescription models.HisPrescriptionInfo
  4963. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4964. if patientPrescription.ID == 0 {
  4965. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4966. }
  4967. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4968. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4969. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4970. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4971. var config []*models.HisXtDiagnoseConfig
  4972. for _, item := range diagnosis_ids {
  4973. id, _ := strconv.ParseInt(item, 10, 64)
  4974. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4975. config = append(config, &diagnosisConfig)
  4976. }
  4977. sickConfig, _ := service.FindSickById(sick_type)
  4978. //if tempOrder.ID == 0 {
  4979. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4980. //}
  4981. if tempOrder.ID == 0 {
  4982. var result string
  4983. var requestLog string
  4984. var res2 ResultSix
  4985. var ressix10265 ResultSix10265
  4986. if miConfig.MdtrtareaAdmvs == "421300" {
  4987. data := make(map[string]interface{})
  4988. client := &http.Client{}
  4989. data["psn_no"] = his.PsnNo
  4990. data["mdtrt_id"] = his.Number
  4991. data["opter"] = roles.UserName
  4992. data["org_name"] = miConfig.OrgName
  4993. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4994. data["doctor_id"] = doctor_info.DoctorNumber
  4995. data["doctor_name"] = doctor_info.UserName
  4996. data["department"] = department.Name
  4997. data["fixmedins_code"] = miConfig.Code
  4998. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4999. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5000. data["secret_key"] = miConfig.SecretKey
  5001. data["sick_code"] = sickConfig.CountryCode
  5002. data["sick_name"] = sickConfig.ClassName
  5003. data["dept"] = strconv.FormatInt(department.ID, 10)
  5004. data["config"] = config
  5005. data["begin_time"] = begin_time
  5006. bytesData, _ := json.Marshal(data)
  5007. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5008. resp, _ := client.Do(req)
  5009. defer resp.Body.Close()
  5010. body, ioErr := ioutil.ReadAll(resp.Body)
  5011. if ioErr != nil {
  5012. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5013. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5014. return
  5015. }
  5016. var respJSON map[string]interface{}
  5017. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5018. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5020. return
  5021. }
  5022. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5023. userJSONBytes, _ := json.Marshal(respJSON)
  5024. fmt.Println("log")
  5025. fmt.Println(string(userJSONBytes))
  5026. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5027. utils.ErrorLog("解析失败:%v", err)
  5028. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5029. return
  5030. }
  5031. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5032. //江苏地区国家医保医疗类别
  5033. //职工透析:医疗类别选特殊情况门诊9933
  5034. //居民血透门慢: 医疗类别选门诊慢病1402
  5035. //var med_type string
  5036. //if his.Insutype == "310" {
  5037. // if reg_type == 14 {
  5038. // med_type = "9933"
  5039. // } else if reg_type == 11 {
  5040. // med_type = "11"
  5041. //
  5042. // }
  5043. //} else if his.Insutype == "390" {
  5044. // if reg_type == 14 {
  5045. // med_type = "1402"
  5046. // } else if reg_type == 11 {
  5047. // med_type = "11"
  5048. // }
  5049. //}
  5050. data := make(map[string]interface{})
  5051. client := &http.Client{}
  5052. data["psn_no"] = his.PsnNo
  5053. data["mdtrt_id"] = his.Number
  5054. data["doctor"] = roles.UserName
  5055. data["department"] = department.Name
  5056. data["org_name"] = miConfig.OrgName
  5057. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5058. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5059. data["fixmedins_code"] = miConfig.Code
  5060. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5061. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5062. data["secret_key"] = miConfig.SecretKey
  5063. data["sick_code"] = sickConfig.CountryCode
  5064. data["sick_name"] = sickConfig.ClassName
  5065. data["url"] = miConfig.Url
  5066. data["ak"] = miConfig.AccessKey
  5067. data["begin_time"] = begin_time
  5068. data["cainfo"] = miConfig.Cainfo
  5069. data["dept"] = strconv.FormatInt(department.ID, 10)
  5070. data["config"] = config
  5071. bytesData, _ := json.Marshal(data)
  5072. var req *http.Request
  5073. if miConfig.MdtrtareaAdmvs == "320921" {
  5074. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5075. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5076. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5077. } else {
  5078. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5079. }
  5080. resp, _ := client.Do(req)
  5081. defer resp.Body.Close()
  5082. body, ioErr := ioutil.ReadAll(resp.Body)
  5083. if ioErr != nil {
  5084. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5086. return
  5087. }
  5088. var respJSON map[string]interface{}
  5089. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5090. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5092. return
  5093. }
  5094. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5095. userJSONBytes, _ := json.Marshal(respJSON)
  5096. fmt.Println("log")
  5097. fmt.Println(string(userJSONBytes))
  5098. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5099. utils.ErrorLog("解析失败:%v", err)
  5100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5101. return
  5102. }
  5103. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5104. res2.Output = ressix10265.Output
  5105. res2.ErrMsg = ressix10265.ErrMsg
  5106. res2.Cainfo = ressix10265.Cainfo
  5107. res2.WarnMsg = ressix10265.WarnMsg
  5108. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5109. res2.Infcode = infocode
  5110. } else {
  5111. if miConfig.MdtrtareaAdmvs == "440781" { //
  5112. 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)
  5113. } else {
  5114. if miConfig.Code == "H15049901371" {
  5115. //赤峰地区国家医保医疗类别
  5116. //职工透析:医疗类别选特殊情况门诊990502
  5117. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5118. var med_type string
  5119. if his.Insutype == "390" {
  5120. if reg_type == 14 {
  5121. med_type = "9933"
  5122. } else if reg_type == 11 {
  5123. med_type = "11"
  5124. }
  5125. } else if his.Insutype == "310" {
  5126. if reg_type == 14 {
  5127. med_type = "990502"
  5128. } else if reg_type == 11 {
  5129. med_type = "11"
  5130. }
  5131. }
  5132. 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)
  5133. } else {
  5134. 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)
  5135. }
  5136. }
  5137. saveLog(result, requestLog, "2203", "上传就诊信息")
  5138. var respJSON2 map[string]interface{}
  5139. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5140. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5142. return
  5143. }
  5144. userJSONBytes2, _ := json.Marshal(respJSON2)
  5145. if miConfig.Code == "H15049901371" {
  5146. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5147. utils.ErrorLog("解析失败:%v", err)
  5148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5149. return
  5150. }
  5151. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5152. res2.Output = ressix10265.Output
  5153. res2.ErrMsg = ressix10265.ErrMsg
  5154. res2.Cainfo = ressix10265.Cainfo
  5155. res2.WarnMsg = ressix10265.WarnMsg
  5156. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5157. res2.Infcode = infocode
  5158. } else {
  5159. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5160. utils.ErrorLog("解析失败:%v", err)
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. }
  5165. }
  5166. if res2.Infcode != 0 {
  5167. adminUser := c.GetAdminUserInfo()
  5168. errlog := &models.HisOrderError{
  5169. UserOrgId: adminUser.CurrentOrgId,
  5170. Ctime: time.Now().Unix(),
  5171. Mtime: time.Now().Unix(),
  5172. ErrMsg: res2.ErrMsg,
  5173. Status: 1,
  5174. PatientId: id,
  5175. RecordTime: recordDateTime,
  5176. Stage: 3,
  5177. }
  5178. service.CreateErrMsgLog(errlog)
  5179. c.ServeSuccessJSON(map[string]interface{}{
  5180. "failed_code": -10,
  5181. "msg": res2.ErrMsg,
  5182. })
  5183. return
  5184. } else {
  5185. his.Diagnosis = diagnosis_id
  5186. his.SickType = sickConfig.ID
  5187. //var p_type int64
  5188. //if reg_type == 1111 || reg_type == 1112 {
  5189. // p_type = 11
  5190. //
  5191. //}
  5192. his.PType = fmt.Sprintf("%d", reg_type)
  5193. service.UpdateHisPatientThree(&his)
  5194. data := make(map[string]interface{})
  5195. if settle_accounts_type == 1 { //日结
  5196. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5197. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5198. } else {
  5199. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5200. }
  5201. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5202. data["pre"] = prescriptions
  5203. } else { //月结
  5204. start_time_str := c.GetString("start_time")
  5205. end_time_str := c.GetString("end_time")
  5206. timeLayout := "2006-01-02"
  5207. loc, _ := time.LoadLocation("Local")
  5208. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5209. if err != nil {
  5210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5211. return
  5212. }
  5213. recordStartTime := theStartTime.Unix()
  5214. start_time = recordStartTime
  5215. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5216. if err != nil {
  5217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5218. return
  5219. }
  5220. recordEndTime := theEndTime.Unix()
  5221. end_time = recordEndTime
  5222. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5223. data["pre"] = prescriptions
  5224. }
  5225. timestamp := time.Now().Unix()
  5226. tempTime := time.Unix(timestamp, 0)
  5227. timeFormat := tempTime.Format("20060102150405")
  5228. chrgBchno := rand.Intn(100000) + 10000
  5229. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5230. strconv.FormatInt(his.PatientId, 10)
  5231. client := &http.Client{}
  5232. data["psn_no"] = his.PsnNo
  5233. data["mdtrt_id"] = his.Number
  5234. data["chrg_bchno"] = chrg_bchno
  5235. data["org_name"] = miConfig.OrgName
  5236. data["doctor"] = doctor_info.UserName
  5237. data["doctor_id"] = doctor_info.DoctorNumber
  5238. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5239. data["fixmedins_code"] = miConfig.Code
  5240. data["opter"] = roles.UserName
  5241. data["dept_code"] = department.Number
  5242. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5243. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5244. data["secret_key"] = miConfig.SecretKey
  5245. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5246. data["url"] = miConfig.Url
  5247. data["ak"] = miConfig.AccessKey
  5248. data["new_doctor_name"] = patientPrescription.Doctor
  5249. data["diag_code"] = sickConfig.CountryCode
  5250. data["cainfo"] = miConfig.Cainfo
  5251. var ids []int64
  5252. for _, item := range prescriptions {
  5253. ids = append(ids, item.ID)
  5254. }
  5255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5256. if config.IsOpen == 1 { //对接了医保,走医保流程
  5257. var res ResultFour
  5258. var resFour10265 ResultFour10265
  5259. if miConfig.MdtrtareaAdmvs == "421300" {
  5260. bytesData, _ := json.Marshal(data)
  5261. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5262. resp, _ := client.Do(req)
  5263. defer resp.Body.Close()
  5264. body, ioErr := ioutil.ReadAll(resp.Body)
  5265. if ioErr != nil {
  5266. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5267. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5268. return
  5269. }
  5270. var respJSON map[string]interface{}
  5271. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5272. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5274. return
  5275. }
  5276. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5277. userJSONBytes, _ := json.Marshal(respJSON)
  5278. fmt.Println("log")
  5279. fmt.Println(string(userJSONBytes))
  5280. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5281. utils.ErrorLog("解析失败:%v", err)
  5282. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5283. return
  5284. }
  5285. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5286. bytesData, _ := json.Marshal(data)
  5287. var req *http.Request
  5288. if miConfig.MdtrtareaAdmvs == "320921" {
  5289. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5290. } else {
  5291. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5292. }
  5293. resp, _ := client.Do(req)
  5294. defer resp.Body.Close()
  5295. body, ioErr := ioutil.ReadAll(resp.Body)
  5296. if ioErr != nil {
  5297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5299. return
  5300. }
  5301. var respJSON map[string]interface{}
  5302. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5305. return
  5306. }
  5307. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5308. userJSONBytes, _ := json.Marshal(respJSON)
  5309. fmt.Println("log")
  5310. fmt.Println(string(userJSONBytes))
  5311. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5312. utils.ErrorLog("解析失败:%v", err)
  5313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5314. return
  5315. }
  5316. res.InfRefmsgid = resFour10265.InfRefmsgid
  5317. res.Output = resFour10265.Output
  5318. res.ErrMsg = resFour10265.ErrMsg
  5319. res.Cainfo = resFour10265.Cainfo
  5320. res.WarnMsg = resFour10265.WarnMsg
  5321. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5322. res.Infcode = infocode
  5323. } else {
  5324. if miConfig.Code == "H15049901371" {
  5325. 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)
  5326. var dat map[string]interface{}
  5327. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5328. fmt.Println(dat)
  5329. } else {
  5330. fmt.Println(err)
  5331. }
  5332. saveLog(result, request_log, "2204", "上传费用明细")
  5333. userJSONBytes, _ := json.Marshal(dat)
  5334. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5335. utils.ErrorLog("解析失败:%v", err)
  5336. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5337. return
  5338. }
  5339. res.InfRefmsgid = resFour10265.InfRefmsgid
  5340. res.Output = resFour10265.Output
  5341. res.ErrMsg = resFour10265.ErrMsg
  5342. res.Cainfo = resFour10265.Cainfo
  5343. res.WarnMsg = resFour10265.WarnMsg
  5344. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5345. res.Infcode = infocode
  5346. } else {
  5347. 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)
  5348. var dat map[string]interface{}
  5349. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5350. fmt.Println(dat)
  5351. } else {
  5352. fmt.Println(err)
  5353. }
  5354. saveLog(result, request_log, "2204", "上传费用明细")
  5355. userJSONBytes, _ := json.Marshal(dat)
  5356. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5357. utils.ErrorLog("解析失败:%v", err)
  5358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5359. return
  5360. }
  5361. }
  5362. }
  5363. if res.Infcode == 0 {
  5364. order := &models.HisOrder{
  5365. UserOrgId: adminUser.CurrentOrgId,
  5366. HisPatientId: his.ID,
  5367. PatientId: his.PatientId,
  5368. SettleAccountsDate: recordDateTime,
  5369. MdtrtId: his.Number,
  5370. PsnNo: his.PsnNo,
  5371. MedType: strconv.FormatInt(reg_type, 10),
  5372. Ctime: time.Now().Unix(),
  5373. Mtime: time.Now().Unix(),
  5374. Status: 1,
  5375. Number: chrg_bchno,
  5376. Infcode: res.Infcode,
  5377. WarnMsg: res.WarnMsg,
  5378. Cainfo: res.Cainfo,
  5379. ErrMsg: res.ErrMsg,
  5380. RespondTime: res.RefmsgTime,
  5381. InfRefmsgid: res.InfRefmsgid,
  5382. OrderStatus: 1,
  5383. PayWay: pay_way,
  5384. PayPrice: pay_price,
  5385. PayCardNo: pay_card_no,
  5386. DiscountPrice: discount_price,
  5387. PreferentialPrice: preferential_price,
  5388. RealityPrice: reality_price,
  5389. FoundPrice: found_price,
  5390. MedicalInsurancePrice: medical_insurance_price,
  5391. PrivatePrice: private_price,
  5392. IsMedicineInsurance: 1,
  5393. SettleType: settle_accounts_type,
  5394. SettleStartTime: start_time,
  5395. SettleEndTime: end_time,
  5396. Creator: roles.AdminUserId,
  5397. Modify: roles.AdminUserId,
  5398. FaPiaoNumber: fapiao_number,
  5399. FaPiaoCode: fapiao_code,
  5400. PType: 2,
  5401. Diagnosis: diagnosis_id,
  5402. }
  5403. err = service.CreateOrder(order)
  5404. if err != nil {
  5405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5406. return
  5407. }
  5408. for _, item := range res.Output.Result {
  5409. temp := strings.Split(item.FeedetlSn, "-")
  5410. var advice_id int64 = 0
  5411. var project_id int64 = 0
  5412. var types int64 = 0
  5413. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5414. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5415. if temp[1] == "1" {
  5416. advice_id = id
  5417. project_id = 0
  5418. } else if temp[1] == "2" {
  5419. advice_id = 0
  5420. project_id = id
  5421. }
  5422. info := &models.HisOrderInfo{
  5423. OrderNumber: order.Number,
  5424. FeedetlSn: item.FeedetlSn,
  5425. UploadDate: time.Now().Unix(),
  5426. AdviceId: advice_id,
  5427. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5428. Cnt: item.Cnt,
  5429. Pric: float64(item.Pric),
  5430. PatientId: his.PatientId,
  5431. PricUplmtAmt: item.PricUplmtAmt,
  5432. SelfpayProp: item.SelfpayProp,
  5433. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5434. OverlmtAmt: item.OverlmtAmt,
  5435. PreselfpayAmt: item.PreselfpayAmt,
  5436. BasMednFlag: item.BasMednFlag,
  5437. MedChrgitmType: item.MedChrgitmType,
  5438. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5439. Status: 1,
  5440. Memo: item.Memo,
  5441. Mtime: time.Now().Unix(),
  5442. InscpScpAmt: item.InscpScpAmt,
  5443. DrtReimFlag: item.DrtReimFlag,
  5444. Ctime: time.Now().Unix(),
  5445. ListSpItemFlag: item.ListSpItemFlag,
  5446. ChldMedcFlag: item.ChldMedcFlag,
  5447. LmtUsedFlag: item.LmtUsedFlag,
  5448. ChrgitmLv: item.ChrgitmLv,
  5449. UserOrgId: adminUser.CurrentOrgId,
  5450. HisPatientId: his.ID,
  5451. OrderId: order.ID,
  5452. ProjectId: project_id,
  5453. Type: types,
  5454. }
  5455. service.CreateOrderInfo(info)
  5456. }
  5457. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5458. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5459. var total float64
  5460. for _, item := range prescriptions {
  5461. if item.Type == 1 { //药品
  5462. for _, subItem := range item.HisDoctorAdviceInfo {
  5463. total = total + (subItem.Price * subItem.PrescribingNumber)
  5464. }
  5465. }
  5466. if item.Type == 2 { //项目
  5467. for _, subItem := range item.HisPrescriptionProject {
  5468. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5469. total = total + (subItem.Price * cnt)
  5470. }
  5471. }
  5472. }
  5473. for _, item := range prescriptions {
  5474. for _, subItem := range item.HisAdditionalCharge {
  5475. total = total + (subItem.Price * float64(subItem.Count))
  5476. }
  5477. }
  5478. var allTotal string
  5479. if adminUser.CurrentOrgId == 9919 {
  5480. allTotal = fmt.Sprintf("%.4f", total)
  5481. } else {
  5482. allTotal = fmt.Sprintf("%.4f", total)
  5483. }
  5484. if res.Infcode == 0 {
  5485. var rf []*ResultFive
  5486. json.Unmarshal([]byte(his.Iinfo), &rf)
  5487. chrg_bchno := chrg_bchno
  5488. cert_no := his.Certno
  5489. var insutypes []string
  5490. var insutype string
  5491. var is390 int = 0
  5492. var is310 int = 0
  5493. for _, item := range rf {
  5494. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5495. insutypes = append(insutypes, item.Insutype)
  5496. }
  5497. }
  5498. if len(insutypes) == 1 {
  5499. insutype = insutypes[0]
  5500. } else {
  5501. for _, i := range insutypes {
  5502. if i == "390" {
  5503. is390 = 1
  5504. }
  5505. if i == "310" {
  5506. is310 = 1
  5507. }
  5508. }
  5509. }
  5510. if is390 == 1 {
  5511. insutype = "390"
  5512. }
  5513. if is310 == 1 {
  5514. insutype = "310"
  5515. }
  5516. if len(insutypes) == 0 {
  5517. insutype = "310"
  5518. }
  5519. if len(insutypes) == 2 {
  5520. insutype = strconv.FormatInt(his.SocialType, 10)
  5521. }
  5522. insutype = strconv.FormatInt(his.SocialType, 10)
  5523. //insutype = "390"
  5524. if his.IdCardType == 1 {
  5525. // cert_no = his.MedicalInsuranceNumber
  5526. cert_no = his.Certno
  5527. } else {
  5528. cert_no = his.Certno
  5529. }
  5530. var res ResultSeven
  5531. var resSeven10265 ResultSeven10265
  5532. var src_resquest string
  5533. var result2 string
  5534. var acct_used_flag string
  5535. fmt.Println("pay_way")
  5536. fmt.Println(pay_way)
  5537. fmt.Println("pay_way")
  5538. if pay_way == 4 {
  5539. acct_used_flag = "1"
  5540. } else {
  5541. acct_used_flag = "0"
  5542. }
  5543. if miConfig.MdtrtareaAdmvs == "421300" {
  5544. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5545. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5546. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5547. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5548. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5549. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5550. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5551. resp, requestErr := http.Get(api)
  5552. if requestErr != nil {
  5553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5554. return
  5555. }
  5556. body, ioErr := ioutil.ReadAll(resp.Body)
  5557. if ioErr != nil {
  5558. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5559. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5560. return
  5561. }
  5562. var respJSON map[string]interface{}
  5563. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5564. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5565. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5566. return
  5567. }
  5568. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5569. result, _ := json.Marshal(respJSON)
  5570. if miConfig.Code == "H15049901371" {
  5571. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5572. utils.ErrorLog("解析失败:%v", err)
  5573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5574. return
  5575. }
  5576. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5577. res.Output = resSeven10265.Output
  5578. res.ErrMsg = resSeven10265.ErrMsg
  5579. res.Cainfo = resSeven10265.Cainfo
  5580. res.WarnMsg = resSeven10265.WarnMsg
  5581. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5582. res.Infcode = infocode
  5583. } else {
  5584. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5585. utils.ErrorLog("解析失败:%v", err)
  5586. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5587. return
  5588. }
  5589. }
  5590. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5591. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5592. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5593. bas := strings.Split(psn_info.CardInfo, "|")
  5594. if his.IdCardType == 1 {
  5595. cert_no = bas[2]
  5596. } else if his.IdCardType == 3 {
  5597. cert_no = his.Certno
  5598. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5599. } else if his.IdCardType == 4 {
  5600. cert_no = his.Certno
  5601. psn_info.VerifyNumber = token
  5602. }
  5603. var api string
  5604. if miConfig.MdtrtareaAdmvs == "320921" {
  5605. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5606. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5607. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5608. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5609. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5610. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5611. "&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
  5612. } else {
  5613. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5614. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5615. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5616. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5617. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5618. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5619. "&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
  5620. }
  5621. resp, requestErr := http.Get(api)
  5622. if requestErr != nil {
  5623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5624. return
  5625. }
  5626. body, ioErr := ioutil.ReadAll(resp.Body)
  5627. if ioErr != nil {
  5628. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5629. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5630. return
  5631. }
  5632. var respJSON map[string]interface{}
  5633. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5634. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5636. return
  5637. }
  5638. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5639. result, _ := json.Marshal(respJSON)
  5640. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5641. utils.ErrorLog("解析失败:%v", err)
  5642. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5643. return
  5644. }
  5645. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5646. res.Output = resSeven10265.Output
  5647. res.ErrMsg = resSeven10265.ErrMsg
  5648. res.Cainfo = resSeven10265.Cainfo
  5649. res.WarnMsg = resSeven10265.WarnMsg
  5650. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5651. res.Infcode = infocode
  5652. } else {
  5653. if miConfig.Code == "H15049901371" {
  5654. //赤峰地区国家医保医疗类别
  5655. //职工透析:医疗类别选特殊情况门诊990502
  5656. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5657. var med_type string
  5658. if his.Insutype == "390" {
  5659. if reg_type == 14 {
  5660. med_type = "9933"
  5661. } else if reg_type == 11 {
  5662. med_type = "11"
  5663. }
  5664. } else if his.Insutype == "310" {
  5665. if reg_type == 14 {
  5666. med_type = "990502"
  5667. } else if reg_type == 11 {
  5668. med_type = "11"
  5669. }
  5670. }
  5671. 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)
  5672. } else {
  5673. 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)
  5674. }
  5675. //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)
  5676. var dat map[string]interface{}
  5677. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5678. fmt.Println(dat)
  5679. } else {
  5680. fmt.Println(err)
  5681. }
  5682. saveLog(result2, src_resquest, "2207", "结算")
  5683. userJSONBytes, _ := json.Marshal(dat)
  5684. if miConfig.Code == "H15049901371" {
  5685. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5686. utils.ErrorLog("解析失败:%v", err)
  5687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5688. return
  5689. }
  5690. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5691. res.Output = resSeven10265.Output
  5692. res.ErrMsg = resSeven10265.ErrMsg
  5693. res.Cainfo = resSeven10265.Cainfo
  5694. res.WarnMsg = resSeven10265.WarnMsg
  5695. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5696. res.Infcode = infocode
  5697. } else {
  5698. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5699. utils.ErrorLog("解析失败:%v", err)
  5700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5701. return
  5702. }
  5703. }
  5704. }
  5705. if res.Infcode != 0 {
  5706. errlog := &models.HisOrderError{
  5707. UserOrgId: adminUser.CurrentOrgId,
  5708. Ctime: time.Now().Unix(),
  5709. Mtime: time.Now().Unix(),
  5710. Number: chrg_bchno,
  5711. ErrMsg: res.ErrMsg,
  5712. Status: 1,
  5713. PatientId: id,
  5714. RecordTime: recordDateTime,
  5715. Stage: 6,
  5716. }
  5717. service.CreateErrMsgLog(errlog)
  5718. c.ServeSuccessJSON(map[string]interface{}{
  5719. "failed_code": -10,
  5720. "msg": res.ErrMsg,
  5721. })
  5722. return
  5723. } else {
  5724. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5725. order.OrderStatus = 2
  5726. order.Status = 1
  5727. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5728. order.SetlId = res.Output.Setlinfo.SetlID
  5729. order.PsnNo = res.Output.Setlinfo.PsnNo
  5730. order.PsnName = res.Output.Setlinfo.PsnName
  5731. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5732. order.Certno = res.Output.Setlinfo.Certno
  5733. order.Gend = res.Output.Setlinfo.Gend
  5734. order.Naty = res.Output.Setlinfo.Naty
  5735. order.Age = res.Output.Setlinfo.Age
  5736. order.Insutype = res.Output.Setlinfo.Insutype
  5737. order.PsnType = res.Output.Setlinfo.PsnType
  5738. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5739. order.SetlTime = res.Output.Setlinfo.SetlTime
  5740. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5741. if res.Output.Setlinfo.MedType == "140101" {
  5742. order.MedType = "14"
  5743. } else {
  5744. order.MedType = res.Output.Setlinfo.MedType
  5745. }
  5746. if reg_type == 1112 {
  5747. order.MedType = "1112"
  5748. }
  5749. if reg_type == 1111 {
  5750. order.MedType = "1111"
  5751. }
  5752. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5753. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5754. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5755. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5756. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5757. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5758. order.HifpPay = res.Output.Setlinfo.HifpPay
  5759. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5760. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5761. order.HifesPay = res.Output.Setlinfo.HifesPay
  5762. order.HifobPay = res.Output.Setlinfo.HifobPay
  5763. order.MafPay = res.Output.Setlinfo.MafPay
  5764. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5765. order.OthPay = res.Output.Setlinfo.OthPay
  5766. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5767. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5768. order.AcctPay = res.Output.Setlinfo.AcctPay
  5769. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5770. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5771. order.Balc = res.Output.Setlinfo.Balc
  5772. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5773. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5774. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5775. order.ClrType = res.Output.Setlinfo.ClrType
  5776. order.ClrWay = res.Output.Setlinfo.ClrWay
  5777. order.Creator = order.Creator
  5778. order.Modify = roles.AdminUserId
  5779. order.RequestLog = src_resquest
  5780. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5781. detailStr := string(setlDetail)
  5782. order.SetlDetail = detailStr
  5783. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5784. err = service.UpDateOrder(order)
  5785. if err == nil {
  5786. //判断是否使用了押金
  5787. if dec_way == "true" {
  5788. tmpstring := strconv.FormatInt(order.ID, 10)
  5789. order.Decimal = decimal
  5790. service.UpDateOrder(order)
  5791. //扣押金
  5792. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5793. if errmsg != nil {
  5794. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5795. return
  5796. }
  5797. }
  5798. c.ServeSuccessJSON(map[string]interface{}{
  5799. "msg": "结算成功",
  5800. })
  5801. } else {
  5802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5803. return
  5804. }
  5805. }
  5806. } else {
  5807. adminUser := c.GetAdminUserInfo()
  5808. errlog := &models.HisOrderError{
  5809. UserOrgId: adminUser.CurrentOrgId,
  5810. Ctime: time.Now().Unix(),
  5811. Mtime: time.Now().Unix(),
  5812. ErrMsg: res.ErrMsg,
  5813. Status: 1,
  5814. PatientId: id,
  5815. RecordTime: recordDateTime,
  5816. Stage: 4,
  5817. }
  5818. service.CreateErrMsgLog(errlog)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5820. return
  5821. }
  5822. } else {
  5823. adminUser := c.GetAdminUserInfo()
  5824. errlog := &models.HisOrderError{
  5825. UserOrgId: adminUser.CurrentOrgId,
  5826. Ctime: time.Now().Unix(),
  5827. Mtime: time.Now().Unix(),
  5828. ErrMsg: res.ErrMsg,
  5829. Status: 1,
  5830. PatientId: id,
  5831. RecordTime: recordDateTime,
  5832. Stage: 4,
  5833. }
  5834. service.CreateErrMsgLog(errlog)
  5835. c.ServeSuccessJSON(map[string]interface{}{
  5836. "failed_code": -10,
  5837. "msg": res.ErrMsg,
  5838. })
  5839. return
  5840. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5841. //return
  5842. }
  5843. }
  5844. }
  5845. } else if tempOrder.ID > 0 {
  5846. if tempOrder.IsPre == 1 {
  5847. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5848. var rf []*ResultFive
  5849. json.Unmarshal([]byte(his.Iinfo), &rf)
  5850. chrg_bchno := tempOrder.Number
  5851. cert_no := his.Certno
  5852. var insutypes []string
  5853. var insutype string
  5854. var is390 int = 0
  5855. var is310 int = 0
  5856. for _, item := range rf {
  5857. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5858. insutypes = append(insutypes, item.Insutype)
  5859. }
  5860. }
  5861. if len(insutypes) == 1 {
  5862. insutype = insutypes[0]
  5863. } else {
  5864. for _, i := range insutypes {
  5865. if i == "390" {
  5866. is390 = 1
  5867. }
  5868. if i == "310" {
  5869. is310 = 1
  5870. }
  5871. }
  5872. }
  5873. if is390 == 1 {
  5874. insutype = "390"
  5875. }
  5876. if is310 == 1 {
  5877. insutype = "310"
  5878. }
  5879. if len(insutypes) == 0 {
  5880. insutype = "310"
  5881. }
  5882. if len(insutypes) == 2 {
  5883. insutype = strconv.FormatInt(his.SocialType, 64)
  5884. }
  5885. //insutype = "390"
  5886. if his.IdCardType == 1 {
  5887. // cert_no = his.MedicalInsuranceNumber
  5888. cert_no = his.Certno
  5889. } else {
  5890. cert_no = his.Certno
  5891. }
  5892. var res ResultSeven
  5893. var resSeven10265 ResultSeven10265
  5894. var src_resquest string
  5895. var result2 string
  5896. var acct_used_flag string
  5897. fmt.Println("pay_way")
  5898. fmt.Println(pay_way)
  5899. fmt.Println("pay_way")
  5900. if pay_way == 4 {
  5901. acct_used_flag = "1"
  5902. } else {
  5903. acct_used_flag = "0"
  5904. }
  5905. if miConfig.MdtrtareaAdmvs == "421300" {
  5906. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5907. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5908. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5909. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5910. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5911. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5912. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5913. resp, requestErr := http.Get(api)
  5914. if requestErr != nil {
  5915. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5916. return
  5917. }
  5918. body, ioErr := ioutil.ReadAll(resp.Body)
  5919. if ioErr != nil {
  5920. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5922. return
  5923. }
  5924. var respJSON map[string]interface{}
  5925. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5926. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5928. return
  5929. }
  5930. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5931. result, _ := json.Marshal(respJSON)
  5932. fmt.Println("log")
  5933. fmt.Println(string(result))
  5934. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5935. utils.ErrorLog("解析失败:%v", err)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5937. return
  5938. }
  5939. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5940. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5941. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5942. //psn_info, _ := service.GetPsnByPatientId(id)
  5943. bas := strings.Split(psn_info.CardInfo, "|")
  5944. if his.IdCardType == 1 {
  5945. cert_no = bas[2]
  5946. } else {
  5947. cert_no = bas[1]
  5948. }
  5949. //江苏地区国家医保医疗类别
  5950. //职工透析:医疗类别选特殊情况门诊9933
  5951. //居民血透门慢: 医疗类别选门诊慢病1402
  5952. //var med_type string
  5953. //if his.Insutype == "310" {
  5954. // if reg_type == 14 {
  5955. // med_type = "9933"
  5956. // } else if reg_type == 11 {
  5957. // med_type = "11"
  5958. //
  5959. // }
  5960. //} else if his.Insutype == "390" {
  5961. // if reg_type == 14 {
  5962. // med_type = "1402"
  5963. // } else if reg_type == 11 {
  5964. // med_type = "11"
  5965. // }
  5966. //}
  5967. var api string
  5968. if miConfig.MdtrtareaAdmvs == "320921" {
  5969. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5970. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5971. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5972. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5973. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5974. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5975. "&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
  5976. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5977. } else {
  5978. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5979. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5980. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5981. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5982. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5983. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5984. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5985. "&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
  5986. }
  5987. resp, requestErr := http.Get(api)
  5988. if requestErr != nil {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5990. return
  5991. }
  5992. body, ioErr := ioutil.ReadAll(resp.Body)
  5993. if ioErr != nil {
  5994. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5996. return
  5997. }
  5998. var respJSON map[string]interface{}
  5999. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6000. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6001. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6002. return
  6003. }
  6004. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6005. result, _ := json.Marshal(respJSON)
  6006. fmt.Println("log")
  6007. fmt.Println(string(result))
  6008. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6009. utils.ErrorLog("解析失败:%v", err)
  6010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6011. return
  6012. }
  6013. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6014. res.Output = resSeven10265.Output
  6015. res.ErrMsg = resSeven10265.ErrMsg
  6016. res.Cainfo = resSeven10265.Cainfo
  6017. res.WarnMsg = resSeven10265.WarnMsg
  6018. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6019. res.Infcode = infocode
  6020. } else {
  6021. var src_resquest string
  6022. if miConfig.Code == "H15049901371" {
  6023. //赤峰地区国家医保医疗类别
  6024. //职工透析:医疗类别选特殊情况门诊990502
  6025. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6026. var med_type string
  6027. if his.Insutype == "390" {
  6028. if reg_type == 14 {
  6029. med_type = "9933"
  6030. } else if reg_type == 11 {
  6031. med_type = "11"
  6032. }
  6033. } else if his.Insutype == "310" {
  6034. if reg_type == 14 {
  6035. med_type = "990502"
  6036. } else if reg_type == 11 {
  6037. med_type = "11"
  6038. }
  6039. }
  6040. 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)
  6041. } else {
  6042. 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)
  6043. }
  6044. var dat map[string]interface{}
  6045. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6046. fmt.Println(dat)
  6047. } else {
  6048. fmt.Println(err)
  6049. }
  6050. saveLog(result2, src_resquest, "2207", "结算")
  6051. userJSONBytes, _ := json.Marshal(dat)
  6052. if miConfig.Code == "H15049901371" {
  6053. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6054. utils.ErrorLog("解析失败:%v", err)
  6055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6056. return
  6057. }
  6058. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6059. res.Output = resSeven10265.Output
  6060. res.ErrMsg = resSeven10265.ErrMsg
  6061. res.Cainfo = resSeven10265.Cainfo
  6062. res.WarnMsg = resSeven10265.WarnMsg
  6063. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6064. res.Infcode = infocode
  6065. } else {
  6066. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6067. utils.ErrorLog("解析失败:%v", err)
  6068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6069. return
  6070. }
  6071. }
  6072. }
  6073. if res.Infcode != 0 {
  6074. errlog := &models.HisOrderError{
  6075. UserOrgId: adminUser.CurrentOrgId,
  6076. Ctime: time.Now().Unix(),
  6077. Mtime: time.Now().Unix(),
  6078. Number: chrg_bchno,
  6079. ErrMsg: res.ErrMsg,
  6080. Status: 1,
  6081. PatientId: id,
  6082. RecordTime: recordDateTime,
  6083. Stage: 6,
  6084. }
  6085. service.CreateErrMsgLog(errlog)
  6086. c.ServeSuccessJSON(map[string]interface{}{
  6087. "failed_code": -10,
  6088. "msg": res.ErrMsg,
  6089. })
  6090. return
  6091. } else {
  6092. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6093. order.OrderStatus = 2
  6094. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6095. order.SetlId = res.Output.Setlinfo.SetlID
  6096. order.PsnNo = res.Output.Setlinfo.PsnNo
  6097. order.PsnName = res.Output.Setlinfo.PsnName
  6098. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6099. order.Certno = res.Output.Setlinfo.Certno
  6100. order.Gend = res.Output.Setlinfo.Gend
  6101. order.Naty = res.Output.Setlinfo.Naty
  6102. order.Age = res.Output.Setlinfo.Age
  6103. order.Insutype = res.Output.Setlinfo.Insutype
  6104. order.PsnType = res.Output.Setlinfo.PsnType
  6105. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6106. order.SetlTime = res.Output.Setlinfo.SetlTime
  6107. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6108. //order.MedType = res.Output.Setlinfo.MedType
  6109. if reg_type == 1112 {
  6110. order.MedType = "1112"
  6111. }
  6112. if reg_type == 1111 {
  6113. order.MedType = "1111"
  6114. }
  6115. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6116. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6117. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6118. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6119. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6120. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6121. order.HifpPay = res.Output.Setlinfo.HifpPay
  6122. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6123. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6124. order.HifesPay = res.Output.Setlinfo.HifesPay
  6125. order.HifobPay = res.Output.Setlinfo.HifobPay
  6126. order.MafPay = res.Output.Setlinfo.MafPay
  6127. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6128. order.OthPay = res.Output.Setlinfo.OthPay
  6129. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6130. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6131. order.AcctPay = res.Output.Setlinfo.AcctPay
  6132. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6133. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6134. order.Balc = res.Output.Setlinfo.Balc
  6135. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6136. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6137. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6138. order.ClrWay = res.Output.Setlinfo.ClrWay
  6139. order.Creator = order.Creator
  6140. order.Modify = roles.AdminUserId
  6141. order.RequestLog = src_resquest
  6142. order.Diagnosis = diagnosis_id
  6143. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6144. detailStr := string(setlDetail)
  6145. order.SetlDetail = detailStr
  6146. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6147. err = service.UpDateOrder(order)
  6148. if err == nil {
  6149. //判断是否使用了押金
  6150. if dec_way == "true" {
  6151. tmpstring := strconv.FormatInt(order.ID, 10)
  6152. //扣押金
  6153. order.Decimal = decimal
  6154. service.UpDateOrder(order)
  6155. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6156. if errmsg != nil {
  6157. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6158. return
  6159. }
  6160. }
  6161. c.ServeSuccessJSON(map[string]interface{}{
  6162. "msg": "结算成功",
  6163. })
  6164. } else {
  6165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6166. return
  6167. }
  6168. }
  6169. }
  6170. }
  6171. }
  6172. //func (c *HisApiController) GetPreUploadInfo() {
  6173. // id, _ := c.GetInt64("id")
  6174. // record_time := c.GetString("record_time")
  6175. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6176. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6177. //
  6178. // timeLayout := "2006-01-02"
  6179. // loc, _ := time.LoadLocation("Local")
  6180. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6181. // if err != nil {
  6182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6183. // return
  6184. // }
  6185. // recordDateTime := theTime.Unix()
  6186. // adminUser := c.GetAdminUserInfo()
  6187. //
  6188. // var prescriptions []*models.HisPrescription
  6189. //
  6190. // var start_time int64
  6191. // var end_time int64
  6192. //
  6193. // data := make(map[string]interface{})
  6194. // if settle_accounts_type == 1 { //日结
  6195. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6196. // data["pre"] = prescriptions
  6197. //
  6198. // } else { //月结
  6199. // start_time_str := c.GetString("start_time")
  6200. // end_time_str := c.GetString("end_time")
  6201. // timeLayout := "2006-01-02"
  6202. // loc, _ := time.LoadLocation("Local")
  6203. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6204. // if err != nil {
  6205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6206. // return
  6207. // }
  6208. // recordStartTime := theStartTime.Unix()
  6209. // start_time = recordStartTime
  6210. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6211. // if err != nil {
  6212. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6213. // return
  6214. // }
  6215. // recordEndTime := theEndTime.Unix()
  6216. // end_time = recordEndTime
  6217. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6218. // data["pre"] = prescriptions
  6219. //
  6220. // }
  6221. //
  6222. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6223. //
  6224. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6225. // timestamp := time.Now().Unix()
  6226. // tempTime := time.Unix(timestamp, 0)
  6227. // timeFormat := tempTime.Format("20060102150405")
  6228. // chrgBchno := rand.Intn(100000) + 10000
  6229. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6230. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6231. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6232. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6233. // strconv.FormatInt(his.PatientId, 10)
  6234. // client := &http.Client{}
  6235. // data["psn_no"] = his.PsnNo
  6236. // data["mdtrt_id"] = his.Number
  6237. // data["chrg_bchno"] = chrg_bchno
  6238. // data["org_name"] = miConfig.OrgName
  6239. // data["doctor"] = roles.UserName
  6240. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6241. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6242. // data["fixmedins_code"] = miConfig.Code
  6243. // data["dept_code"] = department.Number
  6244. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6245. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6246. // data["secret_key"] = miConfig.SecretKey
  6247. // var ids []int64
  6248. //
  6249. // for _, item := range prescriptions {
  6250. // ids = append(ids, item.ID)
  6251. // }
  6252. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6253. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6254. // bytesData, _ := json.Marshal(data)
  6255. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6256. // resp, _ := client.Do(req)
  6257. // defer resp.Body.Close()
  6258. // body, ioErr := ioutil.ReadAll(resp.Body)
  6259. // if ioErr != nil {
  6260. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6262. // return
  6263. // }
  6264. // var respJSON map[string]interface{}
  6265. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6266. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6267. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6268. // return
  6269. // }
  6270. //
  6271. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6272. // userJSONBytes, _ := json.Marshal(respJSON)
  6273. // var res ResultFour
  6274. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6275. // utils.ErrorLog("解析失败:%v", err)
  6276. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6277. // return
  6278. // }
  6279. //
  6280. // if res.Infcode == 0 {
  6281. // order := &models.HisOrder{
  6282. // UserOrgId: adminUser.CurrentOrgId,
  6283. // HisPatientId: his.ID,
  6284. // PatientId: his.PatientId,
  6285. // SettleAccountsDate: recordDateTime,
  6286. // Ctime: time.Now().Unix(),
  6287. // Mtime: time.Now().Unix(),
  6288. // Status: 1,
  6289. // Number: chrg_bchno,
  6290. // Infcode: res.Infcode,
  6291. // WarnMsg: res.WarnMsg,
  6292. // Cainfo: res.Cainfo,
  6293. // ErrMsg: res.ErrMsg,
  6294. // RespondTime: res.RefmsgTime,
  6295. // InfRefmsgid: res.InfRefmsgid,
  6296. // OrderStatus: 1,
  6297. // IsMedicineInsurance: 1,
  6298. // SettleType: settle_accounts_type,
  6299. // SettleStartTime: start_time,
  6300. // SettleEndTime: end_time,
  6301. // Creator: roles.ID,
  6302. // Modify: roles.ID,
  6303. // PType: 2,
  6304. // }
  6305. // err = service.CreateOrder(order)
  6306. // if err != nil {
  6307. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6308. // return
  6309. // }
  6310. //
  6311. // for _, item := range res.Output.Result {
  6312. // temp := strings.Split(item.FeedetlSn, "-")
  6313. // var advice_id int64 = 0
  6314. // var project_id int64 = 0
  6315. // var types int64 = 0
  6316. //
  6317. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6318. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6319. //
  6320. // if temp[1] == "1" {
  6321. // advice_id = id
  6322. // project_id = 0
  6323. // } else if temp[1] == "2" {
  6324. // advice_id = 0
  6325. // project_id = id
  6326. // }
  6327. //
  6328. // info := &models.HisOrderInfo{
  6329. // OrderNumber: order.Number,
  6330. // FeedetlSn: item.FeedetlSn,
  6331. // UploadDate: time.Now().Unix(),
  6332. // AdviceId: advice_id,
  6333. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6334. // Cnt: item.Cnt,
  6335. // Pric: float64(item.Pric),
  6336. // PatientId: his.PatientId,
  6337. // PricUplmtAmt: item.PricUplmtAmt,
  6338. // SelfpayProp: item.SelfpayProp,
  6339. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6340. // OverlmtAmt: item.OverlmtAmt,
  6341. // PreselfpayAmt: item.PreselfpayAmt,
  6342. // BasMednFlag: item.BasMednFlag,
  6343. // MedChrgitmType: item.MedChrgitmType,
  6344. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6345. // Status: 1,
  6346. // Memo: item.Memo,
  6347. // Mtime: time.Now().Unix(),
  6348. // InscpScpAmt: item.InscpScpAmt,
  6349. // DrtReimFlag: item.DrtReimFlag,
  6350. // Ctime: time.Now().Unix(),
  6351. // ListSpItemFlag: item.ListSpItemFlag,
  6352. // ChldMedcFlag: item.ChldMedcFlag,
  6353. // LmtUsedFlag: item.LmtUsedFlag,
  6354. // ChrgitmLv: item.ChrgitmLv,
  6355. // UserOrgId: adminUser.CurrentOrgId,
  6356. // HisPatientId: his.ID,
  6357. // OrderId: order.ID,
  6358. // ProjectId: project_id,
  6359. // Type: types,
  6360. // }
  6361. // service.CreateOrderInfo(info)
  6362. //
  6363. // }
  6364. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6365. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6366. //
  6367. // var total float64
  6368. // for _, item := range prescriptions {
  6369. // if item.Type == 1 { //药品
  6370. // for _, subItem := range item.HisDoctorAdviceInfo {
  6371. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6372. // }
  6373. // }
  6374. // if item.Type == 2 { //项目
  6375. // for _, subItem := range item.HisPrescriptionProject {
  6376. // total = total + (subItem.Price * float64(subItem.Count))
  6377. // }
  6378. // }
  6379. // }
  6380. //
  6381. // for _, item := range prescriptions {
  6382. // for _, subItem := range item.HisAdditionalCharge {
  6383. // total = total + (subItem.Price * float64(subItem.Count))
  6384. // }
  6385. // }
  6386. //
  6387. // allTotal := fmt.Sprintf("%.2f", total)
  6388. // if res.Infcode == 0 {
  6389. // var rf []*ResultFive
  6390. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6391. // psn_no := his.PsnNo
  6392. // mdtrt_id := his.Number
  6393. // chrg_bchno := chrg_bchno
  6394. // cert_no := his.Certno
  6395. // insutype := rf[0].Insutype
  6396. //
  6397. // if his.IdCardType == 1 {
  6398. // cert_no = his.MedicalInsuranceNumber
  6399. //
  6400. // } else {
  6401. //
  6402. // cert_no = his.Certno
  6403. //
  6404. // }
  6405. //
  6406. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6407. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6408. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6409. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6410. // resp, requestErr := http.Get(api)
  6411. // if requestErr != nil {
  6412. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6413. // return
  6414. // }
  6415. // defer resp.Body.Close()
  6416. // body, ioErr := ioutil.ReadAll(resp.Body)
  6417. // if ioErr != nil {
  6418. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6420. // return
  6421. // }
  6422. // var respJSON map[string]interface{}
  6423. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6424. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6425. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6426. // return
  6427. // }
  6428. // fmt.Println(respJSON)
  6429. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6430. // userJSONBytes, _ := json.Marshal(respJSON)
  6431. // var res ResultSeven
  6432. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6433. // utils.ErrorLog("解析失败:%v", err)
  6434. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6435. // return
  6436. // }
  6437. // if res.Infcode != 0 {
  6438. // errlog := &models.HisOrderError{
  6439. // UserOrgId: adminUser.CurrentOrgId,
  6440. // Ctime: time.Now().Unix(),
  6441. // Mtime: time.Now().Unix(),
  6442. // Number: chrg_bchno,
  6443. // ErrMsg: res.ErrMsg,
  6444. // Status: 1,
  6445. // PatientId: id,
  6446. // RecordTime: recordDateTime,
  6447. // Stage: 7,
  6448. // }
  6449. // service.CreateErrMsgLog(errlog)
  6450. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6451. // return
  6452. // } else {
  6453. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6454. // order.OrderStatus = 1
  6455. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6456. // order.SetlId = res.Output.Setlinfo.SetlID
  6457. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6458. // order.PsnName = res.Output.Setlinfo.PsnName
  6459. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6460. // order.Certno = res.Output.Setlinfo.Certno
  6461. // order.Gend = res.Output.Setlinfo.Gend
  6462. // order.Naty = res.Output.Setlinfo.Naty
  6463. // order.Age = res.Output.Setlinfo.Age
  6464. // order.Insutype = res.Output.Setlinfo.Insutype
  6465. // order.PsnType = res.Output.Setlinfo.PsnType
  6466. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6467. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6468. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6469. // order.MedType = res.Output.Setlinfo.MedType
  6470. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6471. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6472. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6473. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6474. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6475. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6476. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6477. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6478. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6479. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6480. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6481. // order.MafPay = res.Output.Setlinfo.MafPay
  6482. // order.OthPay = res.Output.Setlinfo.OthPay
  6483. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6484. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6485. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6486. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6487. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6488. // order.Balc = res.Output.Setlinfo.Balc
  6489. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6490. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6491. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6492. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6493. // order.Creator = order.Creator
  6494. // order.Modify = roles.ID
  6495. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6496. // detailStr := string(setlDetail)
  6497. // order.SetlDetail = detailStr
  6498. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6499. // err = service.UpDateOrder(order)
  6500. // if err == nil {
  6501. // c.ServeSuccessJSON(map[string]interface{}{
  6502. // "msg": "预结算成功",
  6503. // })
  6504. // } else {
  6505. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6506. // return
  6507. // }
  6508. // }
  6509. // } else {
  6510. // adminUser := c.GetAdminUserInfo()
  6511. // errlog := &models.HisOrderError{
  6512. // UserOrgId: adminUser.CurrentOrgId,
  6513. // Ctime: time.Now().Unix(),
  6514. // Mtime: time.Now().Unix(),
  6515. // ErrMsg: res.ErrMsg,
  6516. // Status: 1,
  6517. // PatientId: id,
  6518. // RecordTime: recordDateTime,
  6519. // Stage: 4,
  6520. // }
  6521. // service.CreateErrMsgLog(errlog)
  6522. //
  6523. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6524. // return
  6525. // }
  6526. // } else {
  6527. // adminUser := c.GetAdminUserInfo()
  6528. // errlog := &models.HisOrderError{
  6529. // UserOrgId: adminUser.CurrentOrgId,
  6530. // Ctime: time.Now().Unix(),
  6531. // Mtime: time.Now().Unix(),
  6532. // ErrMsg: res.ErrMsg,
  6533. // Status: 1,
  6534. // PatientId: id,
  6535. // RecordTime: recordDateTime,
  6536. // Stage: 4,
  6537. // }
  6538. // service.CreateErrMsgLog(errlog)
  6539. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6540. // return
  6541. // }
  6542. //
  6543. // } else {
  6544. // var total float64
  6545. // for _, item := range prescriptions {
  6546. // if item.Type == 1 { //药品
  6547. // for _, subItem := range item.HisDoctorAdviceInfo {
  6548. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6549. // }
  6550. // }
  6551. // if item.Type == 2 { //项目
  6552. // for _, subItem := range item.HisPrescriptionProject {
  6553. // total = total + (subItem.Price * float64(subItem.Count))
  6554. // }
  6555. // }
  6556. //
  6557. // for _, subItem := range item.HisAdditionalCharge {
  6558. // total = total + (subItem.Price * float64(subItem.Count))
  6559. // }
  6560. // }
  6561. //
  6562. // allTotal := fmt.Sprintf("%.2f", total)
  6563. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6564. // order := &models.HisOrder{
  6565. // UserOrgId: adminUser.CurrentOrgId,
  6566. // HisPatientId: his.ID,
  6567. // PatientId: id,
  6568. // SettleAccountsDate: recordDateTime,
  6569. // Ctime: time.Now().Unix(),
  6570. // Mtime: time.Now().Unix(),
  6571. // Status: 1,
  6572. // OrderStatus: 2,
  6573. // Number: chrg_bchno,
  6574. // MedfeeSumamt: totals,
  6575. // }
  6576. // err = service.CreateOrder(order)
  6577. // if err != nil {
  6578. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6579. // return
  6580. // }
  6581. //
  6582. // var customs []*Custom
  6583. // for _, item := range prescriptions {
  6584. //
  6585. // if item.Type == 1 { //药品
  6586. // for _, subItem := range item.HisDoctorAdviceInfo {
  6587. // cus := &Custom{
  6588. // AdviceId: subItem.ID,
  6589. // ProjectId: 0,
  6590. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6591. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6592. // FeedetlSn: subItem.FeedetlSn,
  6593. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6594. // MedListCodg: subItem.MedListCodg,
  6595. // Type: 1,
  6596. // }
  6597. // customs = append(customs, cus)
  6598. // }
  6599. // }
  6600. //
  6601. // if item.Type == 2 { //项目
  6602. // for _, subItem := range item.HisPrescriptionProject {
  6603. //
  6604. // cus := &Custom{
  6605. // AdviceId: 0,
  6606. // ProjectId: subItem.ID,
  6607. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6608. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6609. // FeedetlSn: subItem.FeedetlSn,
  6610. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6611. // MedListCodg: subItem.MedListCodg,
  6612. // Type: 2,
  6613. // }
  6614. //
  6615. // customs = append(customs, cus)
  6616. // }
  6617. // }
  6618. //
  6619. // for _, item := range item.HisAdditionalCharge {
  6620. // cus := &Custom{
  6621. // ItemId: item.ID,
  6622. // AdviceId: 0,
  6623. // ProjectId: 0,
  6624. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6625. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6626. // FeedetlSn: item.FeedetlSn,
  6627. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6628. // MedListCodg: item.XtHisAddtionConfig.Code,
  6629. // Type: 3,
  6630. // }
  6631. //
  6632. // customs = append(customs, cus)
  6633. // }
  6634. //
  6635. // }
  6636. //
  6637. // for _, item := range customs {
  6638. // var advice_id int64 = 0
  6639. // var project_id int64 = 0
  6640. // var item_id int64 = 0
  6641. //
  6642. // var types int64 = 0
  6643. //
  6644. // if item.Type == 1 {
  6645. // advice_id = item.AdviceId
  6646. // project_id = 0
  6647. // item_id = 0
  6648. // } else if item.Type == 2 {
  6649. // advice_id = 0
  6650. // item_id = 0
  6651. //
  6652. // project_id = item.ProjectId
  6653. // } else if item.Type == 3 {
  6654. // advice_id = 0
  6655. // item_id = item.ItemId
  6656. // project_id = 0
  6657. // }
  6658. //
  6659. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6660. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6661. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6662. //
  6663. // info := &models.HisOrderInfo{
  6664. // OrderNumber: order.Number,
  6665. // UploadDate: time.Now().Unix(),
  6666. // AdviceId: advice_id,
  6667. // DetItemFeeSumamt: detItemFeeSumamt,
  6668. // Cnt: cut,
  6669. // Pric: pric,
  6670. // PatientId: id,
  6671. // Status: 1,
  6672. // Mtime: time.Now().Unix(),
  6673. // Ctime: time.Now().Unix(),
  6674. // UserOrgId: adminUser.CurrentOrgId,
  6675. // HisPatientId: his.ID,
  6676. // OrderId: order.ID,
  6677. // ProjectId: project_id,
  6678. // Type: types,
  6679. // ItemId: item_id,
  6680. // }
  6681. // service.CreateOrderInfo(info)
  6682. // }
  6683. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6684. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6685. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6686. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6687. // if err == nil {
  6688. // c.ServeSuccessJSON(map[string]interface{}{
  6689. // "msg": "结算成功",
  6690. // })
  6691. // } else {
  6692. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6693. // return
  6694. // }
  6695. // }
  6696. //}
  6697. //上传明细-预结算-
  6698. func (c *HisApiController) GetPreUploadInfo() {
  6699. id, _ := c.GetInt64("id")
  6700. record_time := c.GetString("record_time")
  6701. his_patient_id, _ := c.GetInt64("his_patient_id")
  6702. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6703. admin_user_id, _ := c.GetInt64("admin_user_id")
  6704. diagnosis_id := c.GetString("diagnosis")
  6705. sick_type, _ := c.GetInt64("sick_type")
  6706. reg_type, _ := c.GetInt64("p_type")
  6707. begin_time := c.GetString("begin_time")
  6708. id_str := c.GetString("ids")
  6709. ids_arr := strings.Split(id_str, ",")
  6710. timeLayout := "2006-01-02"
  6711. loc, _ := time.LoadLocation("Local")
  6712. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6713. if err != nil {
  6714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6715. return
  6716. }
  6717. recordDateTime := theTime.Unix()
  6718. adminUser := c.GetAdminUserInfo()
  6719. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6720. var config []*models.HisXtDiagnoseConfig
  6721. for _, item := range diagnosis_ids {
  6722. id, _ := strconv.ParseInt(item, 10, 64)
  6723. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6724. config = append(config, &diagnosisConfig)
  6725. }
  6726. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6727. sickConfig, _ := service.FindSickById(sick_type)
  6728. var prescriptions []*models.HisPrescription
  6729. var start_time int64
  6730. var end_time int64
  6731. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6732. fmt.Println(his_patient_id)
  6733. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6734. timestamp := time.Now().Unix()
  6735. tempTime := time.Unix(timestamp, 0)
  6736. timeFormat := tempTime.Format("20060102150405")
  6737. chrgBchno := rand.Intn(100000) + 10000
  6738. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6739. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6740. var patientPrescription models.HisPrescriptionInfo
  6741. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6742. if patientPrescription.ID == 0 {
  6743. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6744. }
  6745. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6746. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6747. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6748. strconv.FormatInt(his.PatientId, 10)
  6749. var res2 ResultSix
  6750. var resSix10265 ResultSix10265
  6751. var time_stamp string
  6752. if miConfig.MdtrtareaAdmvs == "421300" {
  6753. data := make(map[string]interface{})
  6754. client := &http.Client{}
  6755. data["psn_no"] = his.PsnNo
  6756. data["mdtrt_id"] = his.Number
  6757. data["department"] = department.Name
  6758. data["org_name"] = miConfig.OrgName
  6759. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6760. data["doctor_id"] = doctor_info.DoctorNumber
  6761. data["doctor_name"] = roles.UserName
  6762. data["fixmedins_code"] = miConfig.Code
  6763. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6764. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6765. data["secret_key"] = miConfig.SecretKey
  6766. data["sick_code"] = sickConfig.CountryCode
  6767. data["sick_name"] = sickConfig.ClassName
  6768. data["begin_time"] = begin_time
  6769. data["dept"] = strconv.FormatInt(department.ID, 10)
  6770. data["config"] = config
  6771. data["opter"] = roles.UserName
  6772. fmt.Println(data)
  6773. bytesData, _ := json.Marshal(data)
  6774. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6775. resp, _ := client.Do(req)
  6776. defer resp.Body.Close()
  6777. body, ioErr := ioutil.ReadAll(resp.Body)
  6778. if ioErr != nil {
  6779. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6780. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6781. return
  6782. }
  6783. var respJSON map[string]interface{}
  6784. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6785. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6787. return
  6788. }
  6789. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6790. userJSONBytes, _ := json.Marshal(respJSON)
  6791. fmt.Println("log")
  6792. fmt.Println(string(userJSONBytes))
  6793. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6794. utils.ErrorLog("解析失败:%v", err)
  6795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6796. return
  6797. }
  6798. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6799. //江苏地区国家医保医疗类别
  6800. //职工透析:医疗类别选特殊情况门诊9933
  6801. //居民血透门慢: 医疗类别选门诊慢病1402
  6802. //var med_type string
  6803. //if his.Insutype == "310" {
  6804. // if reg_type == 14 {
  6805. // med_type = "9933"
  6806. // } else if reg_type == 11 {
  6807. // med_type = "11"
  6808. //
  6809. // }
  6810. //} else if his.Insutype == "390" {
  6811. // if reg_type == 14 {
  6812. // med_type = "1402"
  6813. // } else if reg_type == 11 {
  6814. // med_type = "11"
  6815. // }
  6816. //}
  6817. data := make(map[string]interface{})
  6818. client := &http.Client{}
  6819. data["psn_no"] = his.PsnNo
  6820. data["mdtrt_id"] = his.Number
  6821. data["doctor"] = roles.UserName
  6822. data["department"] = department.Name
  6823. data["org_name"] = miConfig.OrgName
  6824. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6825. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6826. data["fixmedins_code"] = miConfig.Code
  6827. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6828. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6829. data["secret_key"] = miConfig.SecretKey
  6830. data["sick_code"] = sickConfig.CountryCode
  6831. data["sick_name"] = sickConfig.ClassName
  6832. data["begin_time"] = begin_time
  6833. data["dept"] = strconv.FormatInt(department.ID, 10)
  6834. data["config"] = config
  6835. data["url"] = miConfig.Url
  6836. data["ak"] = miConfig.AccessKey
  6837. data["cainfo"] = miConfig.Cainfo
  6838. bytesData, _ := json.Marshal(data)
  6839. var req *http.Request
  6840. if miConfig.MdtrtareaAdmvs == "320921" {
  6841. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6842. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6843. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6844. } else {
  6845. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6846. }
  6847. resp, _ := client.Do(req)
  6848. defer resp.Body.Close()
  6849. body, ioErr := ioutil.ReadAll(resp.Body)
  6850. if ioErr != nil {
  6851. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6853. return
  6854. }
  6855. var respJSON map[string]interface{}
  6856. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6857. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6859. return
  6860. }
  6861. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6862. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6863. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6864. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6865. userJSONBytes, _ := json.Marshal(respJSON)
  6866. fmt.Println("log")
  6867. fmt.Println(string(userJSONBytes))
  6868. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6869. utils.ErrorLog("解析失败:%v", err)
  6870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6871. return
  6872. }
  6873. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6874. res2.Output = resSix10265.Output
  6875. res2.ErrMsg = resSix10265.ErrMsg
  6876. res2.Cainfo = resSix10265.Cainfo
  6877. res2.WarnMsg = resSix10265.WarnMsg
  6878. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6879. res2.Infcode = infocode
  6880. } else {
  6881. var result string
  6882. var requestLog string
  6883. if miConfig.MdtrtareaAdmvs == "440781" { //
  6884. 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)
  6885. } else {
  6886. if miConfig.Code == "H15049901371" {
  6887. //赤峰地区国家医保医疗类别
  6888. //职工透析:医疗类别选特殊情况门诊990502
  6889. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6890. var med_type string
  6891. if his.Insutype == "390" {
  6892. if reg_type == 14 {
  6893. med_type = "9933"
  6894. } else if reg_type == 11 {
  6895. med_type = "11"
  6896. }
  6897. } else if his.Insutype == "310" {
  6898. if reg_type == 14 {
  6899. med_type = "990502"
  6900. } else if reg_type == 11 {
  6901. med_type = "11"
  6902. }
  6903. }
  6904. 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)
  6905. } else {
  6906. 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)
  6907. }
  6908. saveLog(result, requestLog, "2203", "上传就诊信息")
  6909. var respJSON2 map[string]interface{}
  6910. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6913. return
  6914. }
  6915. userJSONBytes2, _ := json.Marshal(respJSON2)
  6916. if miConfig.Code == "H15049901371" {
  6917. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6918. utils.ErrorLog("解析失败:%v", err)
  6919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6920. return
  6921. }
  6922. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6923. res2.Output = resSix10265.Output
  6924. res2.ErrMsg = resSix10265.ErrMsg
  6925. res2.Cainfo = resSix10265.Cainfo
  6926. res2.WarnMsg = resSix10265.WarnMsg
  6927. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6928. res2.Infcode = infocode
  6929. } else {
  6930. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6931. utils.ErrorLog("解析失败:%v", err)
  6932. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6933. return
  6934. }
  6935. }
  6936. }
  6937. }
  6938. if res2.Infcode != 0 {
  6939. adminUser := c.GetAdminUserInfo()
  6940. errlog := &models.HisOrderError{
  6941. UserOrgId: adminUser.CurrentOrgId,
  6942. Ctime: time.Now().Unix(),
  6943. Mtime: time.Now().Unix(),
  6944. ErrMsg: res2.ErrMsg,
  6945. Status: 1,
  6946. PatientId: id,
  6947. RecordTime: recordDateTime,
  6948. Stage: 3,
  6949. }
  6950. service.CreateErrMsgLog(errlog)
  6951. c.ServeSuccessJSON(map[string]interface{}{
  6952. "failed_code": -10,
  6953. "msg": res2.ErrMsg,
  6954. })
  6955. return
  6956. } else {
  6957. his.Diagnosis = diagnosis_id
  6958. his.SickType = sickConfig.ID
  6959. his.PType = fmt.Sprintf("%d", reg_type)
  6960. service.UpdateHisPatientThree(&his)
  6961. data := make(map[string]interface{})
  6962. if settle_accounts_type == 1 { //日结
  6963. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6964. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6965. } else {
  6966. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6967. }
  6968. data["pre"] = prescriptions
  6969. } else { //月结
  6970. start_time_str := c.GetString("start_time")
  6971. end_time_str := c.GetString("end_time")
  6972. timeLayout := "2006-01-02"
  6973. loc, _ := time.LoadLocation("Local")
  6974. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6975. if err != nil {
  6976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6977. return
  6978. }
  6979. recordStartTime := theStartTime.Unix()
  6980. start_time = recordStartTime
  6981. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6982. if err != nil {
  6983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6984. return
  6985. }
  6986. recordEndTime := theEndTime.Unix()
  6987. end_time = recordEndTime
  6988. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6989. data["pre"] = prescriptions
  6990. }
  6991. client := &http.Client{}
  6992. data["psn_no"] = his.PsnNo
  6993. data["mdtrt_id"] = his.Number
  6994. data["chrg_bchno"] = chrg_bchno
  6995. data["org_name"] = miConfig.OrgName
  6996. data["doctor"] = roles.UserName
  6997. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6998. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6999. data["fixmedins_code"] = miConfig.Code
  7000. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7001. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7002. data["dept_code"] = "15"
  7003. } else {
  7004. data["dept_code"] = department.Number
  7005. }
  7006. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7007. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7008. data["secret_key"] = miConfig.SecretKey
  7009. data["url"] = miConfig.Url
  7010. data["ak"] = miConfig.AccessKey
  7011. data["new_doctor_name"] = patientPrescription.Doctor
  7012. data["diag_code"] = sickConfig.CountryCode
  7013. data["time_stamp"] = time_stamp
  7014. data["cainfo"] = miConfig.Cainfo
  7015. var ids []int64
  7016. for _, item := range prescriptions {
  7017. ids = append(ids, item.ID)
  7018. }
  7019. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7020. if config.IsOpen == 1 { //对接了医保,走医保流程
  7021. var res ResultFour
  7022. var resFour10265 ResultFour10265
  7023. if miConfig.MdtrtareaAdmvs == "421300" {
  7024. bytesData, _ := json.Marshal(data)
  7025. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7026. resp, _ := client.Do(req)
  7027. defer resp.Body.Close()
  7028. body, ioErr := ioutil.ReadAll(resp.Body)
  7029. if ioErr != nil {
  7030. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7032. return
  7033. }
  7034. var respJSON map[string]interface{}
  7035. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7036. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7037. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7038. return
  7039. }
  7040. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7041. userJSONBytes, _ := json.Marshal(respJSON)
  7042. fmt.Println("log")
  7043. fmt.Println(string(userJSONBytes))
  7044. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7045. utils.ErrorLog("解析失败:%v", err)
  7046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7047. return
  7048. }
  7049. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7050. bytesData, _ := json.Marshal(data)
  7051. var req *http.Request
  7052. if miConfig.MdtrtareaAdmvs == "320921" {
  7053. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7054. } else {
  7055. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7056. }
  7057. resp, _ := client.Do(req)
  7058. defer resp.Body.Close()
  7059. body, ioErr := ioutil.ReadAll(resp.Body)
  7060. if ioErr != nil {
  7061. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7063. return
  7064. }
  7065. var respJSON map[string]interface{}
  7066. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7067. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7069. return
  7070. }
  7071. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7072. userJSONBytes, _ := json.Marshal(respJSON)
  7073. fmt.Println("log")
  7074. fmt.Println(string(userJSONBytes))
  7075. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7076. utils.ErrorLog("解析失败:%v", err)
  7077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7078. return
  7079. }
  7080. res.InfRefmsgid = resFour10265.InfRefmsgid
  7081. res.Output = resFour10265.Output
  7082. res.ErrMsg = resFour10265.ErrMsg
  7083. res.Cainfo = resFour10265.Cainfo
  7084. res.WarnMsg = resFour10265.WarnMsg
  7085. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7086. res.Infcode = infocode
  7087. } else {
  7088. if miConfig.Code == "H15049901371" {
  7089. 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)
  7090. var dat map[string]interface{}
  7091. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7092. fmt.Println(dat)
  7093. } else {
  7094. fmt.Println(err)
  7095. }
  7096. saveLog(result, request_log, "2204", "上传费用明细")
  7097. userJSONBytes, _ := json.Marshal(dat)
  7098. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7099. utils.ErrorLog("解析失败:%v", err)
  7100. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7101. return
  7102. }
  7103. res.InfRefmsgid = resFour10265.InfRefmsgid
  7104. res.Output = resFour10265.Output
  7105. res.ErrMsg = resFour10265.ErrMsg
  7106. res.Cainfo = resFour10265.Cainfo
  7107. res.WarnMsg = resFour10265.WarnMsg
  7108. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7109. res.Infcode = infocode
  7110. } else {
  7111. 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)
  7112. var dat map[string]interface{}
  7113. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7114. fmt.Println(dat)
  7115. } else {
  7116. fmt.Println(err)
  7117. }
  7118. saveLog(result, request_log, "2204", "上传费用明细")
  7119. userJSONBytes, _ := json.Marshal(dat)
  7120. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7121. utils.ErrorLog("解析失败:%v", err)
  7122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7123. return
  7124. }
  7125. }
  7126. }
  7127. if res.Infcode == 0 {
  7128. order := &models.HisOrder{
  7129. UserOrgId: adminUser.CurrentOrgId,
  7130. HisPatientId: his.ID,
  7131. PatientId: his.PatientId,
  7132. SettleAccountsDate: recordDateTime,
  7133. Ctime: time.Now().Unix(),
  7134. Mtime: time.Now().Unix(),
  7135. MdtrtId: his.Number,
  7136. PsnNo: his.PsnNo,
  7137. MedType: strconv.FormatInt(reg_type, 10),
  7138. Status: 1,
  7139. Number: chrg_bchno,
  7140. Infcode: res.Infcode,
  7141. WarnMsg: res.WarnMsg,
  7142. Cainfo: res.Cainfo,
  7143. ErrMsg: res.ErrMsg,
  7144. RespondTime: res.RefmsgTime,
  7145. InfRefmsgid: res.InfRefmsgid,
  7146. OrderStatus: 1,
  7147. IsMedicineInsurance: 1,
  7148. SettleType: settle_accounts_type,
  7149. SettleStartTime: start_time,
  7150. SettleEndTime: end_time,
  7151. Creator: roles.AdminUserId,
  7152. Modify: roles.AdminUserId,
  7153. PType: 2,
  7154. Diagnosis: diagnosis_id,
  7155. }
  7156. err = service.CreateOrder(order)
  7157. if err != nil {
  7158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7159. return
  7160. }
  7161. for _, item := range res.Output.Result {
  7162. temp := strings.Split(item.FeedetlSn, "-")
  7163. var advice_id int64 = 0
  7164. var project_id int64 = 0
  7165. var types int64 = 0
  7166. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7167. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7168. if temp[1] == "1" {
  7169. advice_id = id
  7170. project_id = 0
  7171. } else if temp[1] == "2" {
  7172. advice_id = 0
  7173. project_id = id
  7174. }
  7175. info := &models.HisOrderInfo{
  7176. OrderNumber: order.Number,
  7177. FeedetlSn: item.FeedetlSn,
  7178. UploadDate: time.Now().Unix(),
  7179. AdviceId: advice_id,
  7180. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7181. Cnt: item.Cnt,
  7182. Pric: float64(item.Pric),
  7183. PatientId: his.PatientId,
  7184. PricUplmtAmt: item.PricUplmtAmt,
  7185. SelfpayProp: item.SelfpayProp,
  7186. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7187. OverlmtAmt: item.OverlmtAmt,
  7188. PreselfpayAmt: item.PreselfpayAmt,
  7189. BasMednFlag: item.BasMednFlag,
  7190. MedChrgitmType: item.MedChrgitmType,
  7191. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7192. Status: 1,
  7193. Memo: item.Memo,
  7194. Mtime: time.Now().Unix(),
  7195. InscpScpAmt: item.InscpScpAmt,
  7196. DrtReimFlag: item.DrtReimFlag,
  7197. Ctime: time.Now().Unix(),
  7198. ListSpItemFlag: item.ListSpItemFlag,
  7199. ChldMedcFlag: item.ChldMedcFlag,
  7200. LmtUsedFlag: item.LmtUsedFlag,
  7201. ChrgitmLv: item.ChrgitmLv,
  7202. UserOrgId: adminUser.CurrentOrgId,
  7203. HisPatientId: his.ID,
  7204. OrderId: order.ID,
  7205. ProjectId: project_id,
  7206. Type: types,
  7207. }
  7208. service.CreateOrderInfo(info)
  7209. }
  7210. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7211. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7212. var total float64
  7213. for _, item := range prescriptions {
  7214. if item.Type == 1 { //药品
  7215. for _, subItem := range item.HisDoctorAdviceInfo {
  7216. total = total + (subItem.Price * subItem.PrescribingNumber)
  7217. }
  7218. }
  7219. if item.Type == 2 { //项目
  7220. for _, subItem := range item.HisPrescriptionProject {
  7221. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7222. total = total + (subItem.Price * cnt)
  7223. }
  7224. }
  7225. }
  7226. for _, item := range prescriptions {
  7227. for _, subItem := range item.HisAdditionalCharge {
  7228. total = total + (subItem.Price * float64(subItem.Count))
  7229. }
  7230. }
  7231. allTotal := fmt.Sprintf("%.4f", total)
  7232. if res.Infcode == 0 {
  7233. var rf []*ResultFive
  7234. json.Unmarshal([]byte(his.Iinfo), &rf)
  7235. chrg_bchno := chrg_bchno
  7236. cert_no := his.Certno
  7237. var insutypes []string
  7238. var insutype string
  7239. var is390 int = 0
  7240. var is310 int = 0
  7241. for _, item := range rf {
  7242. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7243. insutypes = append(insutypes, item.Insutype)
  7244. }
  7245. }
  7246. if len(insutypes) == 1 {
  7247. insutype = insutypes[0]
  7248. } else {
  7249. for _, i := range insutypes {
  7250. if i == "390" {
  7251. is390 = 1
  7252. }
  7253. if i == "310" {
  7254. is310 = 1
  7255. }
  7256. }
  7257. }
  7258. if is390 == 1 {
  7259. insutype = "390"
  7260. }
  7261. if is310 == 1 {
  7262. insutype = "310"
  7263. }
  7264. if len(insutypes) == 0 {
  7265. insutype = "310"
  7266. }
  7267. if len(insutypes) == 2 {
  7268. insutype = strconv.FormatInt(his.SocialType, 64)
  7269. }
  7270. //insutype = "390"
  7271. if his.IdCardType == 1 {
  7272. cert_no = his.MedicalInsuranceNumber
  7273. } else {
  7274. cert_no = his.Certno
  7275. }
  7276. var res ResultSeven
  7277. var resSeven10265 ResultSeven10265
  7278. if miConfig.MdtrtareaAdmvs == "421300" {
  7279. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7280. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7281. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7282. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7283. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7284. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7285. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7286. resp, requestErr := http.Get(api)
  7287. if requestErr != nil {
  7288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7289. return
  7290. }
  7291. body, ioErr := ioutil.ReadAll(resp.Body)
  7292. if ioErr != nil {
  7293. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7294. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7295. return
  7296. }
  7297. var respJSON map[string]interface{}
  7298. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7299. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7301. return
  7302. }
  7303. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7304. result, _ := json.Marshal(respJSON)
  7305. fmt.Println("log")
  7306. fmt.Println(string(result))
  7307. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7308. utils.ErrorLog("解析失败:%v", err)
  7309. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7310. return
  7311. }
  7312. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7313. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7314. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7315. bas := strings.Split(psn_info.CardInfo, "|")
  7316. if his.IdCardType == 1 {
  7317. cert_no = bas[2]
  7318. } else {
  7319. cert_no = bas[1]
  7320. }
  7321. //江苏地区国家医保医疗类别
  7322. //职工透析:医疗类别选特殊情况门诊9933
  7323. //居民血透门慢: 医疗类别选门诊慢病1402
  7324. //var med_type string
  7325. //if his.Insutype == "310" {
  7326. // if reg_type == 14 {
  7327. // med_type = "9933"
  7328. // } else if reg_type == 11 {
  7329. // med_type = "11"
  7330. //
  7331. // }
  7332. //} else if his.Insutype == "390" {
  7333. // if reg_type == 14 {
  7334. // med_type = "1402"
  7335. // } else if reg_type == 11 {
  7336. // med_type = "11"
  7337. // }
  7338. //}
  7339. var api string
  7340. if miConfig.MdtrtareaAdmvs == "320921" {
  7341. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7342. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7343. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7344. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7345. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7346. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7347. "&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
  7348. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7349. } else {
  7350. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7351. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7352. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7353. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7354. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7355. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7356. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7357. "&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
  7358. }
  7359. resp, requestErr := http.Get(api)
  7360. if requestErr != nil {
  7361. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7362. return
  7363. }
  7364. body, ioErr := ioutil.ReadAll(resp.Body)
  7365. if ioErr != nil {
  7366. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7367. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7368. return
  7369. }
  7370. var respJSON map[string]interface{}
  7371. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7372. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7373. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7374. return
  7375. }
  7376. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7377. result, _ := json.Marshal(respJSON)
  7378. fmt.Println("log")
  7379. fmt.Println(string(result))
  7380. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7381. utils.ErrorLog("解析失败:%v", err)
  7382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7383. return
  7384. }
  7385. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7386. res.Output = resSeven10265.Output
  7387. res.ErrMsg = resSeven10265.ErrMsg
  7388. res.Cainfo = resSeven10265.Cainfo
  7389. res.WarnMsg = resSeven10265.WarnMsg
  7390. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7391. res.Infcode = infocode
  7392. } else {
  7393. var result string
  7394. var request_log string
  7395. if miConfig.Code == "H15049901371" {
  7396. //赤峰地区国家医保医疗类别
  7397. //职工透析:医疗类别选特殊情况门诊990502
  7398. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7399. var med_type string
  7400. if his.Insutype == "390" {
  7401. if reg_type == 14 {
  7402. med_type = "9933"
  7403. } else if reg_type == 11 {
  7404. med_type = "11"
  7405. }
  7406. } else if his.Insutype == "310" {
  7407. if reg_type == 14 {
  7408. med_type = "990502"
  7409. } else if reg_type == 11 {
  7410. med_type = "11"
  7411. }
  7412. }
  7413. 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)
  7414. } else {
  7415. 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)
  7416. }
  7417. var dat map[string]interface{}
  7418. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7419. fmt.Println(dat)
  7420. } else {
  7421. fmt.Println(err)
  7422. }
  7423. saveLog(result, request_log, "2206", "预结算")
  7424. //userJSONBytes, _ := json.Marshal(dat)
  7425. //
  7426. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7427. // utils.ErrorLog("解析失败:%v", err)
  7428. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7429. // return
  7430. //}
  7431. userJSONBytes, _ := json.Marshal(dat)
  7432. if miConfig.Code == "H15049901371" {
  7433. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7434. utils.ErrorLog("解析失败:%v", err)
  7435. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7436. return
  7437. }
  7438. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7439. res.Output = resSeven10265.Output
  7440. res.ErrMsg = resSeven10265.ErrMsg
  7441. res.Cainfo = resSeven10265.Cainfo
  7442. res.WarnMsg = resSeven10265.WarnMsg
  7443. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7444. res.Infcode = infocode
  7445. } else {
  7446. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7447. utils.ErrorLog("解析失败:%v", err)
  7448. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7449. return
  7450. }
  7451. }
  7452. }
  7453. if res.Infcode != 0 {
  7454. errlog := &models.HisOrderError{
  7455. UserOrgId: adminUser.CurrentOrgId,
  7456. Ctime: time.Now().Unix(),
  7457. Mtime: time.Now().Unix(),
  7458. Number: chrg_bchno,
  7459. ErrMsg: res.ErrMsg,
  7460. Status: 1,
  7461. PatientId: id,
  7462. RecordTime: recordDateTime,
  7463. Stage: 20,
  7464. }
  7465. service.CreateErrMsgLog(errlog)
  7466. c.ServeSuccessJSON(map[string]interface{}{
  7467. "failed_code": -10,
  7468. "msg": res.ErrMsg,
  7469. })
  7470. return
  7471. } else {
  7472. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7473. order.OrderStatus = 1
  7474. order.IsPre = 1
  7475. order.Status = 1
  7476. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7477. order.SetlId = res.Output.Setlinfo.SetlID
  7478. order.PsnNo = res.Output.Setlinfo.PsnNo
  7479. order.PsnName = res.Output.Setlinfo.PsnName
  7480. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7481. order.Certno = res.Output.Setlinfo.Certno
  7482. order.Gend = res.Output.Setlinfo.Gend
  7483. order.Naty = res.Output.Setlinfo.Naty
  7484. order.Age = res.Output.Setlinfo.Age
  7485. order.Insutype = res.Output.Setlinfo.Insutype
  7486. order.PsnType = res.Output.Setlinfo.PsnType
  7487. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7488. order.SetlTime = res.Output.Setlinfo.SetlTime
  7489. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7490. if res.Output.Setlinfo.MedType == "140101" {
  7491. order.MedType = "14"
  7492. } else {
  7493. order.MedType = res.Output.Setlinfo.MedType
  7494. }
  7495. if reg_type == 1112 {
  7496. order.MedType = "1112"
  7497. }
  7498. if reg_type == 1111 {
  7499. order.MedType = "1111"
  7500. }
  7501. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7502. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7503. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7504. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7505. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7506. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7507. order.HifpPay = res.Output.Setlinfo.HifpPay
  7508. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7509. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7510. order.HifesPay = res.Output.Setlinfo.HifesPay
  7511. order.HifobPay = res.Output.Setlinfo.HifobPay
  7512. order.MafPay = res.Output.Setlinfo.MafPay
  7513. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7514. order.OthPay = res.Output.Setlinfo.OthPay
  7515. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7516. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7517. order.AcctPay = res.Output.Setlinfo.AcctPay
  7518. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7519. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7520. order.Balc = res.Output.Setlinfo.Balc
  7521. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7522. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7523. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7524. order.ClrWay = res.Output.Setlinfo.ClrWay
  7525. order.Creator = order.Creator
  7526. order.Modify = roles.AdminUserId
  7527. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7528. detailStr := string(setlDetail)
  7529. order.SetlDetail = detailStr
  7530. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7531. err = service.UpDateOrder(order)
  7532. if err == nil {
  7533. c.ServeSuccessJSON(map[string]interface{}{
  7534. "msg": "预结算成功",
  7535. })
  7536. } else {
  7537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7538. return
  7539. }
  7540. }
  7541. } else {
  7542. adminUser := c.GetAdminUserInfo()
  7543. errlog := &models.HisOrderError{
  7544. UserOrgId: adminUser.CurrentOrgId,
  7545. Ctime: time.Now().Unix(),
  7546. Mtime: time.Now().Unix(),
  7547. ErrMsg: res.ErrMsg,
  7548. Status: 1,
  7549. PatientId: id,
  7550. RecordTime: recordDateTime,
  7551. Stage: 4,
  7552. }
  7553. service.CreateErrMsgLog(errlog)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7555. return
  7556. }
  7557. } else {
  7558. adminUser := c.GetAdminUserInfo()
  7559. errlog := &models.HisOrderError{
  7560. UserOrgId: adminUser.CurrentOrgId,
  7561. Ctime: time.Now().Unix(),
  7562. Mtime: time.Now().Unix(),
  7563. ErrMsg: res.ErrMsg,
  7564. Status: 1,
  7565. PatientId: id,
  7566. RecordTime: recordDateTime,
  7567. Stage: 4,
  7568. }
  7569. service.CreateErrMsgLog(errlog)
  7570. c.ServeSuccessJSON(map[string]interface{}{
  7571. "failed_code": -10,
  7572. "msg": res.ErrMsg,
  7573. })
  7574. return
  7575. }
  7576. }
  7577. }
  7578. }
  7579. //func (c *HisApiController) GetSettleInfo() {
  7580. // id, _ := c.GetInt64("id")
  7581. // order_id, _ := c.GetInt64("order_id")
  7582. //
  7583. // record_time := c.GetString("record_time")
  7584. // pay_way, _ := c.GetInt64("pay_way")
  7585. // pay_price, _ := c.GetFloat("pay_price")
  7586. // pay_card_no := c.GetString("pay_card_no")
  7587. // discount_price, _ := c.GetFloat("discount_price")
  7588. // preferential_price, _ := c.GetFloat("preferential_price")
  7589. // reality_price, _ := c.GetFloat("reality_price")
  7590. // found_price, _ := c.GetFloat("found_price")
  7591. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7592. // private_price, _ := c.GetFloat("private_price")
  7593. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7594. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7595. //
  7596. // timeLayout := "2006-01-02"
  7597. // loc, _ := time.LoadLocation("Local")
  7598. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7599. // if err != nil {
  7600. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7601. // return
  7602. // }
  7603. // recordDateTime := theTime.Unix()
  7604. // adminUser := c.GetAdminUserInfo()
  7605. //
  7606. // var prescriptions []*models.HisPrescription
  7607. //
  7608. // data := make(map[string]interface{})
  7609. // if settle_accounts_type == 1 { //日结
  7610. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7611. // data["pre"] = prescriptions
  7612. //
  7613. // } else { //月结
  7614. // start_time_str := c.GetString("start_time")
  7615. // end_time_str := c.GetString("end_time")
  7616. // timeLayout := "2006-01-02"
  7617. // loc, _ := time.LoadLocation("Local")
  7618. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7619. // if err != nil {
  7620. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7621. // return
  7622. // }
  7623. // recordStartTime := theStartTime.Unix()
  7624. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7625. // if err != nil {
  7626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7627. // return
  7628. // }
  7629. // recordEndTime := theEndTime.Unix()
  7630. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7631. // data["pre"] = prescriptions
  7632. //
  7633. // }
  7634. //
  7635. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7636. //
  7637. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7638. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7639. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7640. // strconv.FormatInt(his.PatientId, 10)
  7641. //
  7642. // order_src, _ := service.GetHisOrderByID(order_id)
  7643. //
  7644. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7645. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7646. //
  7647. // var total float64
  7648. // for _, item := range prescriptions {
  7649. // if item.Type == 1 { //药品
  7650. // for _, subItem := range item.HisDoctorAdviceInfo {
  7651. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7652. // }
  7653. // }
  7654. // if item.Type == 2 { //项目
  7655. // for _, subItem := range item.HisPrescriptionProject {
  7656. // total = total + (subItem.Price * float64(subItem.Count))
  7657. // }
  7658. // }
  7659. // }
  7660. //
  7661. // for _, item := range prescriptions {
  7662. // for _, subItem := range item.HisAdditionalCharge {
  7663. // total = total + (subItem.Price * float64(subItem.Count))
  7664. // }
  7665. // }
  7666. //
  7667. // allTotal := fmt.Sprintf("%.2f", total)
  7668. // var rf []*ResultFive
  7669. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7670. // psn_no := order_src.PsnNo
  7671. // mdtrt_id := order_src.MdtrtId
  7672. // chrg_bchno := order_src.Number
  7673. // cert_no := order_src.Certno
  7674. // insutype := rf[0].Insutype
  7675. //
  7676. // if his.IdCardType == 1 {
  7677. // cert_no = his.MedicalInsuranceNumber
  7678. // } else {
  7679. // cert_no = his.Certno
  7680. // }
  7681. //
  7682. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7683. // var dat map[string]interface{}
  7684. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7685. // fmt.Println(dat)
  7686. // } else {
  7687. // fmt.Println(err)
  7688. // }
  7689. //
  7690. // userJSONBytes, _ := json.Marshal(dat)
  7691. //
  7692. //
  7693. //
  7694. // var res ResultSeven
  7695. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7696. // utils.ErrorLog("解析失败:%v", err)
  7697. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7698. // return
  7699. // }
  7700. // if res.Infcode == -1 {
  7701. // errlog := &models.HisOrderError{
  7702. // UserOrgId: adminUser.CurrentOrgId,
  7703. // Ctime: time.Now().Unix(),
  7704. // Mtime: time.Now().Unix(),
  7705. // Number: chrg_bchno,
  7706. // ErrMsg: res.ErrMsg,
  7707. // Status: 1,
  7708. // PatientId: id,
  7709. // RecordTime: recordDateTime,
  7710. // Stage: 6,
  7711. // }
  7712. // service.CreateErrMsgLog(errlog)
  7713. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7714. // return
  7715. // } else {
  7716. // order_src.OrderStatus = 2
  7717. // order_src.PayWay = pay_way
  7718. // order_src.PayPrice = pay_price
  7719. // order_src.PayCardNo = pay_card_no
  7720. // order_src.DiscountPrice = discount_price
  7721. // order_src.PreferentialPrice = preferential_price
  7722. // order_src.RealityPrice = reality_price
  7723. // order_src.FoundPrice = found_price
  7724. // order_src.MedicalInsurancePrice = medical_insurance_price
  7725. // order_src.PrivatePrice = private_price
  7726. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7727. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7728. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7729. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7730. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7731. // order_src.Certno = res.Output.Setlinfo.Certno
  7732. // order_src.Gend = res.Output.Setlinfo.Gend
  7733. // order_src.Naty = res.Output.Setlinfo.Naty
  7734. // order_src.Age = res.Output.Setlinfo.Age
  7735. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7736. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7737. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7738. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7739. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7740. // order_src.MedType = res.Output.Setlinfo.MedType
  7741. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7742. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7743. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7744. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7745. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7746. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7747. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7748. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7749. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7750. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7751. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7752. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7753. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7754. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7755. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7756. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7757. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7758. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7759. // order_src.Balc = res.Output.Setlinfo.Balc
  7760. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7761. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7762. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7763. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7764. // order_src.Creator = order_src.Creator
  7765. // order_src.Modify = roles.ID
  7766. // order_src.RequestLog = src_resquest
  7767. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7768. // detailStr := string(setlDetail)
  7769. // order_src.SetlDetail = detailStr
  7770. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7771. // err = service.UpDateOrder(order_src)
  7772. //
  7773. // if err == nil {
  7774. // c.ServeSuccessJSON(map[string]interface{}{
  7775. // "msg": "结算成功",
  7776. // })
  7777. // } else {
  7778. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7779. // return
  7780. // }
  7781. // }
  7782. // }
  7783. //}
  7784. //退款
  7785. func (c *HisApiController) Refund() {
  7786. order_id, _ := c.GetInt64("order_id")
  7787. admin_user_id, _ := c.GetInt64("admin_user_id")
  7788. adminUser := c.GetAdminUserInfo()
  7789. var order models.HisOrder
  7790. order, _ = service.GetHisOrderByID(order_id)
  7791. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7792. if order.ID == 0 {
  7793. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7794. return
  7795. }
  7796. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7797. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7798. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7799. if config.IsOpen == 1 { //对接了医保,走医保流程
  7800. var res ResultSixteen
  7801. var resSixteen10265 ResultSixteen10265
  7802. var src_resquest string
  7803. var result string
  7804. if miConfig.MdtrtareaAdmvs == "421300" {
  7805. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7806. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7807. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7808. resp3, requestErr3 := http.Get(api3)
  7809. if requestErr3 != nil {
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7814. if ioErr3 != nil {
  7815. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7817. return
  7818. }
  7819. var respJSON3 map[string]interface{}
  7820. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7821. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7823. return
  7824. }
  7825. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7826. userJSONBytes3, _ := json.Marshal(respJSON3)
  7827. fmt.Println("log")
  7828. fmt.Println(string(userJSONBytes3))
  7829. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7830. utils.ErrorLog("解析失败:%v", err)
  7831. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7832. return
  7833. }
  7834. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7835. var api3 string
  7836. if miConfig.MdtrtareaAdmvs == "320921" {
  7837. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7838. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7839. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7840. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7841. } else {
  7842. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7843. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7844. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7845. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7846. }
  7847. resp3, requestErr3 := http.Get(api3)
  7848. if requestErr3 != nil {
  7849. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7850. return
  7851. }
  7852. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7853. if ioErr3 != nil {
  7854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. var respJSON3 map[string]interface{}
  7859. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7862. return
  7863. }
  7864. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7865. userJSONBytes3, _ := json.Marshal(respJSON3)
  7866. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7867. utils.ErrorLog("解析失败:%v", err)
  7868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. return
  7870. }
  7871. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7872. res.Output = resSixteen10265.Output
  7873. res.ErrMsg = resSixteen10265.ErrMsg
  7874. res.Cainfo = resSixteen10265.Cainfo
  7875. res.WarnMsg = resSixteen10265.WarnMsg
  7876. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7877. res.Infcode = infocode
  7878. } else {
  7879. if miConfig.Code == "H15049901371" {
  7880. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7881. var dat map[string]interface{}
  7882. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7883. fmt.Println(dat)
  7884. } else {
  7885. fmt.Println(err)
  7886. }
  7887. saveLog(result, src_resquest, "2208", "退费")
  7888. userJSONBytes, _ := json.Marshal(dat)
  7889. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7890. utils.ErrorLog("解析失败:%v", err)
  7891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7892. return
  7893. }
  7894. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7895. res.Output = resSixteen10265.Output
  7896. res.ErrMsg = resSixteen10265.ErrMsg
  7897. res.Cainfo = resSixteen10265.Cainfo
  7898. res.WarnMsg = resSixteen10265.WarnMsg
  7899. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7900. res.Infcode = infocode
  7901. } else {
  7902. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7903. var dat map[string]interface{}
  7904. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7905. fmt.Println(dat)
  7906. } else {
  7907. fmt.Println(err)
  7908. }
  7909. saveLog(result, src_resquest, "2208", "退费")
  7910. userJSONBytes, _ := json.Marshal(dat)
  7911. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7912. utils.ErrorLog("解析失败:%v", err)
  7913. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7914. return
  7915. }
  7916. }
  7917. }
  7918. if res.Infcode == 0 {
  7919. var res2 ResultSix
  7920. var resSix10265 ResultSix10265
  7921. if miConfig.MdtrtareaAdmvs == "421300" {
  7922. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7923. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7924. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7925. resp3, requestErr3 := http.Get(api3)
  7926. if requestErr3 != nil {
  7927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7928. return
  7929. }
  7930. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7931. if ioErr3 != nil {
  7932. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7934. return
  7935. }
  7936. var respJSON3 map[string]interface{}
  7937. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7938. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7940. return
  7941. }
  7942. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7943. userJSONBytes3, _ := json.Marshal(respJSON3)
  7944. fmt.Println("log")
  7945. fmt.Println(string(userJSONBytes3))
  7946. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7947. utils.ErrorLog("解析失败:%v", err)
  7948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7949. return
  7950. }
  7951. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7952. var api3 string
  7953. if miConfig.MdtrtareaAdmvs == "320921" {
  7954. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7955. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7956. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7957. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7958. } else {
  7959. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7960. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7961. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7962. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7963. }
  7964. resp3, requestErr3 := http.Get(api3)
  7965. if requestErr3 != nil {
  7966. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7967. return
  7968. }
  7969. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7970. if ioErr3 != nil {
  7971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7973. return
  7974. }
  7975. var respJSON3 map[string]interface{}
  7976. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7979. return
  7980. }
  7981. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7982. userJSONBytes3, _ := json.Marshal(respJSON3)
  7983. fmt.Println("log")
  7984. fmt.Println(string(userJSONBytes3))
  7985. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7986. utils.ErrorLog("解析失败:%v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7991. res2.Output = resSix10265.Output
  7992. res2.ErrMsg = resSix10265.ErrMsg
  7993. res2.Cainfo = resSix10265.Cainfo
  7994. res2.WarnMsg = resSix10265.WarnMsg
  7995. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7996. res2.Infcode = infocode
  7997. } else {
  7998. if miConfig.Code == "H15049901371" {
  7999. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8000. var dat map[string]interface{}
  8001. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8002. fmt.Println(dat)
  8003. } else {
  8004. fmt.Println(err)
  8005. }
  8006. saveLog(result2, src_request, "2205", "撤销明细")
  8007. userJSONBytes, _ := json.Marshal(dat)
  8008. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  8009. utils.ErrorLog("解析失败:%v", err)
  8010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8011. return
  8012. }
  8013. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8014. res2.Output = resSix10265.Output
  8015. res2.ErrMsg = resSix10265.ErrMsg
  8016. res2.Cainfo = resSix10265.Cainfo
  8017. res2.WarnMsg = resSix10265.WarnMsg
  8018. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8019. res2.Infcode = infocode
  8020. } else {
  8021. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8022. var dat map[string]interface{}
  8023. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8024. fmt.Println(dat)
  8025. } else {
  8026. fmt.Println(err)
  8027. }
  8028. saveLog(result2, src_request, "2205", "撤销明细")
  8029. userJSONBytes, _ := json.Marshal(dat)
  8030. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8031. utils.ErrorLog("解析失败:%v", err)
  8032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8033. return
  8034. }
  8035. }
  8036. }
  8037. if res2.Infcode == 0 {
  8038. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8039. if err == nil {
  8040. //当押金不为零时产生退费记录
  8041. if order.Decimal != 0 {
  8042. tmp := strconv.FormatInt(order.ID, 10)
  8043. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8044. if err != nil {
  8045. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8046. return
  8047. }
  8048. }
  8049. c.ServeSuccessJSON(map[string]interface{}{
  8050. "msg": "退费成功",
  8051. })
  8052. } else {
  8053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8054. return
  8055. }
  8056. } else {
  8057. c.ServeSuccessJSON(map[string]interface{}{
  8058. "code": -10,
  8059. "msg": res2.ErrMsg,
  8060. })
  8061. }
  8062. } else {
  8063. c.ServeSuccessJSON(map[string]interface{}{
  8064. "code": -10,
  8065. "msg": res.ErrMsg,
  8066. })
  8067. }
  8068. }
  8069. }
  8070. func (c *HisApiController) RefundNumber() {
  8071. record_time := c.GetString("record_time")
  8072. //patient_id, _ := c.GetInt64("patient_id")
  8073. admin_user_id, _ := c.GetInt64("admin_user_id")
  8074. his_patient_id, _ := c.GetInt64("id")
  8075. timeLayout := "2006-01-02"
  8076. loc, _ := time.LoadLocation("Local")
  8077. adminUser := c.GetAdminUserInfo()
  8078. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8079. fmt.Println(err)
  8080. if err != nil {
  8081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8082. return
  8083. }
  8084. recordDateTime := theTime.Unix()
  8085. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8086. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8087. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8088. //order, _ := service.GetHisOrderByID(order_id)
  8089. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8090. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8091. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8092. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8093. if count > 0 {
  8094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8095. return
  8096. }
  8097. if config.IsOpen == 1 { //对接了医保,走医保流程
  8098. var res2 ResultSix
  8099. var resSix10265 ResultSix10265
  8100. if miConfig.MdtrtareaAdmvs == "421300" {
  8101. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8102. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8103. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8104. resp3, requestErr3 := http.Get(api3)
  8105. if requestErr3 != nil {
  8106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8107. return
  8108. }
  8109. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8110. if ioErr3 != nil {
  8111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8113. return
  8114. }
  8115. var respJSON3 map[string]interface{}
  8116. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8119. return
  8120. }
  8121. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8122. userJSONBytes3, _ := json.Marshal(respJSON3)
  8123. fmt.Println("log")
  8124. fmt.Println(string(userJSONBytes3))
  8125. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8126. utils.ErrorLog("解析失败:%v", err)
  8127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8128. return
  8129. }
  8130. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8131. var api3 string
  8132. if miConfig.MdtrtareaAdmvs == "320921" {
  8133. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8134. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8135. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8136. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8137. } else {
  8138. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8139. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8140. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8141. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8142. }
  8143. resp3, requestErr3 := http.Get(api3)
  8144. if requestErr3 != nil {
  8145. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8146. return
  8147. }
  8148. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8149. if ioErr3 != nil {
  8150. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8152. return
  8153. }
  8154. var respJSON3 map[string]interface{}
  8155. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8156. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8158. return
  8159. }
  8160. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8161. userJSONBytes3, _ := json.Marshal(respJSON3)
  8162. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8163. utils.ErrorLog("解析失败:%v", err)
  8164. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8165. return
  8166. }
  8167. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8168. res2.Output = resSix10265.Output
  8169. res2.ErrMsg = resSix10265.ErrMsg
  8170. res2.Cainfo = resSix10265.Cainfo
  8171. res2.WarnMsg = resSix10265.WarnMsg
  8172. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8173. res2.Infcode = infocode
  8174. } else {
  8175. var api3 string
  8176. if miConfig.Code == "H15049901371" {
  8177. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8178. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8179. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8180. } else {
  8181. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8182. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8183. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8184. }
  8185. resp3, requestErr3 := http.Get(api3)
  8186. if requestErr3 != nil {
  8187. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8188. return
  8189. }
  8190. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8191. if ioErr3 != nil {
  8192. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8194. return
  8195. }
  8196. var respJSON3 map[string]interface{}
  8197. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8198. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8200. return
  8201. }
  8202. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8203. userJSONBytes3, _ := json.Marshal(respJSON3)
  8204. if miConfig.Code == "H15049901371" {
  8205. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8206. utils.ErrorLog("解析失败:%v", err)
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8211. res2.Output = resSix10265.Output
  8212. res2.ErrMsg = resSix10265.ErrMsg
  8213. res2.Cainfo = resSix10265.Cainfo
  8214. res2.WarnMsg = resSix10265.WarnMsg
  8215. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8216. res2.Infcode = infocode
  8217. } else {
  8218. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8219. utils.ErrorLog("解析失败:%v", err)
  8220. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8221. return
  8222. }
  8223. }
  8224. }
  8225. if res2.Infcode == 0 {
  8226. if err == nil {
  8227. c.ServeSuccessJSON(map[string]interface{}{
  8228. "msg": "退号成功",
  8229. })
  8230. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8231. } else {
  8232. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8233. return
  8234. }
  8235. } else {
  8236. c.ServeSuccessJSON(map[string]interface{}{
  8237. "code": -10,
  8238. "msg": res2.ErrMsg,
  8239. })
  8240. }
  8241. } else {
  8242. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8243. //if err == nil {
  8244. // c.ServeSuccessJSON(map[string]interface{}{
  8245. // "msg": "退费成功",
  8246. // })
  8247. //} else {
  8248. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8249. // return
  8250. //}
  8251. }
  8252. }
  8253. func (c *HisApiController) RefundDetail() {
  8254. order_id, _ := c.GetInt64("order_id")
  8255. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8256. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8257. number := c.GetString("number")
  8258. record_time := c.GetString("record_time")
  8259. patient_id, _ := c.GetInt64("patient_id")
  8260. //med_type, _ := c.GetInt64("med_type")
  8261. timeLayout := "2006-01-02"
  8262. loc, _ := time.LoadLocation("Local")
  8263. adminUser := c.GetAdminUserInfo()
  8264. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8265. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8266. fmt.Println(err)
  8267. if err != nil {
  8268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8269. return
  8270. }
  8271. recordDateTime := theTime.Unix()
  8272. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8273. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8274. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8275. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8276. var order models.HisOrder
  8277. order, _ = service.GetHisOrderByID(order_id)
  8278. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8279. if config.IsOpen == 1 { //对接了医保,走医保流程
  8280. var res2 ResultSix
  8281. if miConfig.MdtrtareaAdmvs == "421300" {
  8282. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8283. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8284. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8285. resp3, requestErr3 := http.Get(api3)
  8286. if requestErr3 != nil {
  8287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8288. return
  8289. }
  8290. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8291. if ioErr3 != nil {
  8292. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8293. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8294. return
  8295. }
  8296. var respJSON3 map[string]interface{}
  8297. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8298. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8299. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8300. return
  8301. }
  8302. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8303. userJSONBytes3, _ := json.Marshal(respJSON3)
  8304. fmt.Println("log")
  8305. fmt.Println(string(userJSONBytes3))
  8306. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8307. utils.ErrorLog("解析失败:%v", err)
  8308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8309. return
  8310. }
  8311. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8312. if err == nil {
  8313. c.ServeSuccessJSON(map[string]interface{}{
  8314. "msg": "撤销明细成功",
  8315. })
  8316. return
  8317. } else {
  8318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8319. return
  8320. }
  8321. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8322. var resSix10265 ResultSix10265
  8323. var api3 string
  8324. if miConfig.MdtrtareaAdmvs == "320921" {
  8325. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8326. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8327. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8328. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8329. } else {
  8330. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8331. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8332. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8333. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8334. }
  8335. resp3, requestErr3 := http.Get(api3)
  8336. if requestErr3 != nil {
  8337. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8338. return
  8339. }
  8340. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8341. if ioErr3 != nil {
  8342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8344. return
  8345. }
  8346. var respJSON3 map[string]interface{}
  8347. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8350. return
  8351. }
  8352. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8353. userJSONBytes3, _ := json.Marshal(respJSON3)
  8354. fmt.Println("log")
  8355. fmt.Println(string(userJSONBytes3))
  8356. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8357. utils.ErrorLog("解析失败:%v", err)
  8358. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8359. return
  8360. }
  8361. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8362. res2.Output = resSix10265.Output
  8363. res2.ErrMsg = resSix10265.ErrMsg
  8364. res2.Cainfo = resSix10265.Cainfo
  8365. res2.WarnMsg = resSix10265.WarnMsg
  8366. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8367. res2.Infcode = infocode
  8368. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8369. if err == nil {
  8370. c.ServeSuccessJSON(map[string]interface{}{
  8371. "msg": "撤销明细成功",
  8372. })
  8373. return
  8374. } else {
  8375. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8376. return
  8377. }
  8378. } else {
  8379. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8380. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8381. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8382. resp2, requestErr2 := http.Get(api2)
  8383. if requestErr2 != nil {
  8384. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8385. return
  8386. }
  8387. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8388. if ioErr2 != nil {
  8389. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8390. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8391. return
  8392. }
  8393. var respJSON2 map[string]interface{}
  8394. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8395. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8397. return
  8398. }
  8399. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8400. if err == nil {
  8401. c.ServeSuccessJSON(map[string]interface{}{
  8402. "msg": "撤销明细成功",
  8403. })
  8404. return
  8405. } else {
  8406. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8407. return
  8408. }
  8409. }
  8410. } else {
  8411. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8412. if err == nil {
  8413. c.ServeSuccessJSON(map[string]interface{}{
  8414. "msg": "退费成功",
  8415. })
  8416. } else {
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. }
  8421. }
  8422. //对账
  8423. func (c *HisApiController) GetCheckAccount() {
  8424. start_time := c.GetString("start_time")
  8425. end_time := c.GetString("end_time")
  8426. insutype := c.GetString("insutype")
  8427. clr_type := c.GetString("clr_type")
  8428. clr_org := c.GetString("clr_optins")
  8429. admin_user_id, _ := c.GetInt64("admin_user_id")
  8430. adminUser := c.GetAdminUserInfo()
  8431. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8432. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8433. if len(clr_org) == 0 {
  8434. clr_org = miConfig.MdtrtareaAdmvs
  8435. }
  8436. timeLayout := "2006-01-02"
  8437. loc, _ := time.LoadLocation("Local")
  8438. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8439. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8440. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8441. fixmedins_setl_cnt := int64(len(orders))
  8442. var medfee_sumamt float64
  8443. var acct_pay float64
  8444. var fund_pay_sumamt float64
  8445. for _, item := range orders {
  8446. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8447. acct_pay = acct_pay + item.AcctPay
  8448. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8449. }
  8450. var user_name string
  8451. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8452. if role.ID == 0 {
  8453. user_name = "xxx"
  8454. } else {
  8455. user_name = role.UserName
  8456. }
  8457. var res ResultEight
  8458. var res10188 ResultEightFor10188
  8459. if config.IsOpen == 1 {
  8460. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8461. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8462. "insutype=" + insutype +
  8463. "&clr_type=" + clr_type +
  8464. "&setl_optins=" + clr_org +
  8465. "&stmt_begndate=" + start_time +
  8466. "&stm_enddate=" + end_time +
  8467. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8468. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8469. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8470. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8471. "&fixmedins_code=" + miConfig.Code +
  8472. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8473. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8474. "&secret_key=" + miConfig.SecretKey +
  8475. "&org_name=" + miConfig.OrgName +
  8476. "&doctor=" + user_name +
  8477. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8478. fmt.Println(api)
  8479. resp, requestErr := http.Get(api)
  8480. if requestErr != nil {
  8481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8482. return
  8483. }
  8484. body, ioErr := ioutil.ReadAll(resp.Body)
  8485. fmt.Println(body)
  8486. if ioErr != nil {
  8487. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8489. return
  8490. }
  8491. var respJSON map[string]interface{}
  8492. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8493. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8494. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8495. return
  8496. }
  8497. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8498. userJSONBytes, _ := json.Marshal(respJSON)
  8499. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8500. utils.ErrorLog("解析失败:%v", err)
  8501. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8502. return
  8503. }
  8504. res.InfRefmsgid = res10188.InfRefmsgid
  8505. res.Output = res10188.Output
  8506. res.ErrMsg = res10188.ErrMsg
  8507. res.Cainfo = res10188.Cainfo
  8508. res.WarnMsg = res10188.WarnMsg
  8509. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8510. res.Infcode = infocode
  8511. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8512. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8513. "insutype=" + insutype +
  8514. "&clr_type=" + clr_type +
  8515. "&setl_optins=" + clr_org +
  8516. "&stmt_begndate=" + start_time +
  8517. "&stm_enddate=" + end_time +
  8518. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8519. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8520. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8521. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8522. "&fixmedins_code=" + miConfig.Code +
  8523. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8524. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8525. "&secret_key=" + miConfig.SecretKey +
  8526. "&org_name=" + miConfig.OrgName +
  8527. "&doctor=" + user_name
  8528. resp, requestErr := http.Get(api)
  8529. if requestErr != nil {
  8530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8531. return
  8532. }
  8533. body, ioErr := ioutil.ReadAll(resp.Body)
  8534. if ioErr != nil {
  8535. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8537. return
  8538. }
  8539. var respJSON map[string]interface{}
  8540. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8541. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8546. result, _ := json.Marshal(respJSON)
  8547. fmt.Println("log")
  8548. fmt.Println(string(result))
  8549. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8550. utils.ErrorLog("解析失败:%v", err)
  8551. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8552. return
  8553. }
  8554. res.InfRefmsgid = res10188.InfRefmsgid
  8555. res.Output = res10188.Output
  8556. res.ErrMsg = res10188.ErrMsg
  8557. res.Cainfo = res10188.Cainfo
  8558. res.WarnMsg = res10188.WarnMsg
  8559. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8560. res.Infcode = infocode
  8561. } else {
  8562. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8563. "insutype=" + insutype +
  8564. "&clr_type=" + clr_type +
  8565. "&setl_optins=" + clr_org +
  8566. "&stmt_begndate=" + start_time +
  8567. "&stm_enddate=" + end_time +
  8568. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8569. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8570. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8571. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8572. "&fixmedins_code=" + miConfig.Code +
  8573. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8574. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8575. "&secret_key=" + miConfig.SecretKey +
  8576. "&org_name=" + miConfig.OrgName +
  8577. "&doctor=" + user_name
  8578. fmt.Println(api)
  8579. resp, requestErr := http.Get(api)
  8580. if requestErr != nil {
  8581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8582. return
  8583. }
  8584. body, ioErr := ioutil.ReadAll(resp.Body)
  8585. fmt.Println(body)
  8586. if ioErr != nil {
  8587. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. var respJSON map[string]interface{}
  8592. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8593. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8595. return
  8596. }
  8597. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8598. userJSONBytes, _ := json.Marshal(respJSON)
  8599. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8600. utils.ErrorLog("解析失败:%v", err)
  8601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8602. return
  8603. }
  8604. }
  8605. if res.Infcode == 0 {
  8606. if res.Output.Stmtinfo.StmtRslt == "0" {
  8607. micc := &models.MedicalInsuranceCostCompare{
  8608. StartTime: startime.Unix(),
  8609. EndTime: endtime.Unix(),
  8610. Insutype: insutype,
  8611. CheckType: 1,
  8612. Num: fixmedins_setl_cnt,
  8613. Mtime: time.Now().Unix(),
  8614. Status: 1,
  8615. UserOrgId: adminUser.CurrentOrgId,
  8616. CostTotal: medfee_sumamt,
  8617. FuncTotal: fund_pay_sumamt,
  8618. PsnPay: acct_pay,
  8619. Creator: admin_user_id,
  8620. Ctime: time.Now().Unix(),
  8621. ClrType: clr_type,
  8622. }
  8623. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8624. if err == nil {
  8625. c.ServeSuccessJSON(map[string]interface{}{
  8626. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8627. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8628. })
  8629. } else {
  8630. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8631. }
  8632. } else {
  8633. c.ServeSuccessJSON(map[string]interface{}{
  8634. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8635. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8636. })
  8637. }
  8638. } else {
  8639. c.ServeSuccessJSON(map[string]interface{}{
  8640. "code": -10,
  8641. "msg": res.ErrMsg,
  8642. })
  8643. }
  8644. }
  8645. }
  8646. func (c *HisApiController) Check310() {
  8647. adminUser := c.GetAdminUserInfo()
  8648. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8649. var user_name string
  8650. user_name = "高慧裕"
  8651. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8652. "insutype=" + "310" +
  8653. "&clr_type=" + "" +
  8654. "&setl_optins=" + "441202" +
  8655. "&stmt_begndate=" + "2022-03-01" +
  8656. "&stm_enddate=" + "2022-03-31" +
  8657. "&medfee_sumamt=" + "194930.12" +
  8658. "&fund_pay_sumamt=" + "188741.46" +
  8659. "&acct_pay=" + "0" +
  8660. "&fixmedins_setl_cnt=" + "452" +
  8661. "&fixmedins_code=" + miConfig.Code +
  8662. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8663. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8664. "&secret_key=" + miConfig.SecretKey +
  8665. "&org_name=" + miConfig.OrgName +
  8666. "&doctor=" + user_name
  8667. fmt.Println(api)
  8668. resp, requestErr := http.Get(api)
  8669. if requestErr != nil {
  8670. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8671. return
  8672. }
  8673. body, ioErr := ioutil.ReadAll(resp.Body)
  8674. fmt.Println(body)
  8675. if ioErr != nil {
  8676. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8678. return
  8679. }
  8680. var respJSON map[string]interface{}
  8681. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8682. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8683. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8684. return
  8685. }
  8686. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8687. userJSONBytes, _ := json.Marshal(respJSON)
  8688. var res ResultEight
  8689. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8690. utils.ErrorLog("解析失败:%v", err)
  8691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8692. return
  8693. }
  8694. }
  8695. func (c *HisApiController) Check390() {
  8696. adminUser := c.GetAdminUserInfo()
  8697. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8698. var user_name string
  8699. user_name = "高慧裕"
  8700. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8701. "insutype=" + "390" +
  8702. "&clr_type=" + "" +
  8703. "&setl_optins=" + "441202" +
  8704. "&stmt_begndate=" + "2022-03-01" +
  8705. "&stm_enddate=" + "2022-03-31" +
  8706. "&medfee_sumamt=" + "1068448.89" +
  8707. "&fund_pay_sumamt=" + "1014677.62" +
  8708. "&acct_pay=" + "0" +
  8709. "&fixmedins_setl_cnt=" + "1950" +
  8710. "&fixmedins_code=" + miConfig.Code +
  8711. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8712. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8713. "&secret_key=" + miConfig.SecretKey +
  8714. "&org_name=" + miConfig.OrgName +
  8715. "&doctor=" + user_name
  8716. fmt.Println(api)
  8717. resp, requestErr := http.Get(api)
  8718. if requestErr != nil {
  8719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8720. return
  8721. }
  8722. body, ioErr := ioutil.ReadAll(resp.Body)
  8723. fmt.Println(body)
  8724. if ioErr != nil {
  8725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8727. return
  8728. }
  8729. var respJSON map[string]interface{}
  8730. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8733. return
  8734. }
  8735. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8736. userJSONBytes, _ := json.Marshal(respJSON)
  8737. var res ResultEight
  8738. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8739. utils.ErrorLog("解析失败:%v", err)
  8740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8741. return
  8742. }
  8743. }
  8744. //对账明细
  8745. func (c *HisApiController) GetCheckDetailAccount() {
  8746. start_time := c.GetString("start_time")
  8747. end_time := c.GetString("end_time")
  8748. admin_user_id, _ := c.GetInt64("admin_user_id")
  8749. adminUser := c.GetAdminUserInfo()
  8750. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8751. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  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.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8757. rand.Seed(time.Now().UnixNano())
  8758. num := rand.Intn(30000)
  8759. Mkdir(miConfig.OrgName)
  8760. file := strconv.FormatInt(int64(num), 10)
  8761. file_name := file + ".txt"
  8762. zip_name := file + ".zip"
  8763. zip_path := miConfig.OrgName + "/" + zip_name
  8764. file_path := miConfig.OrgName + "/" + file_name
  8765. decimal.DivisionPrecision = 2
  8766. var medfee_sumamt float64
  8767. var psn_cash_pay float64
  8768. var fund_pay_sumamt float64
  8769. fixmedins_setl_cnt := int64(len(orders))
  8770. for _, item := range orders {
  8771. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8772. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8773. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8774. }
  8775. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8776. defer f.Close()
  8777. if err != nil {
  8778. fmt.Println(err.Error())
  8779. } else {
  8780. for _, item := range orders {
  8781. var refd_setl_flag string
  8782. if item.OrderStatus == 2 {
  8783. refd_setl_flag = "0"
  8784. var str string
  8785. str = item.SetlId + " " +
  8786. item.MdtrtId + " " +
  8787. item.PsnNo + " " +
  8788. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8789. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8790. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8791. _, err = f.Write([]byte(str))
  8792. }
  8793. if item.OrderStatus == 3 {
  8794. var str string
  8795. str = item.SetlId + " " +
  8796. item.MdtrtId + " " +
  8797. item.PsnNo + " " +
  8798. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8799. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8800. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8801. _, err = f.Write([]byte(str))
  8802. var str2 string
  8803. str2 = item.SetlId + " " +
  8804. item.MdtrtId + " " +
  8805. item.PsnNo + " " +
  8806. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8807. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8808. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8809. _, err = f.Write([]byte(str2))
  8810. }
  8811. }
  8812. }
  8813. Zip(file_path, zip_path)
  8814. fmt.Println(ReadFile(zip_path))
  8815. fmt.Println(string(ReadFile(zip_path)))
  8816. if config.IsOpen == 1 {
  8817. var user_name string
  8818. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8819. if role.ID == 0 {
  8820. user_name = "管理员"
  8821. } else {
  8822. user_name = role.UserName
  8823. }
  8824. baseParams := models.BaseParams{
  8825. SecretKey: miConfig.SecretKey,
  8826. FixmedinsCode: miConfig.Code,
  8827. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8828. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8829. OrgName: miConfig.OrgName,
  8830. Doctor: user_name,
  8831. }
  8832. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8833. var dat map[string]interface{}
  8834. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8835. fmt.Println(dat)
  8836. } else {
  8837. fmt.Println(err)
  8838. }
  8839. userJSONBytes, _ := json.Marshal(dat)
  8840. var res ResultNine
  8841. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8842. utils.ErrorLog("解析失败:%v", err)
  8843. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8844. return
  8845. }
  8846. if res.Infcode == 0 {
  8847. fileNo := res.Output.FileQuryNo
  8848. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8849. "file_qury_no=" + fileNo +
  8850. "&setl_optins=" + "定点医保中心" +
  8851. "&stmt_begndate=" + start_time +
  8852. "&stm_enddate=" + end_time +
  8853. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8854. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8855. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8856. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8857. "&fixmedins_code=" + miConfig.Code +
  8858. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8859. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8860. "&secret_key=" + miConfig.SecretKey +
  8861. "&org_name=" + miConfig.OrgName +
  8862. "&doctor=" + user_name
  8863. resp, requestErr := http.Get(api)
  8864. if requestErr != nil {
  8865. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8866. return
  8867. }
  8868. body, ioErr := ioutil.ReadAll(resp.Body)
  8869. if ioErr != nil {
  8870. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8871. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8872. return
  8873. }
  8874. var respJSON map[string]interface{}
  8875. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8876. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8877. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8878. return
  8879. }
  8880. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8881. userJSONBytes, _ := json.Marshal(respJSON)
  8882. var res ResultTen
  8883. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8884. utils.ErrorLog("解析失败:%v", err)
  8885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8886. return
  8887. }
  8888. if res.Infcode == 0 {
  8889. service.Gdyb9102(baseParams, zip_name, fileNo)
  8890. micc := &models.MedicalInsuranceCostCompare{
  8891. StartTime: startime.Unix(),
  8892. EndTime: endtime.Unix(),
  8893. Insutype: "0",
  8894. CheckType: 2,
  8895. Num: fixmedins_setl_cnt,
  8896. Mtime: time.Now().Unix(),
  8897. Status: 1,
  8898. UserOrgId: adminUser.CurrentOrgId,
  8899. CostTotal: medfee_sumamt,
  8900. FuncTotal: fund_pay_sumamt,
  8901. PsnPay: psn_cash_pay,
  8902. Creator: admin_user_id,
  8903. Ctime: time.Now().Unix(),
  8904. }
  8905. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8906. c.ServeSuccessJSON(map[string]interface{}{
  8907. "msg": "明细对账成功",
  8908. })
  8909. }
  8910. } else {
  8911. }
  8912. }
  8913. }
  8914. type CustomOrderInfo struct {
  8915. Name string
  8916. Spec string
  8917. Unit string
  8918. Count float64
  8919. Price float64
  8920. Total float64
  8921. }
  8922. func (c *HisApiController) GetSettleAccounts() {
  8923. //id, _ := c.GetInt64("id")
  8924. //record_time := c.GetString("record_time")
  8925. order_id, _ := c.GetInt64("order_id")
  8926. admin_user_id, _ := c.GetInt64("admin_user_id")
  8927. //timeLayout := "2006-01-02"
  8928. //loc, _ := time.LoadLocation("Local")
  8929. //
  8930. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8931. //if err != nil {
  8932. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8933. // return
  8934. //}
  8935. //recordDateTime := theTime.Unix()
  8936. adminUser := c.GetAdminUserInfo()
  8937. order, _ := service.GetHisOrderByID(order_id)
  8938. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8939. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8940. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8941. orderInfos = append(orderInfos, orderInfos_two...)
  8942. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8943. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8944. var diagnosis_ids []string
  8945. if his.ID > 0 {
  8946. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8947. } else {
  8948. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8949. }
  8950. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8951. var dia_config []*models.HisXtDiagnoseConfig
  8952. var name string
  8953. for _, item := range diagnosis_ids {
  8954. id, _ := strconv.ParseInt(item, 10, 64)
  8955. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8956. dia_config = append(dia_config, &diagnosisConfig)
  8957. if len(name) == 0 {
  8958. name = diagnosisConfig.ClassName
  8959. } else {
  8960. name = name + "," + diagnosisConfig.ClassName
  8961. }
  8962. }
  8963. var bedCostTotal float64 = 0 //床位总费
  8964. var bedCostSelfTotal float64 = 0 //床位自费
  8965. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8966. var operationCostTotal float64 = 0 //手术费
  8967. var operationCostSelfTotal float64 = 0 //手术费
  8968. var operationCostPartSelfTotal float64 = 0 //手术费
  8969. var otherCostTotal float64 = 0 //其他费用
  8970. var otherCostSelfTotal float64 = 0 //其他费用
  8971. var otherCostPartSelfTotal float64 = 0 //其他费用
  8972. var materialCostTotal float64 = 0 //材料费
  8973. var materialCostSelfTotal float64 = 0 //材料费
  8974. var materialCostPartSelfTotal float64 = 0 //材料费
  8975. var westernMedicineCostTotal float64 = 0 //西药费
  8976. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8977. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8978. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8979. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8980. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8981. var checkCostTotal float64 = 0 //检查费
  8982. var checkCostSelfTotal float64 = 0 //检查费
  8983. var checkCostPartSelfTotal float64 = 0 //检查费
  8984. var laboratoryCostTotal float64 = 0 //化验费
  8985. var laboratoryCostSelfTotal float64 = 0 //化验费
  8986. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8987. var treatCostTotal float64 = 0 //治疗费用
  8988. var treatCostSelfTotal float64 = 0 //治疗费用
  8989. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8990. decimal.DivisionPrecision = 2
  8991. for _, item := range orderInfos {
  8992. if item.MedChrgitmType == "01" { //床位费
  8993. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8994. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8995. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8996. }
  8997. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8998. if item.MedChrgitmType == "03" { //检查费
  8999. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9000. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9001. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9002. }
  9003. } else {
  9004. if item.MedChrgitmType == "03" { //检查费
  9005. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9006. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9007. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9008. }
  9009. }
  9010. if item.MedChrgitmType == "04" { //化验费
  9011. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9012. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9013. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9014. }
  9015. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9016. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9017. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9018. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9019. }
  9020. if item.MedChrgitmType == "06" { //手术费
  9021. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9022. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9023. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9024. }
  9025. if item.MedChrgitmType == "08" { //材料费
  9026. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9027. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9028. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9029. }
  9030. if item.MedChrgitmType == "09" { //西药费
  9031. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9032. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9033. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9034. }
  9035. if item.MedChrgitmType == "11" { //中成费
  9036. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9037. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9038. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9039. }
  9040. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9041. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9042. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9043. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9044. }
  9045. }
  9046. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9047. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9048. var user_name string
  9049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9050. if role.ID == 0 {
  9051. user_name = "管理员"
  9052. } else {
  9053. user_name = role.UserName
  9054. }
  9055. baseParams := models.BaseParams{
  9056. SecretKey: miConfig.SecretKey,
  9057. FixmedinsCode: miConfig.Code,
  9058. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9059. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9060. OrgName: miConfig.OrgName,
  9061. Doctor: user_name,
  9062. }
  9063. businessParams := models.BusinessParams{
  9064. PsnNo: order.PsnNo,
  9065. MdtrtId: order.MdtrtId,
  9066. SetlId: order.SetlId,
  9067. }
  9068. var res ResultEleven
  9069. var resEleven10265 ResultEleven10265
  9070. if config.IsOpen == 1 {
  9071. if miConfig.MdtrtareaAdmvs == "421300" {
  9072. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9073. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9074. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9075. resp, requestErr := http.Get(api)
  9076. if requestErr != nil {
  9077. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9078. return
  9079. }
  9080. body, ioErr := ioutil.ReadAll(resp.Body)
  9081. if ioErr != nil {
  9082. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9084. return
  9085. }
  9086. var respJSON map[string]interface{}
  9087. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9088. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9089. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9090. return
  9091. }
  9092. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9093. result, _ := json.Marshal(respJSON)
  9094. fmt.Println("log")
  9095. fmt.Println(string(result))
  9096. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9097. utils.ErrorLog("解析失败:%v", err)
  9098. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9099. return
  9100. }
  9101. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9102. var api string
  9103. if miConfig.MdtrtareaAdmvs == "320921" {
  9104. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9105. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9106. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9107. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9108. } else {
  9109. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9110. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9111. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9112. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9113. }
  9114. resp, requestErr := http.Get(api)
  9115. if requestErr != nil {
  9116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9117. return
  9118. }
  9119. body, ioErr := ioutil.ReadAll(resp.Body)
  9120. if ioErr != nil {
  9121. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9123. return
  9124. }
  9125. var respJSON map[string]interface{}
  9126. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9127. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9128. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9129. return
  9130. }
  9131. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9132. result, _ := json.Marshal(respJSON)
  9133. fmt.Println("log")
  9134. fmt.Println(string(result))
  9135. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9136. utils.ErrorLog("解析失败:%v", err)
  9137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9138. return
  9139. }
  9140. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9141. res.Output = resEleven10265.Output
  9142. res.ErrMsg = resEleven10265.ErrMsg
  9143. res.Cainfo = resEleven10265.Cainfo
  9144. res.WarnMsg = resEleven10265.WarnMsg
  9145. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9146. res.Infcode = infocode
  9147. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9148. fmt.Println("~~~~~~~")
  9149. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9150. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9151. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9152. resp, requestErr := http.Get(api)
  9153. if requestErr != nil {
  9154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9155. return
  9156. }
  9157. body, ioErr := ioutil.ReadAll(resp.Body)
  9158. if ioErr != nil {
  9159. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9161. return
  9162. }
  9163. var respJSON map[string]interface{}
  9164. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9165. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9167. return
  9168. }
  9169. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9170. result, _ := json.Marshal(respJSON)
  9171. fmt.Println("log")
  9172. fmt.Println(string(result))
  9173. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9174. utils.ErrorLog("解析失败:%v", err)
  9175. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9176. return
  9177. }
  9178. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9179. res.Output = resEleven10265.Output
  9180. res.ErrMsg = resEleven10265.ErrMsg
  9181. res.Cainfo = resEleven10265.Cainfo
  9182. res.WarnMsg = resEleven10265.WarnMsg
  9183. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9184. res.Infcode = infocode
  9185. } else {
  9186. result := service.Gdyb5203(baseParams, businessParams)
  9187. //service.Gdyb5204(baseParams, businessParams)
  9188. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9189. var dat map[string]interface{}
  9190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9191. fmt.Println(dat)
  9192. } else {
  9193. fmt.Println(err)
  9194. }
  9195. userJSONBytes, _ := json.Marshal(dat)
  9196. if miConfig.Code == "H15049901371" {
  9197. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9198. utils.ErrorLog("解析失败:%v", err)
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9203. res.Output = resEleven10265.Output
  9204. res.ErrMsg = resEleven10265.ErrMsg
  9205. res.Cainfo = resEleven10265.Cainfo
  9206. res.WarnMsg = resEleven10265.WarnMsg
  9207. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9208. res.Infcode = infocode
  9209. } else {
  9210. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9211. utils.ErrorLog("解析失败:%v", err)
  9212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9213. return
  9214. }
  9215. }
  9216. }
  9217. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9218. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9219. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9220. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9221. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9222. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9223. var doctor_name string
  9224. if roles.ID == 0 {
  9225. doctor_name = "管理员"
  9226. } else {
  9227. doctor_name = roles.UserName
  9228. }
  9229. yiliao_leibie := ""
  9230. switch order.MedType {
  9231. case "11":
  9232. yiliao_leibie = "普通门诊"
  9233. break
  9234. case "12":
  9235. yiliao_leibie = "门诊挂号"
  9236. break
  9237. case "13":
  9238. yiliao_leibie = "急诊"
  9239. break
  9240. case "14":
  9241. yiliao_leibie = "门诊特殊病"
  9242. break
  9243. case "15":
  9244. yiliao_leibie = "门诊统筹"
  9245. break
  9246. case "16":
  9247. yiliao_leibie = "门诊慢性病"
  9248. break
  9249. case "21":
  9250. yiliao_leibie = "普通住院"
  9251. break
  9252. }
  9253. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9254. if res.Infcode == 0 {
  9255. c.ServeSuccessJSON(map[string]interface{}{
  9256. "diagnosis": name,
  9257. "order_infos": orderInfos,
  9258. "number": order.MdtrtId,
  9259. "date": order.SettleAccountsDate,
  9260. "charge_admin": charge_admin,
  9261. "printor_admin": printor_admin,
  9262. "info": res.Output.Setlinfo,
  9263. "order": order,
  9264. "bedCostTotal": bedCostTotal,
  9265. "bedCostSelfTotal": bedCostSelfTotal,
  9266. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9267. "operationCostTotal": operationCostTotal,
  9268. "operationCostSelfTotal": operationCostSelfTotal,
  9269. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9270. "otherCostTotal": otherCostTotal,
  9271. "otherCostSelfTotal": otherCostSelfTotal,
  9272. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9273. "materialCostTotal": materialCostTotal,
  9274. "materialCostSelfTotal": materialCostSelfTotal,
  9275. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9276. "westernMedicineCostTotal": westernMedicineCostTotal,
  9277. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9278. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9279. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9280. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9281. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9282. "checkCostTotal": checkCostTotal,
  9283. "checkCostSelfTotal": checkCostSelfTotal,
  9284. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9285. "laboratoryCostTotal": laboratoryCostTotal,
  9286. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9287. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9288. "treatCostTotal": treatCostTotal,
  9289. "treatCostSelfTotal": treatCostSelfTotal,
  9290. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9291. "doctor_info": doctor_info,
  9292. "doctor_code": adminRole_two.DoctorCode,
  9293. "doctor_name": doctor_name,
  9294. "health_card_no": order.PsnNo,
  9295. "department": departments.Name,
  9296. "yiliao_leibie": yiliao_leibie,
  9297. "after_money": order.AccountPrice,
  9298. "patient": patient,
  9299. "org_name": miConfig.OrgName,
  9300. "org_code": miConfig.Code,
  9301. "order_number": order.Number,
  9302. "his_hospital": his_hospital,
  9303. "his": his,
  9304. "dia_config": dia_config,
  9305. //"check_order_info": cus_slice,
  9306. })
  9307. }
  9308. }
  9309. }
  9310. func (c *HisApiController) CheckTreatment() {
  9311. patient_id, _ := c.GetInt64("patient_id")
  9312. id_card_no := c.GetString("id_card_no")
  9313. insutype := c.GetString("insutype")
  9314. med_type := c.GetString("med_type")
  9315. admin_user_id, _ := c.GetInt64("admin_user_id")
  9316. adminUser := c.GetAdminUserInfo()
  9317. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9318. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9319. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9320. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9321. if miConfig.MdtrtareaAdmvs == "421300" {
  9322. var res ResultTwo
  9323. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9324. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9325. "&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)
  9326. resp, requestErr := http.Get(api)
  9327. if requestErr != nil {
  9328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9329. return
  9330. }
  9331. body, ioErr := ioutil.ReadAll(resp.Body)
  9332. if ioErr != nil {
  9333. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9335. return
  9336. }
  9337. var respJSON map[string]interface{}
  9338. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9339. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9340. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9341. return
  9342. }
  9343. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9344. result, _ := json.Marshal(respJSON)
  9345. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9346. utils.ErrorLog("解析失败:%v", err)
  9347. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9348. return
  9349. }
  9350. if res.Infcode == 0 {
  9351. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9352. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9353. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9354. resp, requestErr := http.Get(api)
  9355. if requestErr != nil {
  9356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9357. return
  9358. }
  9359. body, ioErr := ioutil.ReadAll(resp.Body)
  9360. if ioErr != nil {
  9361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9363. return
  9364. }
  9365. var respJSON map[string]interface{}
  9366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9369. return
  9370. }
  9371. var res Result2001
  9372. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9373. result2, _ := json.Marshal(respJSON)
  9374. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9375. utils.ErrorLog("解析失败:%v", err)
  9376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9377. return
  9378. }
  9379. if res.Infcode == 0 {
  9380. c.ServeSuccessJSON(map[string]interface{}{
  9381. "msg": res.Output.Trtinfo,
  9382. })
  9383. }
  9384. } else {
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9386. return
  9387. }
  9388. } else {
  9389. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9390. var dat map[string]interface{}
  9391. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9392. fmt.Println(dat)
  9393. } else {
  9394. fmt.Println(err)
  9395. }
  9396. userJSONBytes, _ := json.Marshal(dat)
  9397. var res ResultTwo
  9398. var res10265 ResultTwo10265
  9399. if miConfig.Code == "H15049901371" {
  9400. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9401. utils.ErrorLog("解析失败:%v", err)
  9402. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9403. return
  9404. }
  9405. res.ErrMsg = res10265.ErrMsg
  9406. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9407. res.Infcode = infocode
  9408. res.Output = res10265.Output
  9409. res.InfRefmsgid = res10265.InfRefmsgid
  9410. } else {
  9411. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9412. utils.ErrorLog("解析失败:%v", err)
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. }
  9417. var user_name string
  9418. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9419. if role.ID == 0 {
  9420. user_name = "xxx"
  9421. } else {
  9422. user_name = role.UserName
  9423. }
  9424. baseParams := models.BaseParams{
  9425. SecretKey: miConfig.SecretKey,
  9426. FixmedinsCode: miConfig.Code,
  9427. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9428. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9429. OrgName: miConfig.OrgName,
  9430. Doctor: user_name,
  9431. }
  9432. if config.IsOpen == 1 {
  9433. if miConfig.Code == "H15049901371" {
  9434. if med_type == "14" {
  9435. if insutype == "390" {
  9436. med_type = "9933"
  9437. } else if insutype == "310" {
  9438. med_type = "990502"
  9439. }
  9440. } else if med_type == "11" {
  9441. med_type = "11"
  9442. }
  9443. }
  9444. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9445. var dat map[string]interface{}
  9446. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9447. fmt.Println(dat)
  9448. } else {
  9449. fmt.Println(err)
  9450. }
  9451. var res Result2001
  9452. var res10265 Result2001Org10265
  9453. if miConfig.Code == "H15049901371" {
  9454. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9455. utils.ErrorLog("解析失败:%v", err)
  9456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9457. return
  9458. }
  9459. res.ErrMsg = res10265.ErrMsg
  9460. res.Output = res10265.Output
  9461. res.InfRefmsgid = res10265.InfRefmsgid
  9462. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9463. res.Infcode = infocode
  9464. } else {
  9465. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9466. utils.ErrorLog("解析失败:%v", err)
  9467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9468. return
  9469. }
  9470. }
  9471. if res.Infcode == 0 {
  9472. c.ServeSuccessJSON(map[string]interface{}{
  9473. "msg": res.Output.Trtinfo,
  9474. })
  9475. }
  9476. }
  9477. }
  9478. }
  9479. //func (c *HisApiController) PutRecord() {
  9480. // id, _ := c.GetInt64("id")
  9481. // record_time := c.GetString("record_time")
  9482. // timeLayout := "2006-01-02"
  9483. // loc, _ := time.LoadLocation("Local")
  9484. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9485. // if err != nil {
  9486. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9487. // return
  9488. // }
  9489. // recordDateTime := theTime.Unix()
  9490. //
  9491. // adminInfo := c.GetAdminUserInfo()
  9492. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9493. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9494. //
  9495. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9496. //
  9497. // fmt.Println(miConfig.SecretKey)
  9498. //
  9499. // if patient == nil {
  9500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9501. // return
  9502. // }
  9503. // if len(patient.IdCardNo) == 0 {
  9504. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9505. // return
  9506. // }
  9507. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9508. // if config.IsOpen == 1 {
  9509. // 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
  9510. // resp, requestErr := http.Get(api)
  9511. // if requestErr != nil {
  9512. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9513. // return
  9514. // }
  9515. // defer resp.Body.Close()
  9516. // body, ioErr := ioutil.ReadAll(resp.Body)
  9517. // if ioErr != nil {
  9518. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9519. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9520. // return
  9521. // }
  9522. // var respJSON map[string]interface{}
  9523. //
  9524. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9525. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9526. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9527. // return
  9528. // }
  9529. //
  9530. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9531. // userJSONBytes, _ := json.Marshal(userJSON)
  9532. // var res ResultTwo
  9533. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9534. // utils.ErrorLog("解析失败:%v", err)
  9535. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9536. // return
  9537. // }
  9538. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9539. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9540. // infoStr := string(Iinfos)
  9541. // idetinfoStr := string(Idetinfos)
  9542. //
  9543. // if res.Infcode == 0 {
  9544. // his := models.VMHisPatient{
  9545. // Status: 1,
  9546. // Ctime: time.Now().Unix(),
  9547. // Mtime: time.Now().Unix(),
  9548. // PsnNo: res.Output.Baseinfo.PsnNo,
  9549. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9550. // Certno: res.Output.Baseinfo.Certno,
  9551. // PsnName: res.Output.Baseinfo.PsnName,
  9552. // Gend: res.Output.Baseinfo.Gend,
  9553. // Naty: res.Output.Baseinfo.Naty,
  9554. // Brdy: res.Output.Baseinfo.Brdy,
  9555. // Age: res.Output.Baseinfo.Age,
  9556. // Iinfo: infoStr,
  9557. // Idetinfo: idetinfoStr,
  9558. // PatientId: patient.ID,
  9559. // RecordDate: theTime.Unix(),
  9560. // UserOrgId: adminInfo.CurrentOrgId,
  9561. // AdminUserId: adminInfo.AdminUser.Id,
  9562. // IsReturn: 1,
  9563. // }
  9564. //
  9565. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9566. // //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")
  9567. // //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")
  9568. //
  9569. // //var dat map[string]interface{}
  9570. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9571. // // fmt.Println(dat)
  9572. // //} else {
  9573. // // fmt.Println(err)
  9574. // //}
  9575. //
  9576. // var dat2 map[string]interface{}
  9577. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9578. // fmt.Println(dat2)
  9579. // } else {
  9580. // fmt.Println(err)
  9581. // }
  9582. //
  9583. // } else {
  9584. // adminUser := c.GetAdminUserInfo()
  9585. // errlog := &models.HisOrderError{
  9586. // UserOrgId: adminUser.CurrentOrgId,
  9587. // Ctime: time.Now().Unix(),
  9588. // Mtime: time.Now().Unix(),
  9589. // ErrMsg: res.ErrMsg,
  9590. // Status: 1,
  9591. // PatientId: id,
  9592. // RecordTime: recordDateTime,
  9593. // Stage: 1,
  9594. // }
  9595. // service.CreateErrMsgLog(errlog)
  9596. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9597. // return
  9598. // }
  9599. // }
  9600. //
  9601. //}
  9602. //func (c *HisApiController) GetUploadDiag() {
  9603. // id, _ := c.GetInt64("id")
  9604. // record_time := c.GetString("record_time")
  9605. //
  9606. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9607. // sick_type, _ := c.GetInt64("sick_type")
  9608. // reg_type, _ := c.GetInt64("reg_type")
  9609. //
  9610. // timeLayout := "2006-01-02"
  9611. // loc, _ := time.LoadLocation("Local")
  9612. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9613. // if err != nil {
  9614. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9615. // return
  9616. // }
  9617. //
  9618. // var patientPrescription models.HisPrescriptionInfo
  9619. // recordDateTime := theTime.Unix()
  9620. // adminInfo := c.GetAdminUserInfo()
  9621. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9622. //
  9623. // if patientPrescription.ID == 0 {
  9624. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9625. // }
  9626. //
  9627. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9628. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9629. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9630. // sickConfig, _ := service.FindSickById(sick_type)
  9631. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9632. //
  9633. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9634. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9635. // "&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 +
  9636. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9637. // resp2, requestErr2 := http.Get(api2)
  9638. // if requestErr2 != nil {
  9639. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9640. // return
  9641. // }
  9642. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9643. // if ioErr2 != nil {
  9644. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9645. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9646. // return
  9647. // }
  9648. // var respJSON2 map[string]interface{}
  9649. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9650. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9651. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9652. // return
  9653. // }
  9654. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9655. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9656. //
  9657. // var res2 ResultSix
  9658. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9659. // utils.ErrorLog("解析失败:%v", err)
  9660. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9661. // return
  9662. // }
  9663. // if res2.Infcode != 0 {
  9664. // adminUser := c.GetAdminUserInfo()
  9665. // errlog := &models.HisOrderError{
  9666. // UserOrgId: adminUser.CurrentOrgId,
  9667. // Ctime: time.Now().Unix(),
  9668. // Mtime: time.Now().Unix(),
  9669. // ErrMsg: res2.ErrMsg,
  9670. // Status: 1,
  9671. // PatientId: id,
  9672. // RecordTime: recordDateTime,
  9673. // Stage: 3,
  9674. // }
  9675. // service.CreateErrMsgLog(errlog)
  9676. //
  9677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9678. // return
  9679. // }
  9680. //
  9681. // c.ServeSuccessJSON(map[string]interface{}{
  9682. // "msg": "上传成功",
  9683. // })
  9684. //
  9685. //}
  9686. type QueryResult struct {
  9687. ID int64
  9688. Name string
  9689. Code string
  9690. List_type_code string
  9691. }
  9692. func (c *HisApiController) GetCheckCode() {
  9693. ids_str := c.GetString("ids")
  9694. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9695. ids_arr := strings.Split(ids_str, ",")
  9696. var queryResult []QueryResult
  9697. ids := make([]int64, 0)
  9698. for _, item := range ids_arr {
  9699. id, _ := strconv.ParseInt(item, 10, 64)
  9700. ids = append(ids, id)
  9701. }
  9702. if record_type == 1 {
  9703. drugs, _ := service.GetBatchDrugList(ids)
  9704. for _, item := range drugs {
  9705. result := QueryResult{
  9706. ID: item.ID,
  9707. Name: item.DrugName,
  9708. Code: item.MedicalInsuranceNumber,
  9709. List_type_code: "101",
  9710. }
  9711. queryResult = append(queryResult, result)
  9712. }
  9713. } else if record_type == 2 {
  9714. goods, _ := service.GetBatchGoodInformationList(ids)
  9715. for _, item := range goods {
  9716. result := QueryResult{
  9717. ID: item.ID,
  9718. Name: item.GoodName,
  9719. Code: item.MedicalInsuranceNumber,
  9720. List_type_code: "301",
  9721. }
  9722. queryResult = append(queryResult, result)
  9723. }
  9724. } else if record_type == 3 {
  9725. projects, _ := service.GetBathchMyPorjecgList(ids)
  9726. for _, item := range projects {
  9727. result := QueryResult{
  9728. ID: item.ID,
  9729. Name: item.ProjectName,
  9730. Code: item.MedicalCode,
  9731. List_type_code: "201",
  9732. }
  9733. queryResult = append(queryResult, result)
  9734. }
  9735. }
  9736. admin_user_id, _ := c.GetInt64("admin_user_id")
  9737. adminUser := c.GetAdminUserInfo()
  9738. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9739. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9740. var user_name string
  9741. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9742. if role.ID == 0 {
  9743. user_name = "xxx"
  9744. } else {
  9745. user_name = role.UserName
  9746. }
  9747. baseParams := &models.BaseParams{
  9748. SecretKey: miConfig.SecretKey,
  9749. FixmedinsCode: miConfig.Code,
  9750. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9751. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9752. OrgName: miConfig.OrgName,
  9753. Doctor: user_name,
  9754. }
  9755. if config.IsOpen == 1 {
  9756. for _, item := range queryResult {
  9757. var result string
  9758. if record_type == 1 {
  9759. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9760. } else if record_type == 2 {
  9761. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9762. } else if record_type == 3 {
  9763. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9764. }
  9765. var dat map[string]interface{}
  9766. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9767. fmt.Println(dat)
  9768. } else {
  9769. fmt.Println(err)
  9770. }
  9771. userJSONBytes, _ := json.Marshal(dat)
  9772. var res ResultSix
  9773. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9774. utils.ErrorLog("解析失败:%v", err)
  9775. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9776. return
  9777. }
  9778. if res.Infcode == 0 {
  9779. if record_type == 1 {
  9780. service.UpdateBaseDrugById(item.ID)
  9781. } else if record_type == 2 {
  9782. service.UpdateGoodInformaitonByDetail(item.ID)
  9783. } else if record_type == 3 {
  9784. service.UpdateProjectById(item.ID)
  9785. }
  9786. c.ServeSuccessJSON(map[string]interface{}{
  9787. "failed_code": 0,
  9788. "msg": "目录对照成功",
  9789. })
  9790. } else {
  9791. c.ServeSuccessJSON(map[string]interface{}{
  9792. "failed_code": -10,
  9793. "msg": res.ErrMsg,
  9794. })
  9795. }
  9796. }
  9797. }
  9798. }
  9799. func (c *HisApiController) UnCheckCode() {
  9800. ids_str := c.GetString("ids")
  9801. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9802. admin_user_id, _ := c.GetInt64("admin_user_id")
  9803. ids_arr := strings.Split(ids_str, ",")
  9804. var queryResult []QueryResult
  9805. ids := make([]int64, 0)
  9806. for _, item := range ids_arr {
  9807. id, _ := strconv.ParseInt(item, 10, 64)
  9808. ids = append(ids, id)
  9809. }
  9810. if record_type == 1 {
  9811. drugs, _ := service.GetBatchDrugList(ids)
  9812. for _, item := range drugs {
  9813. result := QueryResult{
  9814. ID: item.ID,
  9815. Name: item.DrugName,
  9816. Code: item.MedicalInsuranceNumber,
  9817. List_type_code: "101",
  9818. }
  9819. queryResult = append(queryResult, result)
  9820. }
  9821. } else if record_type == 2 {
  9822. goods, _ := service.GetBatchGoodInformationList(ids)
  9823. for _, item := range goods {
  9824. result := QueryResult{
  9825. ID: item.ID,
  9826. Name: item.GoodName,
  9827. Code: item.MedicalInsuranceNumber,
  9828. List_type_code: "301",
  9829. }
  9830. queryResult = append(queryResult, result)
  9831. }
  9832. } else if record_type == 3 {
  9833. projects, _ := service.GetBathchMyPorjecgList(ids)
  9834. for _, item := range projects {
  9835. result := QueryResult{
  9836. ID: item.ID,
  9837. Name: item.ProjectName,
  9838. Code: item.MedicalCode,
  9839. List_type_code: "201",
  9840. }
  9841. queryResult = append(queryResult, result)
  9842. }
  9843. }
  9844. adminUser := c.GetAdminUserInfo()
  9845. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9846. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9847. var user_name string
  9848. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9849. if role.ID == 0 {
  9850. user_name = "xxx"
  9851. } else {
  9852. user_name = role.UserName
  9853. }
  9854. baseParams := &models.BaseParams{
  9855. SecretKey: miConfig.SecretKey,
  9856. FixmedinsCode: miConfig.Code,
  9857. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9858. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9859. OrgName: miConfig.OrgName,
  9860. Doctor: user_name,
  9861. }
  9862. if config.IsOpen == 1 {
  9863. for _, item := range queryResult {
  9864. var result string
  9865. if record_type == 1 {
  9866. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9867. } else if record_type == 2 {
  9868. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9869. } else if record_type == 3 {
  9870. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9871. }
  9872. var dat2 map[string]interface{}
  9873. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9874. fmt.Println(dat2)
  9875. } else {
  9876. fmt.Println(err)
  9877. }
  9878. userJSONBytes, _ := json.Marshal(dat2)
  9879. var res ResultSix
  9880. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9881. utils.ErrorLog("解析失败:%v", err)
  9882. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9883. return
  9884. }
  9885. if res.Infcode == 0 {
  9886. if record_type == 1 {
  9887. service.UpdateDrugByIdDetail(item.ID)
  9888. } else if record_type == 2 {
  9889. service.UpdateGoodInfoById(item.ID)
  9890. } else if record_type == 3 {
  9891. service.UpdateMyProjectById(item.ID)
  9892. }
  9893. c.ServeSuccessJSON(map[string]interface{}{
  9894. "failed_code": 0,
  9895. "msg": "撤销目录对照成功",
  9896. })
  9897. } else {
  9898. c.ServeSuccessJSON(map[string]interface{}{
  9899. "failed_code": -10,
  9900. "msg": res.ErrMsg,
  9901. })
  9902. }
  9903. }
  9904. }
  9905. }
  9906. func (c *HisApiController) GetPatientInfo() {
  9907. id_card_no := c.GetString("id_card_no")
  9908. admin_user_id, _ := c.GetInt64("admin_user_id")
  9909. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9910. if patient.ID == 0 {
  9911. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9912. return
  9913. }
  9914. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9915. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9916. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9917. if config.IsOpen == 1 {
  9918. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9919. var dat map[string]interface{}
  9920. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9921. fmt.Println(dat)
  9922. } else {
  9923. fmt.Println(err)
  9924. }
  9925. userJSONBytes, _ := json.Marshal(dat)
  9926. var res ResultTwo
  9927. var res10265 ResultTwo10265
  9928. if miConfig.Code == "H15049901371" {
  9929. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9930. utils.ErrorLog("解析失败:%v", err)
  9931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9932. return
  9933. }
  9934. res.ErrMsg = res10265.ErrMsg
  9935. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9936. res.Infcode = infocode
  9937. res.Output = res10265.Output
  9938. res.InfRefmsgid = res10265.InfRefmsgid
  9939. } else {
  9940. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9941. utils.ErrorLog("解析失败:%v", err)
  9942. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9943. return
  9944. }
  9945. }
  9946. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9947. // utils.ErrorLog("解析失败:%v", err)
  9948. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9949. // return
  9950. //}
  9951. if res.Infcode != 0 {
  9952. c.ServeSuccessJSON(map[string]interface{}{
  9953. "failed_code": -10,
  9954. "msg": res.ErrMsg,
  9955. })
  9956. } else {
  9957. c.ServeSuccessJSON(map[string]interface{}{
  9958. "failed_code": 0,
  9959. "info": res,
  9960. })
  9961. }
  9962. }
  9963. }
  9964. func (c *HisApiController) PsnPutOnRecord() {
  9965. record_type, _ := c.GetInt64("type")
  9966. patient_id, _ := c.GetInt64("patient_id")
  9967. admin_user_id, _ := c.GetInt64("admin_user_id")
  9968. start_time := c.GetString("start_time")
  9969. end_time := c.GetString("end_time")
  9970. adminUser := c.GetAdminUserInfo()
  9971. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9972. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9973. var patients []*models.Patients
  9974. if record_type == 1 { //全部备案
  9975. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9976. patients = append(patients, patient...)
  9977. } else { //单个备案
  9978. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9979. patients = append(patients, patient)
  9980. }
  9981. var user_name string
  9982. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9983. if role.ID == 0 {
  9984. user_name = "xxx"
  9985. } else {
  9986. user_name = role.UserName
  9987. }
  9988. if config.IsOpen == 1 {
  9989. for _, item := range patients {
  9990. 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
  9991. resp, requestErr := http.Get(api)
  9992. if requestErr != nil {
  9993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9994. return
  9995. }
  9996. defer resp.Body.Close()
  9997. body, ioErr := ioutil.ReadAll(resp.Body)
  9998. if ioErr != nil {
  9999. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10001. return
  10002. }
  10003. var respJSON map[string]interface{}
  10004. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10007. return
  10008. }
  10009. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10010. userJSONBytes, _ := json.Marshal(userJSON)
  10011. var res ResultTwo
  10012. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10013. utils.ErrorLog("解析失败:%v", err)
  10014. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10015. return
  10016. }
  10017. if res.Infcode == 0 {
  10018. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10019. var dat map[string]interface{}
  10020. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10021. fmt.Println(dat)
  10022. } else {
  10023. fmt.Println(err)
  10024. }
  10025. userJSONBytes, _ := json.Marshal(dat)
  10026. var res2 ResultThirteen
  10027. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10028. utils.ErrorLog("解析失败:%v", err)
  10029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10030. return
  10031. }
  10032. if res2.Infcode == 0 {
  10033. psnResult := &models.GdybPsnRecord{
  10034. UserOrgId: adminUser.CurrentOrgId,
  10035. PatientId: item.ID,
  10036. PsnNo: res.Output.Baseinfo.PsnNo,
  10037. Ctime: time.Now().Unix(),
  10038. Mtime: time.Now().Unix(),
  10039. Status: 1,
  10040. IsCancel: 1,
  10041. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10042. }
  10043. service.CreatePsnRecord(psnResult)
  10044. } else {
  10045. c.ServeSuccessJSON(map[string]interface{}{
  10046. "failed_code": -10,
  10047. "msg": res2.ErrMsg,
  10048. })
  10049. return
  10050. }
  10051. }
  10052. }
  10053. }
  10054. }
  10055. func (c *HisApiController) PsnUnPutOnRecord() {
  10056. id, _ := c.GetInt64("id")
  10057. //record_type, _ := c.GetInt64("type")
  10058. admin_user_id, _ := c.GetInt64("admin_user_id")
  10059. adminUser := c.GetAdminUserInfo()
  10060. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10061. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10062. var user_name string
  10063. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10064. if role.ID == 0 {
  10065. user_name = "xxx"
  10066. } else {
  10067. user_name = role.UserName
  10068. }
  10069. psn_record, _ := service.GetPsnRecordById(id)
  10070. if psn_record.ID == 0 {
  10071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10072. return
  10073. }
  10074. if config.IsOpen == 1 {
  10075. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10076. var dat map[string]interface{}
  10077. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10078. fmt.Println(dat)
  10079. } else {
  10080. fmt.Println(err)
  10081. }
  10082. userJSONBytes, _ := json.Marshal(dat)
  10083. var res ResultFourteen
  10084. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10085. utils.ErrorLog("解析失败:%v", err)
  10086. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10087. return
  10088. }
  10089. if res.Infcode == 0 {
  10090. psn_record.IsCancel = 2
  10091. service.CreatePsnRecord(&psn_record)
  10092. } else {
  10093. c.ServeSuccessJSON(map[string]interface{}{
  10094. "failed_code": -10,
  10095. "msg": res.ErrMsg,
  10096. })
  10097. return
  10098. }
  10099. }
  10100. }
  10101. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10102. patient_id, _ := c.GetInt64("patient_id")
  10103. insutype_two := c.GetString("insutype")
  10104. psn_no := c.GetString("psn_no")
  10105. doctor_id, _ := c.GetInt64("doctor_id")
  10106. sick_id, _ := c.GetInt64("sick_id")
  10107. department_id, _ := c.GetInt64("department_id")
  10108. start_time := c.GetString("start_time")
  10109. end_time := c.GetString("end_time")
  10110. check_time := c.GetString("check_time")
  10111. adminUser := c.GetAdminUserInfo()
  10112. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10113. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10114. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10115. sick, _ := service.FindSickById(sick_id)
  10116. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10117. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10118. var res ResultTwo
  10119. var res10265 ResultTwo10265
  10120. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10121. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10122. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  10123. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10124. "&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
  10125. resp, requestErr := http.Get(api)
  10126. if requestErr != nil {
  10127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10128. return
  10129. }
  10130. body, ioErr := ioutil.ReadAll(resp.Body)
  10131. if ioErr != nil {
  10132. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10133. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10134. return
  10135. }
  10136. var respJSON map[string]interface{}
  10137. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10138. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10140. return
  10141. }
  10142. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10143. result, _ := json.Marshal(respJSON)
  10144. fmt.Println("log")
  10145. fmt.Println(string(result))
  10146. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10147. utils.ErrorLog("解析失败:%v", err)
  10148. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10149. return
  10150. }
  10151. res.ErrMsg = res10265.ErrMsg
  10152. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10153. res.Infcode = infocode
  10154. res.Output = res10265.Output
  10155. res.InfRefmsgid = res10265.InfRefmsgid
  10156. } else {
  10157. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10158. if miConfig.Code == "H15049901371" {
  10159. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10160. utils.ErrorLog("解析失败:%v", err)
  10161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10162. return
  10163. }
  10164. res.ErrMsg = res10265.ErrMsg
  10165. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10166. res.Infcode = infocode
  10167. res.Output = res10265.Output
  10168. res.InfRefmsgid = res10265.InfRefmsgid
  10169. } else {
  10170. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10171. utils.ErrorLog("解析失败:%v", err)
  10172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10173. return
  10174. }
  10175. }
  10176. }
  10177. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10178. infoStr := string(Iinfos)
  10179. var rf []*ResultFive
  10180. json.Unmarshal([]byte(infoStr), &rf)
  10181. var insuplc_admdvs string
  10182. var insutype string
  10183. var is390 int = 0
  10184. var is310 int = 0
  10185. var insutypes []*ResultFive
  10186. for _, item := range rf {
  10187. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10188. insutypes = append(insutypes, item)
  10189. }
  10190. }
  10191. if len(insutypes) == 1 {
  10192. insutype = insutypes[0].Insutype
  10193. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10194. } else {
  10195. for _, i := range insutypes {
  10196. if i.Insutype == "390" {
  10197. is390 = 1
  10198. }
  10199. if i.Insutype == "310" {
  10200. is310 = 1
  10201. }
  10202. }
  10203. }
  10204. if is390 == 1 {
  10205. insutype = "390"
  10206. }
  10207. if is310 == 1 {
  10208. insutype = "310"
  10209. }
  10210. if len(insutypes) == 2 {
  10211. insutype = insutype_two
  10212. }
  10213. if len(insutypes) == 0 {
  10214. insutype = "310"
  10215. }
  10216. insutype = insutype_two
  10217. fmt.Println(insutype)
  10218. for _, item := range rf {
  10219. fmt.Println(item.Insutype)
  10220. fmt.Println(insutype)
  10221. if item.Insutype == insutype {
  10222. fmt.Println(item.Insutype)
  10223. fmt.Println(insutype)
  10224. insuplc_admdvs = item.InsuplcAdmdvs
  10225. }
  10226. }
  10227. fmt.Println(insuplc_admdvs)
  10228. var res2 ResultThirteen
  10229. var res10265_2 ResultThirteen10265
  10230. if config.IsOpen == 1 {
  10231. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10232. } else {
  10233. 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)
  10234. var dat map[string]interface{}
  10235. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10236. fmt.Println(dat)
  10237. } else {
  10238. fmt.Println(err)
  10239. }
  10240. userJSONBytes, _ := json.Marshal(dat)
  10241. if miConfig.Code == "H15049901371" {
  10242. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10243. utils.ErrorLog("解析失败:%v", err)
  10244. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10245. return
  10246. }
  10247. res2.ErrMsg = res10265_2.ErrMsg
  10248. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10249. res2.Infcode = infocode
  10250. res2.Output = res10265_2.Output
  10251. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10252. } else {
  10253. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10254. utils.ErrorLog("解析失败:%v", err)
  10255. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10256. return
  10257. }
  10258. }
  10259. }
  10260. if res2.Infcode == 0 {
  10261. psnResult := &models.GdybPsnNcdsRecord{
  10262. UserOrgId: adminUser.CurrentOrgId,
  10263. PatientId: patient.ID,
  10264. PsnNo: psn_no,
  10265. DoctorId: doctor.AdminUserId,
  10266. DepartmentId: department_id,
  10267. SickType: sick_id,
  10268. Insutype: insutype,
  10269. Ctime: time.Now().Unix(),
  10270. Mtime: time.Now().Unix(),
  10271. Status: 1,
  10272. IsCancel: 1,
  10273. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10274. }
  10275. service.CreatePsnNCDSRecord(psnResult)
  10276. c.ServeSuccessJSON(map[string]interface{}{
  10277. "failed_code": 0,
  10278. "msg": "备案成功",
  10279. "result": psnResult,
  10280. })
  10281. } else {
  10282. c.ServeSuccessJSON(map[string]interface{}{
  10283. "failed_code": -10,
  10284. "msg": res2.ErrMsg,
  10285. })
  10286. return
  10287. }
  10288. }
  10289. }
  10290. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10291. id, _ := c.GetInt64("id")
  10292. admin_user_id, _ := c.GetInt64("admin_user_id")
  10293. adminUser := c.GetAdminUserInfo()
  10294. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10295. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10296. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10297. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10298. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10299. //var user_name string
  10300. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10301. //if role.ID == 0 {
  10302. // user_name = "xxx"
  10303. //} else {
  10304. // user_name = role.UserName
  10305. //}
  10306. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10307. if psn_record.ID == 0 {
  10308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10309. return
  10310. }
  10311. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10312. var res ResultTwo
  10313. var res10265 ResultTwo10265
  10314. if miConfig.Code == "H15049901371" {
  10315. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10316. utils.ErrorLog("解析失败:%v", err)
  10317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10318. return
  10319. }
  10320. res.ErrMsg = res10265.ErrMsg
  10321. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10322. res.Infcode = infocode
  10323. res.Output = res10265.Output
  10324. res.InfRefmsgid = res10265.InfRefmsgid
  10325. } else {
  10326. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10327. utils.ErrorLog("解析失败:%v", err)
  10328. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10329. return
  10330. }
  10331. }
  10332. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10333. infoStr := string(Iinfos)
  10334. var rf []*ResultFive
  10335. json.Unmarshal([]byte(infoStr), &rf)
  10336. var insuplc_admdvs string
  10337. var insutype string
  10338. var is390 int = 0
  10339. var is310 int = 0
  10340. var insutypes []*ResultFive
  10341. for _, item := range rf {
  10342. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10343. insutypes = append(insutypes, item)
  10344. }
  10345. }
  10346. if len(insutypes) == 1 {
  10347. insutype = insutypes[0].Insutype
  10348. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10349. } else {
  10350. for _, i := range insutypes {
  10351. if i.Insutype == "390" {
  10352. is390 = 1
  10353. }
  10354. if i.Insutype == "310" {
  10355. is310 = 1
  10356. }
  10357. }
  10358. }
  10359. if is390 == 1 {
  10360. insutype = "390"
  10361. }
  10362. if is310 == 1 {
  10363. insutype = "310"
  10364. }
  10365. if len(insutypes) == 0 {
  10366. insutype = "310"
  10367. }
  10368. insutype = psn_record.Insutype
  10369. for _, item := range rf {
  10370. if item.Insutype == insutype {
  10371. insuplc_admdvs = item.InsuplcAdmdvs
  10372. }
  10373. }
  10374. if config.IsOpen == 1 {
  10375. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10376. var dat map[string]interface{}
  10377. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10378. fmt.Println(dat)
  10379. } else {
  10380. fmt.Println(err)
  10381. }
  10382. userJSONBytes, _ := json.Marshal(dat)
  10383. var res ResultFourteen
  10384. var res10265 ResultFourteen10265
  10385. if miConfig.Code == "H15049901371" {
  10386. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10387. utils.ErrorLog("解析失败:%v", err)
  10388. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10389. return
  10390. }
  10391. res.ErrMsg = res10265.ErrMsg
  10392. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10393. res.Infcode = infocode
  10394. res.Output = res10265.Output
  10395. res.InfRefmsgid = res10265.InfRefmsgid
  10396. } else {
  10397. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10398. utils.ErrorLog("解析失败:%v", err)
  10399. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10400. return
  10401. }
  10402. }
  10403. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10404. // utils.ErrorLog("解析失败:%v", err)
  10405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10406. // return
  10407. //}
  10408. if res.Infcode == 0 {
  10409. psn_record.IsCancel = 2
  10410. service.CreatePsnNCDSRecord(&psn_record)
  10411. c.ServeSuccessJSON(map[string]interface{}{
  10412. "failed_code": 0,
  10413. "msg": "撤销备案成功",
  10414. })
  10415. } else {
  10416. c.ServeSuccessJSON(map[string]interface{}{
  10417. "failed_code": -10,
  10418. "msg": res.ErrMsg,
  10419. })
  10420. return
  10421. }
  10422. }
  10423. }
  10424. func (c *HisApiController) TestTest() {
  10425. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10426. fmt.Println(patient.Iinfo)
  10427. }
  10428. type CustomData struct {
  10429. MsgId string
  10430. PsnNo string
  10431. Info string
  10432. }
  10433. func (c *HisApiController) ReversalData() {
  10434. var customData []*CustomData
  10435. custom := &CustomData{
  10436. MsgId: "H44022900158202103301714472004",
  10437. PsnNo: "44020000001101329945",
  10438. Info: "2207",
  10439. }
  10440. customData = append(customData, custom)
  10441. custom1 := &CustomData{
  10442. MsgId: "H4402290015820210330172057803",
  10443. PsnNo: "44020000001101161813",
  10444. Info: "2207",
  10445. }
  10446. customData = append(customData, custom1)
  10447. custom2 := &CustomData{
  10448. MsgId: "H44022900158202103301705198813",
  10449. PsnNo: "44190000133097375417",
  10450. Info: "2207",
  10451. }
  10452. customData = append(customData, custom2)
  10453. custom3 := &CustomData{
  10454. MsgId: "H44022900158202103301715524756",
  10455. PsnNo: "44020000001100187221",
  10456. Info: "2207",
  10457. }
  10458. customData = append(customData, custom3)
  10459. custom4 := &CustomData{
  10460. MsgId: "H44022900158202103301730376224",
  10461. PsnNo: "44020000001101959155",
  10462. Info: "2207",
  10463. }
  10464. customData = append(customData, custom4)
  10465. custom5 := &CustomData{
  10466. MsgId: "H44022900158202103301748008725",
  10467. PsnNo: "44020000001104246641",
  10468. Info: "2207",
  10469. }
  10470. customData = append(customData, custom5)
  10471. custom6 := &CustomData{
  10472. MsgId: "H44022900158202103301718096755",
  10473. PsnNo: "44020000001102211860",
  10474. Info: "2207",
  10475. }
  10476. customData = append(customData, custom6)
  10477. custom7 := &CustomData{
  10478. MsgId: "H44022900158202103301736551640",
  10479. PsnNo: "44020000001102687718",
  10480. Info: "2207",
  10481. }
  10482. customData = append(customData, custom7)
  10483. custom8 := &CustomData{
  10484. MsgId: "H44022900158202103301743097676",
  10485. PsnNo: "44020000001102127785",
  10486. Info: "2207",
  10487. }
  10488. customData = append(customData, custom8)
  10489. custom9 := &CustomData{
  10490. MsgId: "H44022900158202103301712304203",
  10491. PsnNo: "44020000001101518097",
  10492. Info: "2207",
  10493. }
  10494. customData = append(customData, custom9)
  10495. custom10 := &CustomData{
  10496. MsgId: "H44022900158202103301738448785",
  10497. PsnNo: "44020000001100500813",
  10498. Info: "2207",
  10499. }
  10500. customData = append(customData, custom10)
  10501. custom11 := &CustomData{
  10502. MsgId: "H44022900158202103301732455843",
  10503. PsnNo: "44020000001102690557",
  10504. Info: "2207",
  10505. }
  10506. customData = append(customData, custom11)
  10507. custom12 := &CustomData{
  10508. MsgId: "H44022900158202103301745421708",
  10509. PsnNo: "44020000001102211928",
  10510. Info: "2207",
  10511. }
  10512. customData = append(customData, custom12)
  10513. custom1212 := &CustomData{
  10514. MsgId: "H440229001582021033017351627",
  10515. PsnNo: "44020000001102481733",
  10516. Info: "2207",
  10517. }
  10518. customData = append(customData, custom1212)
  10519. custom13 := &CustomData{
  10520. MsgId: "H44022900158202103301740327951",
  10521. PsnNo: "44020000001103174866",
  10522. Info: "2207",
  10523. }
  10524. customData = append(customData, custom13)
  10525. custom14 := &CustomData{
  10526. MsgId: "H4402290015820210330174922668",
  10527. PsnNo: "44020000001102927272",
  10528. Info: "2207",
  10529. }
  10530. customData = append(customData, custom14)
  10531. custom15 := &CustomData{
  10532. MsgId: "H44022900158202103301752362273",
  10533. PsnNo: "44020000001102942890",
  10534. Info: "2207",
  10535. }
  10536. customData = append(customData, custom15)
  10537. custom16 := &CustomData{
  10538. MsgId: "H44022900158202103301751082917",
  10539. PsnNo: "44020000001101662162",
  10540. Info: "2207",
  10541. }
  10542. customData = append(customData, custom16)
  10543. custom17 := &CustomData{
  10544. MsgId: "H44022900158202103301754147728",
  10545. PsnNo: "44020000000229014511",
  10546. Info: "2207",
  10547. }
  10548. customData = append(customData, custom17)
  10549. adminUser := c.GetAdminUserInfo()
  10550. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10551. for _, item := range customData {
  10552. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10553. fmt.Println(result)
  10554. }
  10555. }
  10556. //func (c *HisApiController) GetAllopatry() {
  10557. // year := c.GetString("year")
  10558. // month := c.GetString("month")
  10559. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10560. // adminUser := c.GetAdminUserInfo()
  10561. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10562. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10563. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10564. //
  10565. // var dat map[string]interface{}
  10566. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10567. // fmt.Println(dat)
  10568. // } else {
  10569. // fmt.Println(err)
  10570. // }
  10571. // userJSONBytes, _ := json.Marshal(dat)
  10572. // var res models.Result9001
  10573. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10574. // utils.ErrorLog("解析失败:%v", err)
  10575. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10576. // return
  10577. // }
  10578. //
  10579. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10580. // var dat2 map[string]interface{}
  10581. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10582. // fmt.Println(dat)
  10583. // } else {
  10584. // fmt.Println(err)
  10585. // }
  10586. // userJSONBytes2, _ := json.Marshal(dat2)
  10587. // var res2 models.Result3260
  10588. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10589. // utils.ErrorLog("解析失败:%v", err)
  10590. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10591. // return
  10592. // }
  10593. // if res2.Infcode == 0 {
  10594. // c.ServeSuccessJSON(map[string]interface{}{
  10595. // "list": res2.Output.Data,
  10596. // })
  10597. // return
  10598. // } else {
  10599. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10600. // return
  10601. // }
  10602. //
  10603. //}
  10604. //func (c *HisApiController) ComfirmAllopatry() {
  10605. // year := c.GetString("year")
  10606. // month := c.GetString("month")
  10607. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10608. // adminUser := c.GetAdminUserInfo()
  10609. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10610. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10611. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10612. // var dat map[string]interface{}
  10613. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10614. // fmt.Println(dat)
  10615. // } else {
  10616. // fmt.Println(err)
  10617. // }
  10618. // userJSONBytes, _ := json.Marshal(dat)
  10619. // var res models.Result9001
  10620. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10621. // utils.ErrorLog("解析失败:%v", err)
  10622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10623. // return
  10624. // }
  10625. //
  10626. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10627. // var dat2 map[string]interface{}
  10628. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10629. // fmt.Println(dat)
  10630. // } else {
  10631. // fmt.Println(err)
  10632. // }
  10633. // userJSONBytes2, _ := json.Marshal(dat2)
  10634. // var res2 models.Result3260
  10635. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10636. // utils.ErrorLog("解析失败:%v", err)
  10637. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10638. // return
  10639. // }
  10640. //
  10641. // if res2.Infcode == 0 {
  10642. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10643. // var dat map[string]interface{}
  10644. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10645. // fmt.Println(dat)
  10646. // } else {
  10647. // fmt.Println(err)
  10648. // }
  10649. // userJSONBytes, _ := json.Marshal(dat)
  10650. // var res3 models.Result3261
  10651. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10652. // utils.ErrorLog("解析失败:%v", err)
  10653. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10654. // return
  10655. // }
  10656. //
  10657. // if res3.Infcode == 0 {
  10658. // record := &models.HisYidiClearRecord{
  10659. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10660. // Ctime: time.Now().Unix(),
  10661. // Mtime: time.Now().Unix(),
  10662. // Status: 1,
  10663. // MsgId: msgId,
  10664. // }
  10665. // service.SaveClearRecord(record)
  10666. // c.ServeSuccessJSON(map[string]interface{}{
  10667. // "msg": "提取成功",
  10668. // })
  10669. // }
  10670. // }
  10671. //}
  10672. func (c *HisApiController) RefundAllopatry() {
  10673. year := c.GetString("year")
  10674. month := c.GetString("month")
  10675. id, _ := c.GetInt64("id")
  10676. admin_user_id, _ := c.GetInt64("admin_user_id")
  10677. adminUser := c.GetAdminUserInfo()
  10678. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10679. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10680. record, _ := service.GetClearRecordById(id)
  10681. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10682. var dat map[string]interface{}
  10683. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10684. fmt.Println(dat)
  10685. } else {
  10686. fmt.Println(err)
  10687. }
  10688. userJSONBytes, _ := json.Marshal(dat)
  10689. var empty ResultFourteen
  10690. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10691. utils.ErrorLog("解析失败:%v", err)
  10692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10693. return
  10694. }
  10695. if empty.Infcode == 0 {
  10696. c.ServeSuccessJSON(map[string]interface{}{
  10697. "msg": "撤销成功",
  10698. })
  10699. return
  10700. }
  10701. }
  10702. func (c *HisApiController) ReversalOtherData() {
  10703. var customData []*CustomData
  10704. custom := &CustomData{
  10705. MsgId: "H44022900158202103301714472004",
  10706. PsnNo: "44020000001101329945",
  10707. Info: "2208",
  10708. }
  10709. customData = append(customData, custom)
  10710. custom1 := &CustomData{
  10711. MsgId: "H4402290015820210330172057803",
  10712. PsnNo: "44020000001101161813",
  10713. Info: "2208",
  10714. }
  10715. customData = append(customData, custom1)
  10716. custom2 := &CustomData{
  10717. MsgId: "H44022900158202103301705198813",
  10718. PsnNo: "44190000133097375417",
  10719. Info: "2208",
  10720. }
  10721. customData = append(customData, custom2)
  10722. custom3 := &CustomData{
  10723. MsgId: "H44022900158202103301715524756",
  10724. PsnNo: "44020000001100187221",
  10725. Info: "2208",
  10726. }
  10727. customData = append(customData, custom3)
  10728. custom4 := &CustomData{
  10729. MsgId: "H44022900158202103301730376224",
  10730. PsnNo: "44020000001101959155",
  10731. Info: "2208",
  10732. }
  10733. customData = append(customData, custom4)
  10734. custom5 := &CustomData{
  10735. MsgId: "H44022900158202103301748008725",
  10736. PsnNo: "44020000001104246641",
  10737. Info: "2208",
  10738. }
  10739. customData = append(customData, custom5)
  10740. custom6 := &CustomData{
  10741. MsgId: "H44022900158202103301718096755",
  10742. PsnNo: "44020000001102211860",
  10743. Info: "2208",
  10744. }
  10745. customData = append(customData, custom6)
  10746. custom7 := &CustomData{
  10747. MsgId: "H44022900158202103301736551640",
  10748. PsnNo: "44020000001102687718",
  10749. Info: "2208",
  10750. }
  10751. customData = append(customData, custom7)
  10752. custom8 := &CustomData{
  10753. MsgId: "H44022900158202103301743097676",
  10754. PsnNo: "44020000001102127785",
  10755. Info: "2208",
  10756. }
  10757. customData = append(customData, custom8)
  10758. custom9 := &CustomData{
  10759. MsgId: "H44022900158202103301712304203",
  10760. PsnNo: "44020000001101518097",
  10761. Info: "2208",
  10762. }
  10763. customData = append(customData, custom9)
  10764. custom10 := &CustomData{
  10765. MsgId: "H44022900158202103301738448785",
  10766. PsnNo: "44020000001100500813",
  10767. Info: "2208",
  10768. }
  10769. customData = append(customData, custom10)
  10770. custom11 := &CustomData{
  10771. MsgId: "H44022900158202103301732455843",
  10772. PsnNo: "44020000001102690557",
  10773. Info: "2208",
  10774. }
  10775. customData = append(customData, custom11)
  10776. custom12 := &CustomData{
  10777. MsgId: "H44022900158202103301745421708",
  10778. PsnNo: "44020000001102211928",
  10779. Info: "2208",
  10780. }
  10781. customData = append(customData, custom12)
  10782. custom1212 := &CustomData{
  10783. MsgId: "H440229001582021033017351627",
  10784. PsnNo: "44020000001102481733",
  10785. Info: "2208",
  10786. }
  10787. customData = append(customData, custom1212)
  10788. custom13 := &CustomData{
  10789. MsgId: "H44022900158202103301740327951",
  10790. PsnNo: "44020000001103174866",
  10791. Info: "2208",
  10792. }
  10793. customData = append(customData, custom13)
  10794. custom14 := &CustomData{
  10795. MsgId: "H4402290015820210330174922668",
  10796. PsnNo: "44020000001102927272",
  10797. Info: "2208",
  10798. }
  10799. customData = append(customData, custom14)
  10800. custom15 := &CustomData{
  10801. MsgId: "H44022900158202103301752362273",
  10802. PsnNo: "44020000001102942890",
  10803. Info: "2208",
  10804. }
  10805. customData = append(customData, custom15)
  10806. custom16 := &CustomData{
  10807. MsgId: "H44022900158202103301751082917",
  10808. PsnNo: "44020000001101662162",
  10809. Info: "2208",
  10810. }
  10811. customData = append(customData, custom16)
  10812. custom17 := &CustomData{
  10813. MsgId: "H44022900158202103301754147728",
  10814. PsnNo: "44020000000229014511",
  10815. Info: "2208",
  10816. }
  10817. customData = append(customData, custom17)
  10818. adminUser := c.GetAdminUserInfo()
  10819. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10820. for _, item := range customData {
  10821. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10822. fmt.Println(result)
  10823. }
  10824. }
  10825. func PathExists(path string) (bool, error) {
  10826. _, err := os.Stat(path)
  10827. if err == nil {
  10828. return true, nil
  10829. }
  10830. if os.IsNotExist(err) {
  10831. return false, nil
  10832. }
  10833. return false, err
  10834. }
  10835. //创建文件夹
  10836. func Mkdir(dir string) {
  10837. // 创建文件夹
  10838. exist, err := PathExists(dir)
  10839. if err != nil {
  10840. fmt.Println(err.Error())
  10841. } else {
  10842. if exist {
  10843. fmt.Println(dir + "文件夹已存在!")
  10844. } else {
  10845. // 文件夹名称,权限
  10846. err := os.Mkdir(dir, os.ModePerm)
  10847. if err != nil {
  10848. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10849. } else {
  10850. fmt.Println(dir + "文件夹创建成功!")
  10851. }
  10852. }
  10853. }
  10854. }
  10855. //压缩文件
  10856. func Zip(srcFile string, destZip string) error {
  10857. zipfile, err := os.Create(destZip)
  10858. if err != nil {
  10859. return err
  10860. }
  10861. defer zipfile.Close()
  10862. archive := zip.NewWriter(zipfile)
  10863. defer archive.Close()
  10864. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10865. if err != nil {
  10866. return err
  10867. }
  10868. header, err := zip.FileInfoHeader(info)
  10869. if err != nil {
  10870. return err
  10871. }
  10872. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10873. // header.Name = path
  10874. if info.IsDir() {
  10875. header.Name += "/"
  10876. } else {
  10877. header.Method = zip.Deflate
  10878. }
  10879. writer, err := archive.CreateHeader(header)
  10880. if err != nil {
  10881. return err
  10882. }
  10883. if !info.IsDir() {
  10884. file, err := os.Open(path)
  10885. if err != nil {
  10886. return err
  10887. }
  10888. defer file.Close()
  10889. _, err = io.Copy(writer, file)
  10890. }
  10891. return err
  10892. })
  10893. return err
  10894. }
  10895. func ReadFile(filePath string) []byte {
  10896. f, err := os.Open(filePath)
  10897. if err != nil {
  10898. fmt.Println("read file fail", err)
  10899. return nil
  10900. }
  10901. defer f.Close()
  10902. fd, err := ioutil.ReadAll(f)
  10903. if err != nil {
  10904. fmt.Println("read to fd fail", err)
  10905. return nil
  10906. }
  10907. return fd
  10908. }
  10909. func saveLog(result string, request string, infno string, desc string) {
  10910. org_id, _ := beego.AppConfig.Int64("org_id")
  10911. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10912. dir := miConfig.OrgName + "日志"
  10913. utils.Mkdir(dir)
  10914. month := time.Unix(1557042972, 0).Format("1")
  10915. year := time.Now().Format("2006")
  10916. month = time.Now().Format("01")
  10917. day := time.Now().Format("02")
  10918. hour := time.Now().Format("15")
  10919. min := time.Now().Format("04")
  10920. sec := time.Now().Format("05")
  10921. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10922. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10923. file_name := file + ".txt"
  10924. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10925. exist, _ := utils.PathExists(file_path)
  10926. if exist { //存在
  10927. fmt.Println("存在")
  10928. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10929. if err != nil {
  10930. fmt.Println("read fail")
  10931. }
  10932. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10933. n, _ := f.Seek(0, 2)
  10934. _, err = f.WriteAt([]byte(content), n)
  10935. } else { //不存在
  10936. fmt.Println("文件不存在,创建文件")
  10937. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10938. defer f.Close()
  10939. if err != nil {
  10940. } else {
  10941. _, err = f.Write([]byte("记录日志"))
  10942. }
  10943. }
  10944. }
  10945. type Charset string
  10946. const (
  10947. UTF8 = Charset("UTF-8")
  10948. GB18030 = Charset("GB18030")
  10949. )
  10950. func ConvertToString(src string, srcCode string, tagCode string) string {
  10951. srcCoder := mahonia.NewDecoder(srcCode)
  10952. srcResult := srcCoder.ConvertString(src)
  10953. tagCoder := mahonia.NewDecoder(tagCode)
  10954. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10955. result := string(cdata)
  10956. return result
  10957. }
  10958. func (c *HisApiController) ReadEleCard() {
  10959. id_card_type, _ := c.GetInt64("id_card_type")
  10960. admin_user_id, _ := c.GetInt64("admin_user_id")
  10961. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  10962. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  10963. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  10964. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10965. var api string
  10966. if miConfig.MdtrtareaAdmvs == "320921" {
  10967. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  10968. "&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
  10969. fmt.Println(api)
  10970. } else {
  10971. 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 +
  10972. "&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)
  10973. }
  10974. resp, requestErr := http.Get(api)
  10975. if requestErr != nil {
  10976. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10977. return
  10978. }
  10979. body, ioErr := ioutil.ReadAll(resp.Body)
  10980. if ioErr != nil {
  10981. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10983. return
  10984. }
  10985. var respJSON map[string]interface{}
  10986. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10987. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10988. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10989. return
  10990. }
  10991. var status string
  10992. status = respJSON["data"].(map[string]interface{})["status"].(string)
  10993. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  10994. var token string
  10995. var res ResultTwo //1101结果
  10996. var res10265 ResultTwo10265 //1101结果
  10997. if status == "0" { //读卡成功
  10998. var card_info string //卡信息
  10999. var busi_card_info string
  11000. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11001. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11002. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11003. fmt.Println(card_info)
  11004. fmt.Println(busi_card_info)
  11005. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11006. result, _ := json.Marshal(respJSON)
  11007. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11008. utils.ErrorLog("解析失败:%v", err)
  11009. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11010. return
  11011. }
  11012. res.ErrMsg = res10265.ErrMsg
  11013. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11014. res.Infcode = infocode
  11015. res.Output = res10265.Output
  11016. res.InfRefmsgid = res10265.InfRefmsgid
  11017. if res.Infcode == 0 {
  11018. c.ServeSuccessJSON(map[string]interface{}{
  11019. "number": token,
  11020. })
  11021. }
  11022. } else {
  11023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11024. return
  11025. }
  11026. } else { //读卡失败
  11027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11028. return
  11029. }
  11030. }
  11031. func DeleteExtraSpaceTwo(s string) string {
  11032. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11033. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11034. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11035. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11036. s2 := make([]byte, len(s1)) //定义字符数组切片
  11037. copy(s2, s1) //将字符串复制到切片
  11038. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11039. for len(spc_index) > 0 { //找到适配项
  11040. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11041. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11042. }
  11043. return string(s2)
  11044. }
  11045. func Remove0000(s string) string {
  11046. str := make([]rune, 0, len(s))
  11047. for _, v := range []rune(s) {
  11048. if v == 0 {
  11049. continue
  11050. }
  11051. str = append(str, v)
  11052. }
  11053. return string(str)
  11054. }