his_api_controller.go 456KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439
  1. package sg
  2. import (
  3. "archive/zip"
  4. "bytes"
  5. "encoding/json"
  6. "fmt"
  7. "gdyb/controllers"
  8. "gdyb/enums"
  9. "gdyb/models"
  10. "gdyb/service"
  11. "gdyb/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/axgle/mahonia"
  14. "github.com/jinzhu/gorm"
  15. "github.com/shopspring/decimal"
  16. "io"
  17. "io/ioutil"
  18. "math/rand"
  19. "net/http"
  20. "os"
  21. "path/filepath"
  22. "regexp"
  23. "strconv"
  24. "strings"
  25. "syscall"
  26. "time"
  27. "unsafe"
  28. )
  29. type HisApiController struct {
  30. controllers.BaseAuthAPIController
  31. }
  32. func HisManagerApiRegistRouters() {
  33. //挂号
  34. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  35. //上传就诊信息-上传明细-结算
  36. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  37. //查询
  38. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  39. //对总账
  40. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  41. //对明细
  42. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  43. //退费,退明细
  44. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  45. //退号
  46. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  47. //退明细
  48. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  49. //上传就诊信息-上传明细-预结算
  50. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  51. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  52. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  53. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  54. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  55. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  56. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  57. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  58. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  59. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  60. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  61. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  62. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  63. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  64. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  65. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  67. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  68. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  69. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  70. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  71. beego.Router("/api/allopatry/refund", &HisApiController{}, "post:RefundAllopatry")
  72. beego.Router("/api/check", &HisApiController{}, "get:Check")
  73. beego.Router("/api/check3101", &HisApiController{}, "get:Check3101")
  74. beego.Router("/api/check3102", &HisApiController{}, "get:Check3102")
  75. beego.Router("/90990", &HisApiController{}, "get:CheckCardPWDTwo")
  76. beego.Router("/9001", &HisApiController{}, "get:Get9001")
  77. beego.Router("/api/readelecard", &HisApiController{}, "get:ReadEleCard")
  78. }
  79. func (c *HisApiController) Get9001() {
  80. adminUser := c.GetAdminUserInfo()
  81. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  82. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  83. if miConfig.MdtrtareaAdmvs == "350500" {
  84. fmt.Println("350500")
  85. service.GetFjAuthorizationInfo(miConfig.Code)
  86. } else {
  87. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  88. var dat map[string]interface{}
  89. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  90. fmt.Println(dat)
  91. } else {
  92. fmt.Println(err)
  93. }
  94. userJSONBytes, _ := json.Marshal(dat)
  95. var res models.Result9001
  96. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  97. utils.ErrorLog("解析失败:%v", err)
  98. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  99. return
  100. }
  101. }
  102. }
  103. func (c *HisApiController) Check3101() {
  104. patient_id, _ := c.GetInt64("patient_id")
  105. his_patient_id, _ := c.GetInt64("his_patient_id")
  106. admin_user_id, _ := c.GetInt64("admin_user_id")
  107. adminUser := c.GetAdminUserInfo()
  108. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  109. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  110. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  111. record_time := c.GetString("record_time")
  112. trig_scen := c.GetString("trig_scen")
  113. timeLayout := "2006-01-02"
  114. loc, _ := time.LoadLocation("Local")
  115. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  116. if err != nil {
  117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  118. return
  119. }
  120. recordDateTime := theTime.Unix()
  121. var patientPrescription models.HisPrescriptionInfo
  122. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  123. if patientPrescription.ID == 0 {
  124. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  125. }
  126. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  127. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  128. //
  129. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  130. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  131. var pp models.PublicParams
  132. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  133. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  134. pp.FixmedinsName = miConfig.OrgName
  135. pp.FixmedinsCode = miConfig.Code
  136. pp.RequestUrl = miConfig.Url
  137. pp.Cainfo = miConfig.Cainfo
  138. pp.SecretKey = miConfig.SecretKey
  139. pp.AccessKey = miConfig.AccessKey
  140. pp.OpterName = roles.UserName
  141. var config []*models.HisXtDiagnoseConfig
  142. for _, item := range diagnosis_ids {
  143. id, _ := strconv.ParseInt(item, 10, 64)
  144. diagnosisConfig, _ := service.FindDiagnoseById(id)
  145. config = append(config, &diagnosisConfig)
  146. }
  147. var pd models.PatientDtos
  148. pd.PatnID = his.PsnNo
  149. pd.PatnName = his.Name
  150. pd.Gend = his.Gend
  151. pd.Brdy = his.Brdy
  152. pd.Poolarea = his.InsuplcAdmdvs
  153. pd.CurrMdtrtID = his.Number
  154. var fed models.FsiEncounterDtos
  155. fed.MdtrtID = his.Number
  156. fed.MedinsID = miConfig.Code
  157. fed.MedinsName = miConfig.OrgName
  158. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  159. fed.MedMdtrtType = "1"
  160. fed.MedinsType = "1"
  161. fed.MedinsLv = "11"
  162. tm := time.Unix(his.RecordDate, 0)
  163. s_tm := tm.Format("2006-01-02 15:04:05")
  164. fed.AdmDate = s_tm
  165. fed.DscgDate = s_tm
  166. fed.DscgMainDiseCodg = config[0].CountryCode
  167. fed.DscgMainDiseName = config[0].CountryContentName
  168. //诊断信息
  169. var fdds []*models.FsiDiagnoseDtos
  170. for index, item := range config {
  171. if index == 0 {
  172. var fdd models.FsiDiagnoseDtos
  173. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  174. fdd.InoutDiseType = "1"
  175. fdd.MaindiseFlag = "1"
  176. fdd.DiseDate = s_tm
  177. fdd.DiasSrtNo = "1"
  178. fdd.DiseName = item.CountryContentName
  179. fdd.DiseCodg = item.CountryCode
  180. fdds = append(fdds, &fdd)
  181. } else {
  182. var fdd models.FsiDiagnoseDtos
  183. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  184. fdd.InoutDiseType = "1"
  185. fdd.MaindiseFlag = "1"
  186. fdd.DiseDate = s_tm
  187. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  188. fdd.DiseName = item.CountryContentName
  189. fdd.DiseCodg = item.CountryCode
  190. fdds = append(fdds, &fdd)
  191. }
  192. }
  193. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  194. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  195. fed.AdmDeptName = department.Name
  196. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  197. fed.DscgDeptName = department.Name
  198. fed.MedMdtrtType = "1"
  199. fed.MedType = "11"
  200. //if his.Insutype == "390" {
  201. // fed.MedType = "1402"
  202. //} else {
  203. // fed.MedType = "9933"
  204. //}
  205. var orders []*models.FsiOrderDtos
  206. if trig_scen == "2" {
  207. //处方医嘱信息
  208. for _, item := range prescriptions {
  209. for _, subItem := range item.HisDoctorAdviceInfo {
  210. var order models.FsiOrderDtos
  211. order.RxID = strconv.FormatInt(item.ID, 10)
  212. order.Rxno = strconv.FormatInt(item.ID, 10)
  213. order.LongDrordFlag = "0"
  214. order.HilistType = "1"
  215. order.ChrgType = "1"
  216. order.DrordBhvr = "-"
  217. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  218. order.HosplistName = subItem.BaseDrugLib.DrugName
  219. order.HilistLv = "1"
  220. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  221. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  222. order.HosplistName = subItem.BaseDrugLib.DrugName
  223. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  224. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  225. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  226. order.OwnpayAmt = ""
  227. order.SelfpayAmt = ""
  228. order.Spec = ""
  229. order.SpecUnt = ""
  230. order.DrordBegnDate = s_tm
  231. order.DrordStopDate = ""
  232. order.DrordDrCodg = "1"
  233. order.DrordDeptName = department.Name
  234. order.DrordDrCodg = "1"
  235. order.DrordDrName = doctor_info.UserName
  236. order.DrordDrProfttl = ""
  237. order.CurrDrordFlag = "1"
  238. orders = append(orders, &order)
  239. }
  240. for _, subItem := range item.HisPrescriptionProject {
  241. if subItem.Type == 2 {
  242. var order models.FsiOrderDtos
  243. order.RxID = strconv.FormatInt(item.ID, 10)
  244. order.Rxno = strconv.FormatInt(item.ID, 10)
  245. order.LongDrordFlag = "0"
  246. order.HilistType = "1"
  247. order.ChrgType = "1"
  248. order.DrordBhvr = "-"
  249. order.HilistCode = subItem.HisProject.MedicalCode
  250. order.HosplistName = subItem.HisProject.ProjectName
  251. order.HilistLv = "1"
  252. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  253. order.HosplistCode = subItem.HisProject.MedicalCode
  254. order.HosplistName = subItem.HisProject.ProjectName
  255. order.Cnt = subItem.Count
  256. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  257. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  258. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  259. order.OwnpayAmt = ""
  260. order.SelfpayAmt = ""
  261. order.Spec = ""
  262. order.SpecUnt = ""
  263. order.DrordBegnDate = s_tm
  264. order.DrordStopDate = ""
  265. order.DrordDrCodg = "1"
  266. order.DrordDeptName = department.Name
  267. order.DrordDrCodg = "1"
  268. order.DrordDrName = doctor_info.UserName
  269. order.DrordDrProfttl = ""
  270. order.CurrDrordFlag = "1"
  271. orders = append(orders, &order)
  272. }
  273. if subItem.Type == 3 {
  274. var order models.FsiOrderDtos
  275. order.RxID = strconv.FormatInt(item.ID, 10)
  276. order.Rxno = strconv.FormatInt(item.ID, 10)
  277. order.LongDrordFlag = "0"
  278. order.HilistType = "1"
  279. order.ChrgType = "1"
  280. order.DrordBhvr = "-"
  281. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  282. order.HosplistName = subItem.GoodInfo.GoodName
  283. order.HilistLv = "1"
  284. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  285. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  286. order.HosplistName = subItem.GoodInfo.GoodName
  287. order.Cnt = subItem.Count
  288. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  289. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  290. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  291. order.OwnpayAmt = ""
  292. order.SelfpayAmt = ""
  293. order.Spec = ""
  294. order.SpecUnt = ""
  295. order.DrordBegnDate = s_tm
  296. order.DrordStopDate = ""
  297. order.DrordDrCodg = "1"
  298. order.DrordDeptName = department.Name
  299. order.DrordDrCodg = "1"
  300. order.DrordDrName = doctor_info.UserName
  301. order.DrordDrProfttl = ""
  302. order.CurrDrordFlag = "1"
  303. orders = append(orders, &order)
  304. }
  305. }
  306. }
  307. //处方医嘱信息
  308. }
  309. fed.MatnStas = "0"
  310. fed.MedfeeSumamt = "0"
  311. fed.OwnpayAmt = "0"
  312. fed.SelfpayAmt = "0"
  313. fed.AcctPayamt = "0"
  314. fed.MaAmt = "0"
  315. fed.HifpPayamt = "0"
  316. fed.SetlTotlnum = "1"
  317. fed.Insutype = his.Insutype
  318. fed.ReimFlag = "0"
  319. fed.OutSetlFlag = "0"
  320. var fopd []*models.FsiOperationDtosData
  321. data := make(map[string]interface{})
  322. data["fed"] = fed
  323. data["fdd"] = fdds
  324. data["fod"] = orders
  325. data["pd"] = pd
  326. data["pp"] = pp
  327. data["fopd"] = fopd
  328. data["trig_scen"] = trig_scen
  329. fmt.Println(data)
  330. fmt.Println(fed)
  331. fmt.Println(fdds)
  332. fmt.Println(orders)
  333. fmt.Println(pd)
  334. fmt.Println(pp)
  335. fmt.Println(fopd)
  336. client := &http.Client{}
  337. bytesData, _ := json.Marshal(data)
  338. var req *http.Request
  339. if miConfig.MdtrtareaAdmvs == "320921" {
  340. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  341. } else {
  342. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  343. }
  344. resp, _ := client.Do(req)
  345. defer resp.Body.Close()
  346. body, ioErr := ioutil.ReadAll(resp.Body)
  347. if ioErr != nil {
  348. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. var respJSON map[string]interface{}
  353. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  354. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  355. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  356. return
  357. }
  358. //手术操作集合
  359. //手术操作集合
  360. }
  361. func (c *HisApiController) Check3102() {
  362. patient_id, _ := c.GetInt64("patient_id")
  363. order_id, _ := c.GetInt64("order_id")
  364. his_patient_id, _ := c.GetInt64("his_patient_id")
  365. admin_user_id, _ := c.GetInt64("admin_user_id")
  366. trig_scen := c.GetString("trig_scen")
  367. adminUser := c.GetAdminUserInfo()
  368. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  369. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  370. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  371. record_time := c.GetString("record_time")
  372. order, _ := service.GetHisOrderByID(order_id)
  373. timeLayout := "2006-01-02"
  374. loc, _ := time.LoadLocation("Local")
  375. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  376. if err != nil {
  377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  378. return
  379. }
  380. recordDateTime := theTime.Unix()
  381. var patientPrescription models.HisPrescriptionInfo
  382. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  383. if patientPrescription.ID == 0 {
  384. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  385. }
  386. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  387. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  388. //
  389. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  390. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  391. var pp models.PublicParams
  392. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  393. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  394. pp.FixmedinsName = miConfig.OrgName
  395. pp.FixmedinsCode = miConfig.Code
  396. pp.RequestUrl = miConfig.Url
  397. pp.Cainfo = miConfig.Cainfo
  398. pp.SecretKey = miConfig.SecretKey
  399. pp.AccessKey = miConfig.AccessKey
  400. pp.OpterName = roles.UserName
  401. var config []*models.HisXtDiagnoseConfig
  402. for _, item := range diagnosis_ids {
  403. id, _ := strconv.ParseInt(item, 10, 64)
  404. diagnosisConfig, _ := service.FindDiagnoseById(id)
  405. config = append(config, &diagnosisConfig)
  406. }
  407. var pd models.PatientDtos
  408. pd.PatnID = his.PsnNo
  409. pd.PatnName = his.Name
  410. pd.Gend = his.Gend
  411. pd.Brdy = his.Brdy
  412. pd.Poolarea = his.InsuplcAdmdvs
  413. pd.CurrMdtrtID = his.Number
  414. var fed models.FsiEncounterDtos
  415. fed.MdtrtID = his.Number
  416. fed.MedinsID = miConfig.Code
  417. fed.MedinsName = miConfig.OrgName
  418. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  419. fed.MedMdtrtType = "1"
  420. fed.MedinsType = "1"
  421. fed.MedinsLv = "11"
  422. tm := time.Unix(his.RecordDate, 0)
  423. s_tm := tm.Format("2006-01-02 15:04:05")
  424. fed.AdmDate = s_tm
  425. fed.DscgDate = s_tm
  426. fed.DscgMainDiseCodg = config[0].CountryCode
  427. fed.DscgMainDiseName = config[0].CountryContentName
  428. //诊断信息
  429. var fdds []*models.FsiDiagnoseDtos
  430. for index, item := range config {
  431. if index == 0 {
  432. var fdd models.FsiDiagnoseDtos
  433. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  434. fdd.InoutDiseType = "1"
  435. fdd.MaindiseFlag = "1"
  436. fdd.DiseDate = s_tm
  437. fdd.DiasSrtNo = "1"
  438. fdd.DiseName = item.CountryContentName
  439. fdd.DiseCodg = item.CountryCode
  440. fdds = append(fdds, &fdd)
  441. } else {
  442. var fdd models.FsiDiagnoseDtos
  443. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  444. fdd.InoutDiseType = "1"
  445. fdd.MaindiseFlag = "1"
  446. fdd.DiseDate = s_tm
  447. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  448. fdd.DiseName = item.CountryContentName
  449. fdd.DiseCodg = item.CountryCode
  450. fdds = append(fdds, &fdd)
  451. }
  452. }
  453. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  454. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  455. fed.AdmDeptName = department.Name
  456. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  457. fed.DscgDeptName = department.Name
  458. fed.MedType = order.MedType
  459. //处方医嘱信息
  460. var orders []*models.FsiOrderDtos
  461. //for _, item := range prescriptions {
  462. // for _, subItem := range item.HisDoctorAdviceInfo {
  463. // var order models.FsiOrderDtos
  464. // order.RxID = strconv.FormatInt(item.ID, 10)
  465. // order.Rxno = strconv.FormatInt(item.ID, 10)
  466. // order.LongDrordFlag = "0"
  467. // order.HilistType = "1"
  468. // order.ChrgType = "1"
  469. // order.DrordBhvr = "-"
  470. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  471. // order.HosplistName = subItem.BaseDrugLib.DrugName
  472. // order.HilistLv = "1"
  473. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  474. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  475. // order.HosplistName = subItem.BaseDrugLib.DrugName
  476. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  477. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  478. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  479. // order.OwnpayAmt = ""
  480. // order.SelfpayAmt = ""
  481. // order.Spec = ""
  482. // order.SpecUnt = ""
  483. // order.DrordBegnDate = s_tm
  484. // order.DrordStopDate = ""
  485. // order.DrordDrCodg = "1"
  486. // order.DrordDeptName = department.Name
  487. // order.DrordDrCodg = "1"
  488. // order.DrordDrName = doctor_info.UserName
  489. // order.DrordDrProfttl = ""
  490. // order.CurrDrordFlag = "1"
  491. // orders = append(orders, &order)
  492. // }
  493. // for _, subItem := range item.HisPrescriptionProject {
  494. // if subItem.Type == 2 {
  495. // var order models.FsiOrderDtos
  496. // order.RxID = strconv.FormatInt(item.ID, 10)
  497. // order.Rxno = strconv.FormatInt(item.ID, 10)
  498. // order.LongDrordFlag = "0"
  499. // order.HilistType = "1"
  500. // order.ChrgType = "1"
  501. // order.DrordBhvr = "-"
  502. // order.HilistCode = subItem.HisProject.MedicalCode
  503. // order.HosplistName = subItem.HisProject.ProjectName
  504. // order.HilistLv = "1"
  505. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.HosplistCode = subItem.HisProject.MedicalCode
  507. // order.HosplistName = subItem.HisProject.ProjectName
  508. // order.Cnt = subItem.Count
  509. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  510. //
  511. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  512. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  513. // order.OwnpayAmt = ""
  514. // order.SelfpayAmt = ""
  515. // order.Spec = ""
  516. // order.SpecUnt = ""
  517. // order.DrordBegnDate = s_tm
  518. // order.DrordStopDate = ""
  519. // order.DrordDrCodg = "1"
  520. // order.DrordDeptName = department.Name
  521. // order.DrordDrCodg = "1"
  522. // order.DrordDrName = doctor_info.UserName
  523. // order.DrordDrProfttl = ""
  524. // order.CurrDrordFlag = "1"
  525. // orders = append(orders, &order)
  526. //
  527. // }
  528. // if subItem.Type == 3 {
  529. //
  530. // var order models.FsiOrderDtos
  531. // order.RxID = strconv.FormatInt(item.ID, 10)
  532. // order.Rxno = strconv.FormatInt(item.ID, 10)
  533. // order.LongDrordFlag = "0"
  534. // order.HilistType = "1"
  535. // order.ChrgType = "1"
  536. // order.DrordBhvr = "-"
  537. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  538. // order.HosplistName = subItem.GoodInfo.GoodName
  539. // order.HilistLv = "1"
  540. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  541. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  542. // order.HosplistName = subItem.GoodInfo.GoodName
  543. // order.Cnt = subItem.Count
  544. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  545. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  546. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  547. // order.OwnpayAmt = ""
  548. // order.SelfpayAmt = ""
  549. // order.Spec = ""
  550. // order.SpecUnt = ""
  551. // order.DrordBegnDate = s_tm
  552. // order.DrordStopDate = ""
  553. // order.DrordDrCodg = "1"
  554. // order.DrordDeptName = department.Name
  555. // order.DrordDrCodg = "1"
  556. // order.DrordDrName = doctor_info.UserName
  557. // order.DrordDrProfttl = ""
  558. // order.CurrDrordFlag = "1"
  559. // orders = append(orders, &order)
  560. //
  561. // }
  562. // }
  563. //}
  564. for _, item := range prescriptions {
  565. for _, subItem := range item.HisDoctorAdviceInfo {
  566. var order models.FsiOrderDtos
  567. order.RxID = strconv.FormatInt(item.ID, 10)
  568. order.Rxno = strconv.FormatInt(item.ID, 10)
  569. order.LongDrordFlag = "0"
  570. order.HilistType = "1"
  571. order.ChrgType = "1"
  572. order.DrordBhvr = "-"
  573. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  574. order.HosplistName = subItem.BaseDrugLib.DrugName
  575. order.HilistLv = "1"
  576. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  577. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  578. order.HosplistName = subItem.BaseDrugLib.DrugName
  579. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  580. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  581. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  582. order.OwnpayAmt = ""
  583. order.SelfpayAmt = ""
  584. order.Spec = ""
  585. order.SpecUnt = ""
  586. order.DrordBegnDate = s_tm
  587. order.DrordStopDate = ""
  588. order.DrordDrCodg = "1"
  589. order.DrordDeptName = department.Name
  590. order.DrordDrCodg = "1"
  591. order.DrordDrName = doctor_info.UserName
  592. order.DrordDrProfttl = ""
  593. order.CurrDrordFlag = "1"
  594. orders = append(orders, &order)
  595. }
  596. for _, subItem := range item.HisPrescriptionProject {
  597. if subItem.Type == 2 {
  598. var order models.FsiOrderDtos
  599. order.RxID = strconv.FormatInt(item.ID, 10)
  600. order.Rxno = strconv.FormatInt(item.ID, 10)
  601. order.LongDrordFlag = "0"
  602. order.HilistType = "1"
  603. order.ChrgType = "1"
  604. order.DrordBhvr = "-"
  605. order.HilistCode = subItem.HisProject.MedicalCode
  606. order.HosplistName = subItem.HisProject.ProjectName
  607. order.HilistLv = "1"
  608. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  609. order.HosplistCode = subItem.HisProject.MedicalCode
  610. order.HosplistName = subItem.HisProject.ProjectName
  611. order.Cnt = subItem.Count
  612. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  613. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  614. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  615. order.OwnpayAmt = ""
  616. order.SelfpayAmt = ""
  617. order.Spec = ""
  618. order.SpecUnt = ""
  619. order.DrordBegnDate = s_tm
  620. order.DrordStopDate = ""
  621. order.DrordDrCodg = "1"
  622. order.DrordDeptName = department.Name
  623. order.DrordDrCodg = "1"
  624. order.DrordDrName = doctor_info.UserName
  625. order.DrordDrProfttl = ""
  626. order.CurrDrordFlag = "1"
  627. orders = append(orders, &order)
  628. }
  629. if subItem.Type == 3 {
  630. var order models.FsiOrderDtos
  631. order.RxID = strconv.FormatInt(item.ID, 10)
  632. order.Rxno = strconv.FormatInt(item.ID, 10)
  633. order.LongDrordFlag = "0"
  634. order.HilistType = "1"
  635. order.ChrgType = "1"
  636. order.DrordBhvr = "-"
  637. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  638. order.HosplistName = subItem.GoodInfo.GoodName
  639. order.HilistLv = "1"
  640. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  641. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  642. order.HosplistName = subItem.GoodInfo.GoodName
  643. order.Cnt = subItem.Count
  644. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  645. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  646. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  647. order.OwnpayAmt = ""
  648. order.SelfpayAmt = ""
  649. order.Spec = ""
  650. order.SpecUnt = ""
  651. order.DrordBegnDate = s_tm
  652. order.DrordStopDate = ""
  653. order.DrordDrCodg = "1"
  654. order.DrordDeptName = department.Name
  655. order.DrordDrCodg = "1"
  656. order.DrordDrName = doctor_info.UserName
  657. order.DrordDrProfttl = ""
  658. order.CurrDrordFlag = "1"
  659. orders = append(orders, &order)
  660. }
  661. }
  662. }
  663. //处方医嘱信息
  664. fed.MatnStas = "0"
  665. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  666. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  667. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  668. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  669. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  670. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  671. fed.SetlTotlnum = "1"
  672. fed.Insutype = his.Insutype
  673. fed.ReimFlag = "0"
  674. fed.OutSetlFlag = "0"
  675. var fopd []*models.FsiOperationDtosData
  676. data := make(map[string]interface{})
  677. data["fed"] = fed
  678. data["fdd"] = fdds
  679. data["fod"] = orders
  680. data["pd"] = pd
  681. data["pp"] = pp
  682. data["fopd"] = fopd
  683. data["trig_scen"] = trig_scen
  684. client := &http.Client{}
  685. bytesData, _ := json.Marshal(data)
  686. var req *http.Request
  687. if miConfig.MdtrtareaAdmvs == "320921" {
  688. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  689. } else {
  690. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  691. }
  692. resp, _ := client.Do(req)
  693. defer resp.Body.Close()
  694. body, ioErr := ioutil.ReadAll(resp.Body)
  695. if ioErr != nil {
  696. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. var respJSON map[string]interface{}
  701. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  702. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  703. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  704. return
  705. }
  706. //手术操作集合
  707. //手术操作集合
  708. }
  709. func (c *HisApiController) Check() {
  710. psn_no := c.GetString("psn_no")
  711. in := c.GetString("in")
  712. mt := c.GetString("mt")
  713. baseParams := models.BaseParams{
  714. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  715. FixmedinsCode: "H15049901371",
  716. InsuplcAdmdvs: "150499",
  717. MdtrtareaAdmvs: "150499",
  718. OrgName: "赤峰费森血液透析中心",
  719. Doctor: "1111",
  720. }
  721. service.Gdyb2001(baseParams, psn_no, in, mt)
  722. }
  723. func (c *HisApiController) GetPsnNcdsInfo() {
  724. admin_user_id, _ := c.GetInt64("admin_user_id")
  725. patient_id, _ := c.GetInt64("patient_id")
  726. id, _ := c.GetInt64("id")
  727. adminUser := c.GetAdminUserInfo()
  728. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  729. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  730. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  731. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  732. psn_record, _ := service.GetPsnNCDSRecordById(id)
  733. //
  734. //if psn_record.ID == 0 {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  736. // return
  737. //}
  738. var res Result5301
  739. var res10265 Result5301For10265
  740. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  741. psn_info, _ := service.GetPsnByPatientId(patient_id)
  742. var api string
  743. if miConfig.MdtrtareaAdmvs == "320921" {
  744. api = "http://192.168.2.110:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  745. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  746. } else {
  747. api = "http://192.168.5.251:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  749. }
  750. resp, requestErr := http.Get(api)
  751. if requestErr != nil {
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. body, ioErr := ioutil.ReadAll(resp.Body)
  756. if ioErr != nil {
  757. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. var respJSON map[string]interface{}
  762. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  763. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  765. return
  766. }
  767. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  768. result, _ := json.Marshal(respJSON)
  769. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  770. utils.ErrorLog("解析失败:%v", err)
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  772. return
  773. }
  774. res.ErrMsg = res10265.ErrMsg
  775. res.Output = res10265.Output
  776. res.InfRefmsgid = res10265.InfRefmsgid
  777. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  778. res.Infcode = infocode
  779. } else {
  780. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  781. var dat map[string]interface{}
  782. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  783. fmt.Println(dat)
  784. } else {
  785. fmt.Println(err)
  786. }
  787. userJSONBytes, _ := json.Marshal(dat)
  788. if miConfig.Code == "H15049901371" {
  789. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  790. utils.ErrorLog("解析失败:%v", err)
  791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  792. return
  793. }
  794. res.InfRefmsgid = res10265.InfRefmsgid
  795. res.Output = res10265.Output
  796. res.ErrMsg = res10265.ErrMsg
  797. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  798. res.Infcode = infocode
  799. } else {
  800. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  801. utils.ErrorLog("解析失败:%v", err)
  802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  803. return
  804. }
  805. }
  806. }
  807. if res.Infcode == 0 {
  808. c.ServeSuccessJSON(map[string]interface{}{
  809. "result": res.Output.Result,
  810. })
  811. }
  812. }
  813. func (c *HisApiController) CheckInsutype() {
  814. his_patient_id, _ := c.GetInt64("his_patient_id")
  815. admin_user_id, _ := c.GetInt64("admin_user_id")
  816. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  817. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  818. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  819. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result90100
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Infcode != 0 {
  834. c.ServeSuccessJSON(map[string]interface{}{
  835. "failed_code": -10,
  836. "msg": res.ErrMsg,
  837. })
  838. return
  839. } else {
  840. fmt.Println(res)
  841. }
  842. }
  843. func (c *HisApiController) CheckCardPWD() {
  844. card_pwd := c.GetString("card_pwd")
  845. his_patient_id, _ := c.GetInt64("his_patient_id")
  846. admin_user_id, _ := c.GetInt64("admin_user_id")
  847. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  848. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  849. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  850. psn, _ := service.GetPsnByPatientId(his.PatientId)
  851. bas := strings.Split(psn.CardInfo, "|")
  852. basNumber := bas[2]
  853. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  854. var dat map[string]interface{}
  855. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  856. fmt.Println(dat)
  857. } else {
  858. fmt.Println(err)
  859. }
  860. userJSONBytes, _ := json.Marshal(dat)
  861. var res Result90991
  862. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  863. utils.ErrorLog("解析失败:%v", err)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. if res.Infcode != 0 {
  868. c.ServeSuccessJSON(map[string]interface{}{
  869. "failed_code": -10,
  870. "msg": res.ErrMsg,
  871. })
  872. return
  873. } else {
  874. if res.Output.Result.SscnoCheckStat == "0" {
  875. var msg string
  876. switch res.Output.Result.CardStat {
  877. case "00":
  878. msg = "未激活"
  879. break
  880. case "10":
  881. msg = "激活"
  882. break
  883. case "20":
  884. msg = "窗口挂失"
  885. break
  886. case "21":
  887. msg = "电话挂失"
  888. break
  889. case "22":
  890. msg = "单位网上申报挂失"
  891. break
  892. case "23":
  893. msg = "保健办挂失"
  894. break
  895. case "24":
  896. msg = "个人网上挂失"
  897. break
  898. case "25":
  899. msg = "网上服务大厅挂失"
  900. break
  901. case "30":
  902. msg = "注销"
  903. break
  904. case "40":
  905. msg = "回收"
  906. break
  907. case "99":
  908. msg = "制卡中(无效卡)"
  909. break
  910. }
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "failed_code": -10,
  913. "msg": msg,
  914. })
  915. return
  916. } else {
  917. c.ServeSuccessJSON(map[string]interface{}{
  918. "msg": "校验成功",
  919. })
  920. return
  921. }
  922. }
  923. }
  924. func (c *HisApiController) CheckCardPWDTwo() {
  925. //card_pwd := c.GetString("card_pwd")
  926. //his_patient_id, _ := c.GetInt64("his_patient_id")
  927. admin_user_id, _ := c.GetInt64("admin_user_id")
  928. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  929. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  930. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  931. var dat map[string]interface{}
  932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  933. fmt.Println(dat)
  934. } else {
  935. fmt.Println(err)
  936. }
  937. userJSONBytes, _ := json.Marshal(dat)
  938. var res Result90991
  939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  940. utils.ErrorLog("解析失败:%v", err)
  941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  942. return
  943. }
  944. if res.Infcode != 0 {
  945. c.ServeSuccessJSON(map[string]interface{}{
  946. "failed_code": -10,
  947. "msg": res.ErrMsg,
  948. })
  949. return
  950. } else {
  951. if res.Output.Result.SscnoCheckStat == "0" {
  952. var msg string
  953. switch res.Output.Result.CardStat {
  954. case "00":
  955. msg = "未激活"
  956. break
  957. case "10":
  958. msg = "激活"
  959. break
  960. case "20":
  961. msg = "窗口挂失"
  962. break
  963. case "21":
  964. msg = "电话挂失"
  965. break
  966. case "22":
  967. msg = "单位网上申报挂失"
  968. break
  969. case "23":
  970. msg = "保健办挂失"
  971. break
  972. case "24":
  973. msg = "个人网上挂失"
  974. break
  975. case "25":
  976. msg = "网上服务大厅挂失"
  977. break
  978. case "30":
  979. msg = "注销"
  980. break
  981. case "40":
  982. msg = "回收"
  983. break
  984. case "99":
  985. msg = "制卡中(无效卡)"
  986. break
  987. }
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "failed_code": -10,
  990. "msg": msg,
  991. })
  992. return
  993. } else {
  994. c.ServeSuccessJSON(map[string]interface{}{
  995. "msg": "校验成功",
  996. })
  997. return
  998. }
  999. }
  1000. }
  1001. func (c *HisApiController) ReadCard() {
  1002. id_card_type, _ := c.GetInt64("id_card_type")
  1003. admin_user_id, _ := c.GetInt64("admin_user_id")
  1004. certificates, _ := c.GetInt64("certificates")
  1005. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1006. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1007. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1008. switch id_card_type {
  1009. case 1:
  1010. if miConfig.MdtrtareaAdmvs == "421300" {
  1011. var res ResultTwo
  1012. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1013. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1014. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&card_sn=" + "" + "&certificates=" + strconv.FormatInt(certificates, 10)
  1015. resp, requestErr := http.Get(api)
  1016. if requestErr != nil {
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. body, ioErr := ioutil.ReadAll(resp.Body)
  1021. if ioErr != nil {
  1022. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. var respJSON map[string]interface{}
  1027. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1028. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1030. return
  1031. }
  1032. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1033. result, _ := json.Marshal(respJSON)
  1034. fmt.Println("log")
  1035. fmt.Println(string(result))
  1036. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1037. utils.ErrorLog("解析失败:%v", err)
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1039. return
  1040. }
  1041. if res.Infcode == 0 {
  1042. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1043. if err == gorm.ErrRecordNotFound {
  1044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1045. return
  1046. } else if err != nil {
  1047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1048. return
  1049. } else {
  1050. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1051. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1052. infoStr := string(Iinfos)
  1053. idetinfoStr := string(Idetinfos)
  1054. psn := &models.HisPsn{
  1055. PsnNo: res.Output.Baseinfo.PsnNo,
  1056. Age: res.Output.Baseinfo.Age,
  1057. PatientId: patient.ID,
  1058. Certno: res.Output.Baseinfo.Certno,
  1059. Brdy: res.Output.Baseinfo.Brdy,
  1060. Gend: res.Output.Baseinfo.Gend,
  1061. Naty: res.Output.Baseinfo.Naty,
  1062. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1063. PsnName: res.Output.Baseinfo.PsnName,
  1064. Idetinfo: idetinfoStr,
  1065. Insuinfo: infoStr,
  1066. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1067. }
  1068. service.CreateHisPsn(psn)
  1069. c.ServeSuccessJSON(map[string]interface{}{
  1070. "patient": patient,
  1071. "number": res.Output.Baseinfo.Certno,
  1072. })
  1073. }
  1074. } else {
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1076. return
  1077. }
  1078. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1079. var api string
  1080. if miConfig.MdtrtareaAdmvs == "320921" {
  1081. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1082. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10) + "&operator_id=" + strconv.FormatInt(admin_user_id, 10) + "&operator=" + roles.UserName
  1083. fmt.Println(api)
  1084. } else {
  1085. api = "http://192.168.5.251:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1086. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo + "&id_card_type=" + strconv.FormatInt(id_card_type, 10)
  1087. }
  1088. resp, requestErr := http.Get(api)
  1089. if requestErr != nil {
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. body, ioErr := ioutil.ReadAll(resp.Body)
  1094. if ioErr != nil {
  1095. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var respJSON map[string]interface{}
  1100. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1101. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1103. return
  1104. }
  1105. var status string
  1106. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1107. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1108. //console.log()
  1109. fmt.Println("type===")
  1110. fmt.Println(card_type)
  1111. var token string
  1112. var res ResultTwo //1101结果
  1113. var res10265 ResultTwo10265 //1101结果
  1114. var card_info string //卡信息
  1115. var busi_card_info string
  1116. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1117. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1118. if status == "0" { //读卡成功
  1119. if card_type == "1" {
  1120. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1121. result, _ := json.Marshal(respJSON)
  1122. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1123. utils.ErrorLog("解析失败:%v", err)
  1124. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1125. return
  1126. }
  1127. res.ErrMsg = res10265.ErrMsg
  1128. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1129. res.Infcode = infocode
  1130. res.Output = res10265.Output
  1131. res.InfRefmsgid = res10265.InfRefmsgid
  1132. } else {
  1133. //var card_info string //卡信息
  1134. //var busi_card_info string
  1135. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1136. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1137. //fmt.Println(card_info)
  1138. //fmt.Println(busi_card_info)
  1139. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1140. result, _ := json.Marshal(respJSON)
  1141. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1142. utils.ErrorLog("解析失败:%v", err)
  1143. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1144. return
  1145. }
  1146. res.ErrMsg = res10265.ErrMsg
  1147. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1148. res.Infcode = infocode
  1149. res.Output = res10265.Output
  1150. res.InfRefmsgid = res10265.InfRefmsgid
  1151. }
  1152. if res.Infcode == 0 {
  1153. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1154. if err == gorm.ErrRecordNotFound {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1156. return
  1157. } else if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1159. return
  1160. } else {
  1161. if card_type == "1" {
  1162. bas := strings.Split(card_info, "|")
  1163. basNumber := bas[2]
  1164. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1165. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1166. infoStr := string(Iinfos)
  1167. idetinfoStr := string(Idetinfos)
  1168. psn := &models.HisPsn{
  1169. PsnNo: res.Output.Baseinfo.PsnNo,
  1170. Age: res.Output.Baseinfo.Age,
  1171. PatientId: patient.ID,
  1172. Certno: res.Output.Baseinfo.Certno,
  1173. Brdy: res.Output.Baseinfo.Brdy,
  1174. Gend: res.Output.Baseinfo.Gend,
  1175. Naty: res.Output.Baseinfo.Naty,
  1176. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1177. PsnName: res.Output.Baseinfo.PsnName,
  1178. Idetinfo: idetinfoStr,
  1179. Insuinfo: infoStr,
  1180. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1181. CardInfo: card_info,
  1182. VerifyNumber: busi_card_info,
  1183. }
  1184. service.CreateHisPsn(psn)
  1185. var rf []*ResultFive
  1186. json.Unmarshal([]byte(infoStr), &rf)
  1187. var insutypes []*ResultFive
  1188. var insutype string
  1189. var is390 int = 0
  1190. var is310 int = 0
  1191. for _, item := range rf {
  1192. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1193. insutypes = append(insutypes, item)
  1194. }
  1195. }
  1196. if len(insutypes) == 1 {
  1197. insutype = insutypes[0].Insutype
  1198. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1199. } else {
  1200. for _, i := range insutypes {
  1201. if i.Insutype == "390" {
  1202. is390 = 1
  1203. }
  1204. if i.Insutype == "310" {
  1205. is310 = 1
  1206. }
  1207. }
  1208. }
  1209. if is390 == 1 {
  1210. insutype = "390"
  1211. }
  1212. if is310 == 1 {
  1213. insutype = "310"
  1214. }
  1215. if len(insutypes) == 0 {
  1216. insutype = "310"
  1217. }
  1218. c.ServeSuccessJSON(map[string]interface{}{
  1219. "patient": patient,
  1220. "number": basNumber,
  1221. "insutype": insutype,
  1222. })
  1223. } else {
  1224. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1225. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1226. infoStr := string(Iinfos)
  1227. idetinfoStr := string(Idetinfos)
  1228. psn := &models.HisPsn{
  1229. PsnNo: res.Output.Baseinfo.PsnNo,
  1230. Age: res.Output.Baseinfo.Age,
  1231. PatientId: patient.ID,
  1232. Certno: res.Output.Baseinfo.Certno,
  1233. Brdy: res.Output.Baseinfo.Brdy,
  1234. Gend: res.Output.Baseinfo.Gend,
  1235. Naty: res.Output.Baseinfo.Naty,
  1236. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1237. PsnName: res.Output.Baseinfo.PsnName,
  1238. Idetinfo: idetinfoStr,
  1239. Insuinfo: infoStr,
  1240. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1241. CardInfo: card_info,
  1242. VerifyNumber: token,
  1243. }
  1244. service.CreateHisPsn(psn)
  1245. c.ServeSuccessJSON(map[string]interface{}{
  1246. "patient": patient,
  1247. "number": token,
  1248. })
  1249. }
  1250. }
  1251. } else {
  1252. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1253. return
  1254. }
  1255. } else { //读卡失败
  1256. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1257. return
  1258. }
  1259. } else if miConfig.MdtrtareaAdmvs == "350500" {
  1260. cardnum, cardCode, id_card_no, name, errmsg := c.GetFjBasBaseInfo()
  1261. cardnum = DeleteExtraSpaceTwo(cardnum)
  1262. cardCode = DeleteExtraSpaceTwo(cardCode)
  1263. id_card_no = DeleteExtraSpaceTwo(id_card_no)
  1264. name = DeleteExtraSpaceTwo(name)
  1265. errmsg = DeleteExtraSpaceTwo(errmsg)
  1266. cardnum = Remove0000(cardnum)
  1267. cardCode = Remove0000(cardCode)
  1268. id_card_no = Remove0000(id_card_no)
  1269. name = Remove0000(name)
  1270. errmsg = Remove0000(errmsg)
  1271. basStr := cardnum + "|" + cardCode + "|" + id_card_no + "|" + name
  1272. result, requestLog, errMsgLog := service.FJyb1101(cardnum, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, id_card_type, cardCode, certificates, miConfig.Url, miConfig.Cainfo, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  1273. saveLog(result, requestLog, "1101", "获取人员信息")
  1274. fmt.Println(errMsgLog)
  1275. var dat map[string]interface{}
  1276. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1277. fmt.Println(dat)
  1278. } else {
  1279. fmt.Println(err)
  1280. }
  1281. userJSONBytes, _ := json.Marshal(dat)
  1282. var res ResultTwo
  1283. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1284. utils.ErrorLog("解析失败:%v", err)
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1286. return
  1287. }
  1288. res.ErrMsg = errMsgLog
  1289. if res.Infcode == 0 {
  1290. patient, err := service.GetPatientByNumber(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  1291. if err == gorm.ErrRecordNotFound {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1293. return
  1294. } else if err != nil {
  1295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1296. return
  1297. } else {
  1298. fmt.Println(res)
  1299. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1300. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1301. infoStr := string(Iinfos)
  1302. idetinfoStr := string(Idetinfos)
  1303. psn := &models.HisPsn{
  1304. PsnNo: res.Output.Baseinfo.PsnNo,
  1305. Age: res.Output.Baseinfo.Age,
  1306. PatientId: patient.ID,
  1307. Certno: res.Output.Baseinfo.Certno,
  1308. Brdy: res.Output.Baseinfo.Brdy,
  1309. Gend: res.Output.Baseinfo.Gend,
  1310. Naty: res.Output.Baseinfo.Naty,
  1311. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1312. PsnName: res.Output.Baseinfo.PsnName,
  1313. Idetinfo: idetinfoStr,
  1314. Insuinfo: infoStr,
  1315. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1316. CardInfo: basStr,
  1317. VerifyNumber: "",
  1318. }
  1319. service.CreateHisPsn(psn)
  1320. var rf []*ResultFive
  1321. json.Unmarshal([]byte(infoStr), &rf)
  1322. var insutypes []*ResultFive
  1323. var insutype string
  1324. var is390 int = 0
  1325. var is310 int = 0
  1326. for _, item := range rf {
  1327. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1328. insutypes = append(insutypes, item)
  1329. }
  1330. }
  1331. if len(insutypes) == 1 {
  1332. insutype = insutypes[0].Insutype
  1333. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1334. } else {
  1335. for _, i := range insutypes {
  1336. if i.Insutype == "390" {
  1337. is390 = 1
  1338. }
  1339. if i.Insutype == "310" {
  1340. is310 = 1
  1341. }
  1342. }
  1343. }
  1344. if is390 == 1 {
  1345. insutype = "390"
  1346. }
  1347. if is310 == 1 {
  1348. insutype = "310"
  1349. }
  1350. if len(insutypes) == 0 {
  1351. insutype = "310"
  1352. }
  1353. c.ServeSuccessJSON(map[string]interface{}{
  1354. "patient": patient,
  1355. "number": cardnum,
  1356. "insutype": insutype,
  1357. })
  1358. }
  1359. } else {
  1360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1361. return
  1362. }
  1363. } else {
  1364. if initFlag == 0 {
  1365. c.TestGetBasBaseInit()
  1366. }
  1367. basStr := c.GetBasBaseInfo()
  1368. if len(basStr) == 0 {
  1369. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1370. return
  1371. }
  1372. fmt.Println(basStr)
  1373. bas := strings.Split(basStr, "|")
  1374. basNumber := bas[1]
  1375. fmt.Println(basNumber)
  1376. card_sn := bas[3]
  1377. fmt.Println(card_sn)
  1378. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1379. var dat map[string]interface{}
  1380. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1381. fmt.Println(dat)
  1382. } else {
  1383. fmt.Println(err)
  1384. }
  1385. userJSONBytes, _ := json.Marshal(dat)
  1386. var res ResultTwo
  1387. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1388. utils.ErrorLog("解析失败:%v", err)
  1389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1390. return
  1391. }
  1392. if res.Infcode == 0 {
  1393. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1394. if err == gorm.ErrRecordNotFound {
  1395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1396. return
  1397. } else if err != nil {
  1398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1399. return
  1400. } else {
  1401. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1402. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1403. infoStr := string(Iinfos)
  1404. idetinfoStr := string(Idetinfos)
  1405. psn := &models.HisPsn{
  1406. PsnNo: res.Output.Baseinfo.PsnNo,
  1407. Age: res.Output.Baseinfo.Age,
  1408. PatientId: patient.ID,
  1409. Certno: res.Output.Baseinfo.Certno,
  1410. Brdy: res.Output.Baseinfo.Brdy,
  1411. Gend: res.Output.Baseinfo.Gend,
  1412. Naty: res.Output.Baseinfo.Naty,
  1413. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1414. PsnName: res.Output.Baseinfo.PsnName,
  1415. Idetinfo: idetinfoStr,
  1416. Insuinfo: infoStr,
  1417. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1418. CardInfo: basStr,
  1419. VerifyNumber: "",
  1420. }
  1421. service.CreateHisPsn(psn)
  1422. c.ServeSuccessJSON(map[string]interface{}{
  1423. "patient": patient,
  1424. "number": basNumber,
  1425. })
  1426. }
  1427. } else {
  1428. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1429. return
  1430. }
  1431. break
  1432. }
  1433. case 2:
  1434. SFZStr := c.GetSFZBaseInfo()
  1435. id_card_str := strings.Split(SFZStr, "^")
  1436. id_card_number := id_card_str[0]
  1437. card_sn := ""
  1438. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1439. var dat map[string]interface{}
  1440. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1441. fmt.Println(dat)
  1442. } else {
  1443. fmt.Println(err)
  1444. }
  1445. userJSONBytes, _ := json.Marshal(dat)
  1446. var res ResultTwo
  1447. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1448. utils.ErrorLog("解析失败:%v", err)
  1449. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1450. return
  1451. }
  1452. if res.Infcode == 0 {
  1453. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1454. if err == gorm.ErrRecordNotFound {
  1455. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1456. return
  1457. } else if err != nil {
  1458. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1459. return
  1460. } else {
  1461. c.ServeSuccessJSON(map[string]interface{}{
  1462. "patient": patient,
  1463. "number": id_card_number,
  1464. })
  1465. }
  1466. } else {
  1467. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1468. return
  1469. }
  1470. break
  1471. case 3:
  1472. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1473. var api string
  1474. if miConfig.MdtrtareaAdmvs == "320921" {
  1475. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1476. "&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
  1477. fmt.Println(api)
  1478. } else {
  1479. 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 +
  1480. "&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)
  1481. }
  1482. resp, requestErr := http.Get(api)
  1483. if requestErr != nil {
  1484. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1485. return
  1486. }
  1487. body, ioErr := ioutil.ReadAll(resp.Body)
  1488. if ioErr != nil {
  1489. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1490. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1491. return
  1492. }
  1493. var respJSON map[string]interface{}
  1494. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1495. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1497. return
  1498. }
  1499. var status string
  1500. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1501. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1502. var token string
  1503. var res ResultTwo //1101结果
  1504. var res10265 ResultTwo10265 //1101结果
  1505. var card_info string //卡信息
  1506. var busi_card_info string
  1507. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1508. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1509. if status == "0" { //读卡成功
  1510. if card_type == "1" {
  1511. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1512. result, _ := json.Marshal(respJSON)
  1513. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1514. utils.ErrorLog("解析失败:%v", err)
  1515. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1516. return
  1517. }
  1518. res.ErrMsg = res10265.ErrMsg
  1519. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1520. res.Infcode = infocode
  1521. res.Output = res10265.Output
  1522. res.InfRefmsgid = res10265.InfRefmsgid
  1523. } else {
  1524. //var card_info string //卡信息
  1525. //var busi_card_info string
  1526. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1527. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1528. //fmt.Println(card_info)
  1529. //fmt.Println(busi_card_info)
  1530. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1531. result, _ := json.Marshal(respJSON)
  1532. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1533. utils.ErrorLog("解析失败:%v", err)
  1534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1535. return
  1536. }
  1537. res.ErrMsg = res10265.ErrMsg
  1538. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1539. res.Infcode = infocode
  1540. res.Output = res10265.Output
  1541. res.InfRefmsgid = res10265.InfRefmsgid
  1542. }
  1543. if res.Infcode == 0 {
  1544. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1545. if err == gorm.ErrRecordNotFound {
  1546. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1547. return
  1548. } else if err != nil {
  1549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1550. return
  1551. } else {
  1552. if card_type == "1" {
  1553. bas := strings.Split(card_info, "|")
  1554. basNumber := bas[2]
  1555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1557. infoStr := string(Iinfos)
  1558. idetinfoStr := string(Idetinfos)
  1559. psn := &models.HisPsn{
  1560. PsnNo: res.Output.Baseinfo.PsnNo,
  1561. Age: res.Output.Baseinfo.Age,
  1562. PatientId: patient.ID,
  1563. Certno: res.Output.Baseinfo.Certno,
  1564. Brdy: res.Output.Baseinfo.Brdy,
  1565. Gend: res.Output.Baseinfo.Gend,
  1566. Naty: res.Output.Baseinfo.Naty,
  1567. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1568. PsnName: res.Output.Baseinfo.PsnName,
  1569. Idetinfo: idetinfoStr,
  1570. Insuinfo: infoStr,
  1571. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1572. CardInfo: card_info,
  1573. VerifyNumber: busi_card_info,
  1574. }
  1575. service.CreateHisPsn(psn)
  1576. c.ServeSuccessJSON(map[string]interface{}{
  1577. "patient": patient,
  1578. "number": basNumber,
  1579. })
  1580. } else {
  1581. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1582. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1583. infoStr := string(Iinfos)
  1584. idetinfoStr := string(Idetinfos)
  1585. psn := &models.HisPsn{
  1586. PsnNo: res.Output.Baseinfo.PsnNo,
  1587. Age: res.Output.Baseinfo.Age,
  1588. PatientId: patient.ID,
  1589. Certno: res.Output.Baseinfo.Certno,
  1590. Brdy: res.Output.Baseinfo.Brdy,
  1591. Gend: res.Output.Baseinfo.Gend,
  1592. Naty: res.Output.Baseinfo.Naty,
  1593. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1594. PsnName: res.Output.Baseinfo.PsnName,
  1595. Idetinfo: idetinfoStr,
  1596. Insuinfo: infoStr,
  1597. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1598. CardInfo: card_info,
  1599. VerifyNumber: token,
  1600. }
  1601. service.CreateHisPsn(psn)
  1602. var rf []*ResultFive
  1603. json.Unmarshal([]byte(infoStr), &rf)
  1604. var insutypes []*ResultFive
  1605. var insutype string
  1606. var is390 int = 0
  1607. var is310 int = 0
  1608. for _, item := range rf {
  1609. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1610. insutypes = append(insutypes, item)
  1611. }
  1612. }
  1613. if len(insutypes) == 1 {
  1614. insutype = insutypes[0].Insutype
  1615. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1616. } else {
  1617. for _, i := range insutypes {
  1618. if i.Insutype == "390" {
  1619. is390 = 1
  1620. }
  1621. if i.Insutype == "310" {
  1622. is310 = 1
  1623. }
  1624. }
  1625. }
  1626. if is390 == 1 {
  1627. insutype = "390"
  1628. }
  1629. if is310 == 1 {
  1630. insutype = "310"
  1631. }
  1632. if len(insutypes) == 0 {
  1633. insutype = "310"
  1634. }
  1635. c.ServeSuccessJSON(map[string]interface{}{
  1636. "patient": patient,
  1637. "number": token,
  1638. "insutype": insutype,
  1639. })
  1640. }
  1641. }
  1642. } else {
  1643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1644. return
  1645. }
  1646. } else { //读卡失败
  1647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1648. return
  1649. }
  1650. }
  1651. break
  1652. case 4:
  1653. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1654. var api string
  1655. if miConfig.MdtrtareaAdmvs == "320921" {
  1656. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1657. "&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
  1658. fmt.Println(api)
  1659. } else {
  1660. 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 +
  1661. "&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)
  1662. }
  1663. resp, requestErr := http.Get(api)
  1664. if requestErr != nil {
  1665. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1666. return
  1667. }
  1668. body, ioErr := ioutil.ReadAll(resp.Body)
  1669. if ioErr != nil {
  1670. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. return
  1673. }
  1674. var respJSON map[string]interface{}
  1675. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1676. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1678. return
  1679. }
  1680. var status string
  1681. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1682. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1683. var token string
  1684. var res ResultTwo //1101结果
  1685. var res10265 ResultTwo10265 //1101结果
  1686. if status == "0" { //读卡成功
  1687. var card_info string //卡信息
  1688. var busi_card_info string
  1689. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1690. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1691. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1692. fmt.Println(card_info)
  1693. fmt.Println(busi_card_info)
  1694. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1695. result, _ := json.Marshal(respJSON)
  1696. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1697. utils.ErrorLog("解析失败:%v", err)
  1698. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1699. return
  1700. }
  1701. res.ErrMsg = res10265.ErrMsg
  1702. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1703. res.Infcode = infocode
  1704. res.Output = res10265.Output
  1705. res.InfRefmsgid = res10265.InfRefmsgid
  1706. if res.Infcode == 0 {
  1707. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1708. if err == gorm.ErrRecordNotFound {
  1709. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1710. return
  1711. } else if err != nil {
  1712. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1713. return
  1714. } else {
  1715. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1716. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1717. infoStr := string(Iinfos)
  1718. idetinfoStr := string(Idetinfos)
  1719. psn := &models.HisPsn{
  1720. PsnNo: res.Output.Baseinfo.PsnNo,
  1721. Age: res.Output.Baseinfo.Age,
  1722. PatientId: patient.ID,
  1723. Certno: res.Output.Baseinfo.Certno,
  1724. Brdy: res.Output.Baseinfo.Brdy,
  1725. Gend: res.Output.Baseinfo.Gend,
  1726. Naty: res.Output.Baseinfo.Naty,
  1727. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1728. PsnName: res.Output.Baseinfo.PsnName,
  1729. Idetinfo: idetinfoStr,
  1730. Insuinfo: infoStr,
  1731. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1732. CardInfo: card_info,
  1733. VerifyNumber: token,
  1734. }
  1735. service.CreateHisPsn(psn)
  1736. c.ServeSuccessJSON(map[string]interface{}{
  1737. "patient": patient,
  1738. "number": token,
  1739. })
  1740. }
  1741. } else {
  1742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1743. return
  1744. }
  1745. } else { //读卡失败
  1746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1747. return
  1748. }
  1749. } else if miConfig.MdtrtareaAdmvs == "440300" || miConfig.MdtrtareaAdmvs == "440305" {
  1750. }
  1751. break
  1752. }
  1753. }
  1754. var initFlag int64 = 0
  1755. func (c *HisApiController) TestGetBasBaseInit() {
  1756. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1757. Iinit := DllDef.MustFindProc("Init")
  1758. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1759. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1760. if ret != 0 {
  1761. fmt.Println("SSCard的报错原因:", err)
  1762. fmt.Println("SSCard的运算结果为:", ret)
  1763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1764. return
  1765. }
  1766. result := int(ret)
  1767. fmt.Println("SSCard的运算结果为1:", result)
  1768. initFlag = 1
  1769. return
  1770. }
  1771. func (c *HisApiController) GetSFZBaseInfo() string {
  1772. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1773. readCard := DllDef.MustFindProc("ReadSFZ")
  1774. if readCard == nil {
  1775. fmt.Println("readcard is nil")
  1776. readCard = DllDef.MustFindProc("ReadSFZ")
  1777. }
  1778. str := make([]byte, 256)
  1779. str1 := make([]byte, 256)
  1780. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1781. fmt.Println(r)
  1782. return string(str)
  1783. }
  1784. func (c *HisApiController) GetBasBaseInfo() string {
  1785. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1786. readCard := DllDef.MustFindProc("ReadCardBas")
  1787. if readCard == nil {
  1788. fmt.Println("readcard is nil")
  1789. readCard = DllDef.MustFindProc("ReadCardBas")
  1790. }
  1791. str := make([]byte, 1024)
  1792. str1 := make([]byte, 1024)
  1793. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1794. fmt.Println(string(str1))
  1795. fmt.Println(string(str))
  1796. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1797. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1798. if ret2 != 0 {
  1799. return ""
  1800. }
  1801. return string(str)
  1802. }
  1803. func (c *HisApiController) GetFjBasBaseInfo() (string, string, string, string, string) {
  1804. DllDef := syscall.MustLoadDLL("chs_fjs_standard.dll")
  1805. readCard := DllDef.MustFindProc("read_cardinfo")
  1806. if readCard == nil {
  1807. fmt.Println("readcard is nil")
  1808. readCard = DllDef.MustFindProc("read_cardinfo")
  1809. }
  1810. str := make([]byte, 1024) //卡号
  1811. str1 := make([]byte, 1024) //卡识别码
  1812. str2 := make([]byte, 1024) //身份证号
  1813. str3 := make([]byte, 1024) //姓名
  1814. str4 := make([]byte, 1024) //错误信息
  1815. 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])))
  1816. fmt.Println(string(str1))
  1817. fmt.Println(string(str))
  1818. fmt.Println(string(str2))
  1819. fmt.Println(string(str3))
  1820. fmt.Println(string(str4))
  1821. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1822. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1823. fmt.Println(":", ConvertToString(string(str2), "gbk", "utf-8"))
  1824. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  1825. fmt.Println(":", ConvertToString(string(str4), "gbk", "utf-8"))
  1826. if ret2 != 0 {
  1827. return "", "", "", "", ""
  1828. }
  1829. return string(str), string(str1), string(str2), string(str3), string(str4)
  1830. }
  1831. type CustomFundPay struct {
  1832. FundPayType string `json:"fund_pay_type"`
  1833. FundPayamt float64 `json:"fund_payamt"`
  1834. }
  1835. func (c *HisApiController) GetSettleList() {
  1836. order_id, _ := c.GetInt64("order_id")
  1837. admin_user_id, _ := c.GetInt64("admin_user_id")
  1838. order, _ := service.GetHisOrderByIDTwo(order_id)
  1839. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1840. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1841. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1842. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1843. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1844. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1845. if order.ID == 0 {
  1846. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1847. return
  1848. }
  1849. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1850. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1851. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1852. fmt.Println(count)
  1853. var zero string
  1854. number := count + 1
  1855. if number >= 1000 {
  1856. zero = "0000" + strconv.FormatInt(number, 10)
  1857. } else if number >= 10000 {
  1858. zero = "000" + strconv.FormatInt(number, 10)
  1859. } else if number >= 100000 {
  1860. zero = "00" + strconv.FormatInt(number, 10)
  1861. } else if number >= 1000000 {
  1862. zero = "0" + strconv.FormatInt(number, 10)
  1863. } else {
  1864. zero = strconv.FormatInt(number, 10)
  1865. }
  1866. fmt.Println(zero)
  1867. struct4101 := service.Struct4101{
  1868. PsnNo: order.PsnNo,
  1869. MdtrtId: order.MdtrtId,
  1870. SetlId: order.SetlId,
  1871. PsnName: order.PsnName,
  1872. Gend: order.Gend,
  1873. Brdy: his.Brdy,
  1874. Age: his.Age,
  1875. Naty: order.Naty,
  1876. PatnCertType: "01",
  1877. Certno: order.Certno,
  1878. Prfs: "90",
  1879. ConerName: roles[0].UserName,
  1880. PatnRlts: "99",
  1881. ConerAddr: miConfig.OrgName,
  1882. ConerTel: admin.Mobile,
  1883. HiType: order.Insutype,
  1884. Insuplc: miConfig.InsuplcAdmdvs,
  1885. MaindiagFlag: "1",
  1886. BillCode: last_order.FaPiaoCode,
  1887. BillNo: zero,
  1888. BizSn: order.Number,
  1889. PsnSelfPay: order.PsnPartAmt,
  1890. PsnOwnPay: order.PsnPartAmt,
  1891. AcctPay: order.AcctPay,
  1892. PsnCashpay: order.PsnCashPay,
  1893. HiPaymtd: "1",
  1894. Hsorg: miConfig.InsuplcAdmdvs,
  1895. HsorgOpter: miConfig.InsuplcAdmdvs,
  1896. MedinsFillPsn: curRoles.UserName,
  1897. MedinsFillDept: depart.Name,
  1898. IptMedType: "2",
  1899. }
  1900. struct4101.SetlBegnDate = order.SetlTime
  1901. struct4101.SetlEndDate = order.SetlTime
  1902. time_arr := strings.Split(order.SetlTime, " ")
  1903. struct4101.AdmTime = time_arr[0]
  1904. struct4101.AdmEndTime = time_arr[0]
  1905. var rf []CustomFundPay
  1906. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1907. var tempFunPays []service.CustomStruct
  1908. for _, item := range rf {
  1909. var tempFunPay service.CustomStruct
  1910. tempFunPay.FundPayamt = item.FundPayamt
  1911. tempFunPay.FundPayType = item.FundPayType
  1912. tempFunPays = append(tempFunPays, tempFunPay)
  1913. }
  1914. struct4101.CustomStruct = tempFunPays
  1915. var tempDiaginfos []service.DiaginfoStructTwo
  1916. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1917. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1918. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1919. var config []*models.HisXtDiagnoseConfig
  1920. for _, item := range diagnosis_ids {
  1921. id, _ := strconv.ParseInt(item, 10, 64)
  1922. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1923. config = append(config, &diagnosisConfig)
  1924. }
  1925. for index, item := range config {
  1926. if index == 0 {
  1927. var tempDiaginfo service.DiaginfoStructTwo
  1928. tempDiaginfo.DiagCode = item.CountryCode
  1929. tempDiaginfo.DiagName = item.CountryContentName
  1930. tempDiaginfo.DiagType = "1"
  1931. tempDiaginfo.MaindiagFlag = "1"
  1932. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1933. } else {
  1934. var tempDiaginfo service.DiaginfoStructTwo
  1935. tempDiaginfo.DiagCode = item.CountryCode
  1936. tempDiaginfo.DiagName = item.CountryContentName
  1937. tempDiaginfo.DiagType = "2"
  1938. tempDiaginfo.MaindiagFlag = "0"
  1939. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1940. }
  1941. }
  1942. struct4101.Diseinfo = tempDiaginfos
  1943. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1944. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1945. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1946. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1947. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1948. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1949. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1950. var iteminfo service.IteminfoStruct
  1951. var bedCostTotal float64 = 0 //床位总费
  1952. var bedCostSelfTotal float64 = 0 //床位自费
  1953. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1954. var operationCostTotal float64 = 0 //手术费
  1955. var operationCostSelfTotal float64 = 0 //手术费
  1956. var operationCostPartSelfTotal float64 = 0 //手术费
  1957. var otherCostTotal float64 = 0 //其他费用
  1958. var otherCostSelfTotal float64 = 0 //其他费用
  1959. var otherCostPartSelfTotal float64 = 0 //其他费用
  1960. var materialCostTotal float64 = 0 //材料费
  1961. var materialCostSelfTotal float64 = 0 //材料费
  1962. var materialCostPartSelfTotal float64 = 0 //材料费
  1963. var westernMedicineCostTotal float64 = 0 //西药费
  1964. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1965. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1966. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1967. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1968. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1969. var checkCostTotal float64 = 0 //检查费
  1970. var checkCostSelfTotal float64 = 0 //检查费
  1971. var checkCostPartSelfTotal float64 = 0 //检查费
  1972. var laboratoryCostTotal float64 = 0 //化验费
  1973. var laboratoryCostSelfTotal float64 = 0 //化验费
  1974. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1975. var treatCostTotal float64 = 0 //治疗费用
  1976. var treatCostSelfTotal float64 = 0 //治疗费用
  1977. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1978. decimal.DivisionPrecision = 2
  1979. var bed_fulamt_ownpay_amt float64 = 0
  1980. var operation_fulamt_ownpay_amt float64 = 0
  1981. var other_fulamt_ownpay_amt float64 = 0
  1982. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1983. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1984. var check_fulamt_ownpay_amt float64 = 0
  1985. var material_fulamt_ownpay_amt float64 = 0
  1986. var laboratory_fulamt_ownpay_amt float64 = 0
  1987. var treat_fulamt_ownpay_amt float64 = 0
  1988. var bed_claa_sunmfee float64 = 0
  1989. var bed_clab_amt float64 = 0
  1990. var bed_other_amt float64 = 0
  1991. var operation_claa_sunmfee float64 = 0
  1992. var operation_clab_amt float64 = 0
  1993. var operation_other_amt float64 = 0
  1994. var other_claa_sunmfee float64 = 0
  1995. var other_clab_amt float64 = 0
  1996. var other_other_amt float64 = 0
  1997. var westernMedicine_claa_sunmfee float64 = 0
  1998. var westernMedicine_clab_amt float64 = 0
  1999. var westernMedicine_other_amt float64 = 0
  2000. var chineseTraditional_claa_sunmfee float64 = 0
  2001. var chineseTraditional_clab_amt float64 = 0
  2002. var chineseTraditional_other_amt float64 = 0
  2003. var check_claa_sunmfee float64 = 0
  2004. var check_clab_amt float64 = 0
  2005. var check_other_amt float64 = 0
  2006. var material_claa_sunmfee float64 = 0
  2007. var material_clab_amt float64 = 0
  2008. var material_other_amt float64 = 0
  2009. var laboratory_claa_sunmfee float64 = 0
  2010. var laboratory_clab_amt float64 = 0
  2011. var laboratory_other_amt float64 = 0
  2012. var treat_claa_sunmfee float64 = 0
  2013. var treat_clab_amt float64 = 0
  2014. var treat_other_amt float64 = 0
  2015. for _, item := range order.HisOrderInfo {
  2016. if item.MedChrgitmType == "01" { //床位费
  2017. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2018. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2019. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2020. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2021. if item.ChrgitmLv == "1" {
  2022. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2023. }
  2024. if item.ChrgitmLv == "2" {
  2025. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2026. }
  2027. if item.ChrgitmLv == "3" {
  2028. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2029. }
  2030. }
  2031. if item.MedChrgitmType == "03" { //检查费
  2032. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2033. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2034. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2035. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2036. if item.ChrgitmLv == "1" {
  2037. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2038. }
  2039. if item.ChrgitmLv == "2" {
  2040. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2041. }
  2042. if item.ChrgitmLv == "3" {
  2043. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2044. }
  2045. }
  2046. if item.MedChrgitmType == "04" { //化验费
  2047. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2048. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2049. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2050. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2051. if item.ChrgitmLv == "1" {
  2052. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2053. }
  2054. if item.ChrgitmLv == "2" {
  2055. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2056. }
  2057. if item.ChrgitmLv == "3" {
  2058. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2059. }
  2060. }
  2061. if item.MedChrgitmType == "05" { //治疗费
  2062. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2063. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2064. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2065. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2066. if item.ChrgitmLv == "1" {
  2067. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2068. }
  2069. if item.ChrgitmLv == "2" {
  2070. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2071. }
  2072. if item.ChrgitmLv == "3" {
  2073. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2074. }
  2075. }
  2076. if item.MedChrgitmType == "06" { //手术费
  2077. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2078. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2079. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2080. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2081. if item.ChrgitmLv == "1" {
  2082. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2083. }
  2084. if item.ChrgitmLv == "2" {
  2085. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2086. }
  2087. if item.ChrgitmLv == "3" {
  2088. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2089. }
  2090. }
  2091. if item.MedChrgitmType == "08" { //材料费
  2092. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2093. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2094. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2095. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2096. if item.ChrgitmLv == "1" {
  2097. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2098. }
  2099. if item.ChrgitmLv == "2" {
  2100. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2101. }
  2102. if item.ChrgitmLv == "3" {
  2103. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2104. }
  2105. }
  2106. if item.MedChrgitmType == "09" { //西药费
  2107. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2108. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2109. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2110. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2111. if item.ChrgitmLv == "1" {
  2112. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2113. }
  2114. if item.ChrgitmLv == "2" {
  2115. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2116. }
  2117. if item.ChrgitmLv == "3" {
  2118. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2119. }
  2120. }
  2121. if item.MedChrgitmType == "11" { //中成费
  2122. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2123. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2124. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2125. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2126. if item.ChrgitmLv == "1" {
  2127. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2128. }
  2129. if item.ChrgitmLv == "2" {
  2130. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2131. }
  2132. if item.ChrgitmLv == "3" {
  2133. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2134. }
  2135. }
  2136. if item.MedChrgitmType == "14" { //其他费
  2137. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2138. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2139. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2140. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2141. if item.ChrgitmLv == "1" {
  2142. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2143. }
  2144. if item.ChrgitmLv == "2" {
  2145. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2146. }
  2147. if item.ChrgitmLv == "3" {
  2148. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2149. }
  2150. }
  2151. }
  2152. var iteminfoStructs []service.IteminfoStruct
  2153. if bedCostTotal != 0 {
  2154. iteminfo.MedChrgitm = "01"
  2155. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2156. iteminfo.Amt = bedCostTotal
  2157. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2158. iteminfo.ClabAmt = bed_clab_amt
  2159. iteminfo.OthAmt = bed_other_amt
  2160. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2161. }
  2162. if checkCostTotal != 0 {
  2163. iteminfo.MedChrgitm = "03"
  2164. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2165. iteminfo.Amt = checkCostTotal
  2166. iteminfo.ClaaSumfee = check_claa_sunmfee
  2167. iteminfo.ClabAmt = check_clab_amt
  2168. iteminfo.OthAmt = check_other_amt
  2169. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2170. }
  2171. if laboratoryCostTotal != 0 {
  2172. iteminfo.MedChrgitm = "04"
  2173. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2174. iteminfo.Amt = laboratoryCostTotal
  2175. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2176. iteminfo.ClabAmt = laboratory_clab_amt
  2177. iteminfo.OthAmt = laboratory_other_amt
  2178. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2179. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2180. }
  2181. if treatCostTotal != 0 {
  2182. iteminfo.MedChrgitm = "05"
  2183. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2184. iteminfo.Amt = treatCostTotal
  2185. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2186. iteminfo.ClabAmt = treat_clab_amt
  2187. iteminfo.OthAmt = treat_other_amt
  2188. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2189. //(struct4101.IteminfoStruct, iteminfo)
  2190. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2191. }
  2192. if operationCostTotal != 0 {
  2193. iteminfo.MedChrgitm = "06"
  2194. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2195. iteminfo.Amt = operationCostTotal
  2196. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2197. iteminfo.ClabAmt = operation_clab_amt
  2198. iteminfo.OthAmt = operation_other_amt
  2199. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2200. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2201. }
  2202. if materialCostTotal != 0 {
  2203. iteminfo.MedChrgitm = "08"
  2204. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2205. iteminfo.Amt = materialCostTotal
  2206. iteminfo.ClaaSumfee = material_claa_sunmfee
  2207. iteminfo.ClabAmt = material_clab_amt
  2208. iteminfo.OthAmt = material_other_amt
  2209. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2210. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2211. }
  2212. if westernMedicineCostTotal != 0 {
  2213. iteminfo.MedChrgitm = "09"
  2214. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2215. iteminfo.Amt = westernMedicineCostTotal
  2216. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2217. iteminfo.ClabAmt = westernMedicine_clab_amt
  2218. iteminfo.OthAmt = westernMedicine_other_amt
  2219. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2220. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2221. }
  2222. if chineseTraditionalMedicineCostTotal != 0 {
  2223. iteminfo.MedChrgitm = "11"
  2224. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2225. iteminfo.Amt = westernMedicineCostTotal
  2226. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2227. iteminfo.ClabAmt = westernMedicine_clab_amt
  2228. iteminfo.OthAmt = westernMedicine_other_amt
  2229. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2230. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2231. }
  2232. if otherCostTotal != 0 {
  2233. iteminfo.MedChrgitm = "14"
  2234. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2235. iteminfo.Amt = otherCostTotal
  2236. iteminfo.ClaaSumfee = other_claa_sunmfee
  2237. iteminfo.ClabAmt = other_clab_amt
  2238. iteminfo.OthAmt = other_other_amt
  2239. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2240. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2241. }
  2242. struct4101.IteminfoStruct = iteminfoStructs
  2243. struct4101.Ntly = "中国"
  2244. struct4101.AdmCaty = "A03.06"
  2245. var res ResultSeventeen
  2246. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  2247. var resOther ResultSeventeenOther
  2248. var pp models.PublicParams
  2249. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  2250. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  2251. pp.FixmedinsName = miConfig.OrgName
  2252. pp.FixmedinsCode = miConfig.Code
  2253. pp.RequestUrl = miConfig.Url
  2254. pp.Cainfo = miConfig.Cainfo
  2255. pp.SecretKey = miConfig.SecretKey
  2256. pp.AccessKey = miConfig.AccessKey
  2257. pp.OpterName = curRoles.UserName
  2258. client := &http.Client{}
  2259. var req *http.Request
  2260. data := make(map[string]interface{})
  2261. data["struct4101"] = struct4101
  2262. data["pp"] = pp
  2263. bytesData, _ := json.Marshal(data)
  2264. if miConfig.MdtrtareaAdmvs == "320921" {
  2265. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2266. } else {
  2267. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/4101", bytes.NewReader(bytesData))
  2268. }
  2269. resp, _ := client.Do(req)
  2270. defer resp.Body.Close()
  2271. body, ioErr := ioutil.ReadAll(resp.Body)
  2272. if ioErr != nil {
  2273. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2274. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2275. return
  2276. }
  2277. var respJSON map[string]interface{}
  2278. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2279. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2280. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2281. return
  2282. }
  2283. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2284. userJSONBytes, _ := json.Marshal(respJSON)
  2285. fmt.Println("log")
  2286. fmt.Println(string(userJSONBytes))
  2287. if err := json.Unmarshal(userJSONBytes, &resOther); err != nil {
  2288. utils.ErrorLog("解析失败:%v", err)
  2289. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2290. return
  2291. }
  2292. res.InfRefmsgid = resOther.InfRefmsgid
  2293. res.Output = resOther.Output
  2294. res.ErrMsg = resOther.ErrMsg
  2295. infocode, _ := strconv.ParseInt(resOther.Infcode, 10, 64)
  2296. res.Infcode = infocode
  2297. } else {
  2298. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2299. var dat map[string]interface{}
  2300. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2301. fmt.Println(dat)
  2302. } else {
  2303. fmt.Println(err)
  2304. }
  2305. userJSONBytes, _ := json.Marshal(dat)
  2306. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2307. utils.ErrorLog("解析失败:%v", err)
  2308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2309. return
  2310. }
  2311. }
  2312. if res.Infcode != 0 {
  2313. c.ServeSuccessJSON(map[string]interface{}{
  2314. "failed_code": -10,
  2315. "msg": res.ErrMsg,
  2316. })
  2317. return
  2318. } else {
  2319. order.FaPiaoNumber = zero
  2320. order.FaPiaoCode = last_order.FaPiaoCode
  2321. service.UpdateOrder(order)
  2322. hisFundSettleListResult := &models.HisFundSettleListResult{
  2323. Number: res.Output.SetlListId,
  2324. Status: 1,
  2325. Ctime: time.Now().Unix(),
  2326. Mtime: time.Now().Unix(),
  2327. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2328. IsUpload: 1,
  2329. OrderId: order_id,
  2330. }
  2331. service.CreateUploadRecord(hisFundSettleListResult)
  2332. c.ServeSuccessJSON(map[string]interface{}{
  2333. "msg": "上传成功",
  2334. "result": hisFundSettleListResult,
  2335. })
  2336. return
  2337. }
  2338. }
  2339. func (c *HisApiController) GetSettleListHospital() {
  2340. order_id, _ := c.GetInt64("order_id")
  2341. admin_user_id, _ := c.GetInt64("admin_user_id")
  2342. order, _ := service.GetHisOrderByIDTwo(order_id)
  2343. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2344. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2345. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2346. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2347. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2348. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2349. if order.ID == 0 {
  2350. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2351. return
  2352. }
  2353. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2354. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2355. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2356. fmt.Println(count)
  2357. var zero string
  2358. number := count + 1
  2359. if number >= 1000 {
  2360. zero = "0000" + strconv.FormatInt(number, 10)
  2361. } else if number >= 10000 {
  2362. zero = "000" + strconv.FormatInt(number, 10)
  2363. } else if number >= 100000 {
  2364. zero = "00" + strconv.FormatInt(number, 10)
  2365. } else if number >= 1000000 {
  2366. zero = "0" + strconv.FormatInt(number, 10)
  2367. } else {
  2368. zero = strconv.FormatInt(number, 10)
  2369. }
  2370. fmt.Println(zero)
  2371. struct4101 := service.Struct4101{
  2372. PsnNo: order.PsnNo,
  2373. MdtrtId: order.MdtrtId,
  2374. SetlId: order.SetlId,
  2375. PsnName: order.PsnName,
  2376. Gend: order.Gend,
  2377. Brdy: his.Brdy,
  2378. Age: int64(order.Age),
  2379. Naty: order.Naty,
  2380. PatnCertType: "01",
  2381. Certno: order.Certno,
  2382. Prfs: "90",
  2383. ConerName: roles[0].UserName,
  2384. PatnRlts: "99",
  2385. ConerAddr: miConfig.OrgName,
  2386. ConerTel: admin.Mobile,
  2387. HiType: order.Insutype,
  2388. Insuplc: miConfig.InsuplcAdmdvs,
  2389. MaindiagFlag: "1",
  2390. BillCode: last_order.FaPiaoCode,
  2391. BillNo: zero,
  2392. BizSn: order.Number,
  2393. PsnSelfPay: order.PsnPartAmt,
  2394. PsnOwnPay: order.PsnPartAmt,
  2395. AcctPay: order.AcctPay,
  2396. PsnCashpay: order.PsnCashPay,
  2397. HiPaymtd: "1",
  2398. Hsorg: miConfig.InsuplcAdmdvs,
  2399. HsorgOpter: miConfig.InsuplcAdmdvs,
  2400. MedinsFillPsn: curRoles.UserName,
  2401. MedinsFillDept: depart.Name,
  2402. IptMedType: "2",
  2403. AdmTime: his.InHosptialTime,
  2404. AdmEndTime: his.OutHosptialTime,
  2405. }
  2406. struct4101.SetlBegnDate = order.SetlTime
  2407. struct4101.SetlEndDate = order.SetlTime
  2408. var rf []CustomFundPay
  2409. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2410. var tempFunPays []service.CustomStruct
  2411. for _, item := range rf {
  2412. var tempFunPay service.CustomStruct
  2413. tempFunPay.FundPayamt = item.FundPayamt
  2414. tempFunPay.FundPayType = item.FundPayType
  2415. tempFunPays = append(tempFunPays, tempFunPay)
  2416. }
  2417. struct4101.CustomStruct = tempFunPays
  2418. var tempDiaginfos []service.DiaginfoStructTwo
  2419. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2420. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2421. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2422. var config []*models.HisXtDiagnoseConfig
  2423. for _, item := range diagnosis_ids {
  2424. id, _ := strconv.ParseInt(item, 10, 64)
  2425. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2426. config = append(config, &diagnosisConfig)
  2427. }
  2428. for index, item := range config {
  2429. if index == 0 {
  2430. var tempDiaginfo service.DiaginfoStructTwo
  2431. tempDiaginfo.DiagCode = item.CountryCode
  2432. tempDiaginfo.DiagName = item.CountryContentName
  2433. tempDiaginfo.DiagType = "1"
  2434. tempDiaginfo.MaindiagFlag = "1"
  2435. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2436. } else {
  2437. var tempDiaginfo service.DiaginfoStructTwo
  2438. tempDiaginfo.DiagCode = item.CountryCode
  2439. tempDiaginfo.DiagName = item.CountryContentName
  2440. tempDiaginfo.DiagType = "2"
  2441. tempDiaginfo.MaindiagFlag = "0"
  2442. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2443. }
  2444. }
  2445. struct4101.Diseinfo = tempDiaginfos
  2446. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2447. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2448. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2449. tempOpspdiseinfo2.OprnOprtCode = ""
  2450. tempOpspdiseinfo2.OprnOprtName = ""
  2451. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2452. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2453. var iteminfo service.IteminfoStruct
  2454. var bedCostTotal float64 = 0 //床位总费
  2455. var bedCostSelfTotal float64 = 0 //床位自费
  2456. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2457. var operationCostTotal float64 = 0 //手术费
  2458. var operationCostSelfTotal float64 = 0 //手术费
  2459. var operationCostPartSelfTotal float64 = 0 //手术费
  2460. var otherCostTotal float64 = 0 //其他费用
  2461. var otherCostSelfTotal float64 = 0 //其他费用
  2462. var otherCostPartSelfTotal float64 = 0 //其他费用
  2463. var materialCostTotal float64 = 0 //材料费
  2464. var materialCostSelfTotal float64 = 0 //材料费
  2465. var materialCostPartSelfTotal float64 = 0 //材料费
  2466. var westernMedicineCostTotal float64 = 0 //西药费
  2467. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2468. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2469. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2470. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2471. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2472. var checkCostTotal float64 = 0 //检查费
  2473. var checkCostSelfTotal float64 = 0 //检查费
  2474. var checkCostPartSelfTotal float64 = 0 //检查费
  2475. var laboratoryCostTotal float64 = 0 //化验费
  2476. var laboratoryCostSelfTotal float64 = 0 //化验费
  2477. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2478. var treatCostTotal float64 = 0 //治疗费用
  2479. var treatCostSelfTotal float64 = 0 //治疗费用
  2480. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2481. decimal.DivisionPrecision = 2
  2482. var bed_fulamt_ownpay_amt float64 = 0
  2483. var operation_fulamt_ownpay_amt float64 = 0
  2484. var other_fulamt_ownpay_amt float64 = 0
  2485. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2486. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2487. var check_fulamt_ownpay_amt float64 = 0
  2488. var material_fulamt_ownpay_amt float64 = 0
  2489. var laboratory_fulamt_ownpay_amt float64 = 0
  2490. var treat_fulamt_ownpay_amt float64 = 0
  2491. var bed_claa_sunmfee float64 = 0
  2492. var bed_clab_amt float64 = 0
  2493. var bed_other_amt float64 = 0
  2494. var operation_claa_sunmfee float64 = 0
  2495. var operation_clab_amt float64 = 0
  2496. var operation_other_amt float64 = 0
  2497. var other_claa_sunmfee float64 = 0
  2498. var other_clab_amt float64 = 0
  2499. var other_other_amt float64 = 0
  2500. var westernMedicine_claa_sunmfee float64 = 0
  2501. var westernMedicine_clab_amt float64 = 0
  2502. var westernMedicine_other_amt float64 = 0
  2503. var chineseTraditional_claa_sunmfee float64 = 0
  2504. var chineseTraditional_clab_amt float64 = 0
  2505. var chineseTraditional_other_amt float64 = 0
  2506. var check_claa_sunmfee float64 = 0
  2507. var check_clab_amt float64 = 0
  2508. var check_other_amt float64 = 0
  2509. var material_claa_sunmfee float64 = 0
  2510. var material_clab_amt float64 = 0
  2511. var material_other_amt float64 = 0
  2512. var laboratory_claa_sunmfee float64 = 0
  2513. var laboratory_clab_amt float64 = 0
  2514. var laboratory_other_amt float64 = 0
  2515. var treat_claa_sunmfee float64 = 0
  2516. var treat_clab_amt float64 = 0
  2517. var treat_other_amt float64 = 0
  2518. for _, item := range order.HisOrderInfo {
  2519. if item.MedChrgitmType == "01" { //床位费
  2520. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2521. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2522. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2523. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2524. if item.ChrgitmLv == "1" {
  2525. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2526. }
  2527. if item.ChrgitmLv == "2" {
  2528. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2529. }
  2530. if item.ChrgitmLv == "3" {
  2531. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2532. }
  2533. }
  2534. if item.MedChrgitmType == "03" { //检查费
  2535. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2536. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2537. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2538. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2539. if item.ChrgitmLv == "1" {
  2540. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2541. }
  2542. if item.ChrgitmLv == "2" {
  2543. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2544. }
  2545. if item.ChrgitmLv == "3" {
  2546. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2547. }
  2548. }
  2549. if item.MedChrgitmType == "04" { //化验费
  2550. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2551. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2552. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2553. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2554. if item.ChrgitmLv == "1" {
  2555. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2556. }
  2557. if item.ChrgitmLv == "2" {
  2558. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2559. }
  2560. if item.ChrgitmLv == "3" {
  2561. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2562. }
  2563. }
  2564. if item.MedChrgitmType == "05" { //治疗费
  2565. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2566. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2567. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2568. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2569. if item.ChrgitmLv == "1" {
  2570. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2571. }
  2572. if item.ChrgitmLv == "2" {
  2573. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2574. }
  2575. if item.ChrgitmLv == "3" {
  2576. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2577. }
  2578. }
  2579. if item.MedChrgitmType == "06" { //手术费
  2580. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2581. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2582. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2583. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2584. if item.ChrgitmLv == "1" {
  2585. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2586. }
  2587. if item.ChrgitmLv == "2" {
  2588. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2589. }
  2590. if item.ChrgitmLv == "3" {
  2591. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2592. }
  2593. }
  2594. if item.MedChrgitmType == "08" { //材料费
  2595. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2596. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2597. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2598. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2599. if item.ChrgitmLv == "1" {
  2600. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2601. }
  2602. if item.ChrgitmLv == "2" {
  2603. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2604. }
  2605. if item.ChrgitmLv == "3" {
  2606. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2607. }
  2608. }
  2609. if item.MedChrgitmType == "09" { //西药费
  2610. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2611. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2612. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2613. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2614. if item.ChrgitmLv == "1" {
  2615. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2616. }
  2617. if item.ChrgitmLv == "2" {
  2618. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2619. }
  2620. if item.ChrgitmLv == "3" {
  2621. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2622. }
  2623. }
  2624. if item.MedChrgitmType == "11" { //中成费
  2625. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2626. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2627. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2628. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2629. if item.ChrgitmLv == "1" {
  2630. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2631. }
  2632. if item.ChrgitmLv == "2" {
  2633. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2634. }
  2635. if item.ChrgitmLv == "3" {
  2636. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2637. }
  2638. }
  2639. if item.MedChrgitmType == "14" { //其他费
  2640. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2641. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2642. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2643. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2644. if item.ChrgitmLv == "1" {
  2645. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2646. }
  2647. if item.ChrgitmLv == "2" {
  2648. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2649. }
  2650. if item.ChrgitmLv == "3" {
  2651. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2652. }
  2653. }
  2654. }
  2655. var iteminfoStructs []service.IteminfoStruct
  2656. if bedCostTotal != 0 {
  2657. iteminfo.MedChrgitm = "01"
  2658. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2659. iteminfo.Amt = bedCostTotal
  2660. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2661. iteminfo.ClabAmt = bed_clab_amt
  2662. iteminfo.OthAmt = bed_other_amt
  2663. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2664. }
  2665. if checkCostTotal != 0 {
  2666. iteminfo.MedChrgitm = "03"
  2667. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2668. iteminfo.Amt = checkCostTotal
  2669. iteminfo.ClaaSumfee = check_claa_sunmfee
  2670. iteminfo.ClabAmt = check_clab_amt
  2671. iteminfo.OthAmt = check_other_amt
  2672. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2673. }
  2674. if laboratoryCostTotal != 0 {
  2675. iteminfo.MedChrgitm = "04"
  2676. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2677. iteminfo.Amt = laboratoryCostTotal
  2678. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2679. iteminfo.ClabAmt = laboratory_clab_amt
  2680. iteminfo.OthAmt = laboratory_other_amt
  2681. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2682. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2683. }
  2684. if treatCostTotal != 0 {
  2685. iteminfo.MedChrgitm = "05"
  2686. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2687. iteminfo.Amt = treatCostTotal
  2688. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2689. iteminfo.ClabAmt = treat_clab_amt
  2690. iteminfo.OthAmt = treat_other_amt
  2691. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2692. //(struct4101.IteminfoStruct, iteminfo)
  2693. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2694. }
  2695. if operationCostTotal != 0 {
  2696. iteminfo.MedChrgitm = "06"
  2697. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2698. iteminfo.Amt = operationCostTotal
  2699. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2700. iteminfo.ClabAmt = operation_clab_amt
  2701. iteminfo.OthAmt = operation_other_amt
  2702. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2703. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2704. }
  2705. if materialCostTotal != 0 {
  2706. iteminfo.MedChrgitm = "08"
  2707. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2708. iteminfo.Amt = materialCostTotal
  2709. iteminfo.ClaaSumfee = material_claa_sunmfee
  2710. iteminfo.ClabAmt = material_clab_amt
  2711. iteminfo.OthAmt = material_other_amt
  2712. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2713. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2714. }
  2715. if westernMedicineCostTotal != 0 {
  2716. iteminfo.MedChrgitm = "09"
  2717. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2718. iteminfo.Amt = westernMedicineCostTotal
  2719. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2720. iteminfo.ClabAmt = westernMedicine_clab_amt
  2721. iteminfo.OthAmt = westernMedicine_other_amt
  2722. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2723. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2724. }
  2725. if chineseTraditionalMedicineCostTotal != 0 {
  2726. iteminfo.MedChrgitm = "11"
  2727. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2728. iteminfo.Amt = westernMedicineCostTotal
  2729. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2730. iteminfo.ClabAmt = westernMedicine_clab_amt
  2731. iteminfo.OthAmt = westernMedicine_other_amt
  2732. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2733. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2734. }
  2735. if otherCostTotal != 0 {
  2736. iteminfo.MedChrgitm = "14"
  2737. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2738. iteminfo.Amt = otherCostTotal
  2739. iteminfo.ClaaSumfee = other_claa_sunmfee
  2740. iteminfo.ClabAmt = other_clab_amt
  2741. iteminfo.OthAmt = other_other_amt
  2742. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2743. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2744. }
  2745. struct4101.IteminfoStruct = iteminfoStructs
  2746. struct4101.Ntly = "中国"
  2747. struct4101.AdmCaty = "A03.06"
  2748. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2749. fmt.Println(result)
  2750. var dat map[string]interface{}
  2751. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2752. fmt.Println(dat)
  2753. } else {
  2754. fmt.Println(err)
  2755. }
  2756. userJSONBytes, _ := json.Marshal(dat)
  2757. var res ResultSeventeen
  2758. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2759. utils.ErrorLog("解析失败:%v", err)
  2760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2761. return
  2762. }
  2763. if res.Infcode != 0 {
  2764. c.ServeSuccessJSON(map[string]interface{}{
  2765. "failed_code": -10,
  2766. "msg": res.ErrMsg,
  2767. })
  2768. return
  2769. } else {
  2770. order.FaPiaoNumber = zero
  2771. order.FaPiaoCode = last_order.FaPiaoCode
  2772. service.UpdateOrder(order)
  2773. hisFundSettleListResult := &models.HisFundSettleListResult{
  2774. Number: res.Output.SetlListId,
  2775. Status: 1,
  2776. Ctime: time.Now().Unix(),
  2777. Mtime: time.Now().Unix(),
  2778. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2779. IsUpload: 1,
  2780. OrderId: order_id,
  2781. }
  2782. service.CreateUploadRecord(hisFundSettleListResult)
  2783. c.ServeSuccessJSON(map[string]interface{}{
  2784. "msg": "上传成功",
  2785. "result": hisFundSettleListResult,
  2786. })
  2787. return
  2788. }
  2789. }
  2790. func (c *HisApiController) GetBatchSettleList() {
  2791. orders, _ := service.GetAllHisOrder(10106)
  2792. for _, item := range orders {
  2793. order_id := item.ID
  2794. order, _ := service.GetHisOrderByIDTwo(order_id)
  2795. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2796. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2797. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2798. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2799. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2800. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2801. if order.ID == 0 {
  2802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2803. return
  2804. }
  2805. if his.BalanceAccountsType == 2 {
  2806. continue
  2807. }
  2808. struct4101 := service.Struct4101{
  2809. PsnNo: order.PsnNo,
  2810. MdtrtId: order.MdtrtId,
  2811. SetlId: order.SetlId,
  2812. PsnName: order.PsnName,
  2813. Gend: order.Gend,
  2814. Brdy: his.Brdy,
  2815. Age: his.Age,
  2816. Naty: order.Naty,
  2817. PatnCertType: "01",
  2818. Certno: order.Certno,
  2819. Prfs: "90",
  2820. ConerName: roles[0].UserName,
  2821. PatnRlts: "99",
  2822. ConerAddr: miConfig.OrgName,
  2823. ConerTel: admin.Mobile,
  2824. HiType: order.Insutype,
  2825. Insuplc: his.InsuplcAdmdvs,
  2826. MaindiagFlag: "1",
  2827. BillCode: order.FaPiaoCode,
  2828. BillNo: order.FaPiaoNumber,
  2829. BizSn: order.Number,
  2830. PsnSelfPay: order.PsnPartAmt,
  2831. PsnOwnPay: order.PsnPartAmt,
  2832. AcctPay: order.AcctPay,
  2833. PsnCashpay: order.PsnCashPay,
  2834. HiPaymtd: "1",
  2835. Hsorg: his.InsuplcAdmdvs,
  2836. HsorgOpter: his.InsuplcAdmdvs,
  2837. MedinsFillPsn: curRoles.UserName,
  2838. MedinsFillDept: depart.Name,
  2839. IptMedType: "2",
  2840. }
  2841. struct4101.SetlBegnDate = order.SetlTime
  2842. struct4101.SetlEndDate = order.SetlTime
  2843. //if order.SettleType == 1 {
  2844. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2845. // dateStr := t.Format("2006-01-02")
  2846. // struct4101.SetlBegnDate = dateStr
  2847. // struct4101.SetlEndDate = dateStr
  2848. //} else {
  2849. // t := time.Unix(int64(order.SettleStartTime), 0)
  2850. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2851. // dateStartStr := t.Format("2006-01-02")
  2852. // dateEndStr := t2.Format("2006-01-02")
  2853. // struct4101.SetlBegnDate = dateStartStr
  2854. // struct4101.SetlEndDate = dateEndStr
  2855. //}
  2856. var rf []CustomFundPay
  2857. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2858. var tempFunPays []service.CustomStruct
  2859. var tempFunPay610100 service.CustomStruct
  2860. for _, item := range rf {
  2861. if item.FundPayType == "610100" {
  2862. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2863. tempFunPay610100.FundPayType = item.FundPayType
  2864. } else {
  2865. var tempFunPay service.CustomStruct
  2866. tempFunPay.FundPayamt = item.FundPayamt
  2867. tempFunPay.FundPayType = item.FundPayType
  2868. tempFunPays = append(tempFunPays, tempFunPay)
  2869. }
  2870. }
  2871. tempFunPays = append(tempFunPays, tempFunPay610100)
  2872. struct4101.CustomStruct = tempFunPays
  2873. var tempDiaginfos []service.DiaginfoStructTwo
  2874. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2875. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2876. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2877. var config []*models.HisXtDiagnoseConfig
  2878. for _, item := range diagnosis_ids {
  2879. id, _ := strconv.ParseInt(item, 10, 64)
  2880. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2881. config = append(config, &diagnosisConfig)
  2882. }
  2883. for index, item := range config {
  2884. if index == 0 {
  2885. var tempDiaginfo service.DiaginfoStructTwo
  2886. tempDiaginfo.DiagCode = item.CountryCode
  2887. tempDiaginfo.DiagName = item.CountryContentName
  2888. tempDiaginfo.DiagType = "1"
  2889. tempDiaginfo.MaindiagFlag = "1"
  2890. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2891. } else {
  2892. var tempDiaginfo service.DiaginfoStructTwo
  2893. tempDiaginfo.DiagCode = item.CountryCode
  2894. tempDiaginfo.DiagName = item.CountryContentName
  2895. tempDiaginfo.DiagType = "2"
  2896. tempDiaginfo.MaindiagFlag = "0"
  2897. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2898. }
  2899. }
  2900. struct4101.Diseinfo = tempDiaginfos
  2901. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2902. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2903. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2904. tempOpspdiseinfo2.OprnOprtCode = ""
  2905. tempOpspdiseinfo2.OprnOprtName = ""
  2906. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2907. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2908. var iteminfo service.IteminfoStruct
  2909. var bedCostTotal float64 = 0 //床位总费
  2910. var bedCostSelfTotal float64 = 0 //床位自费
  2911. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2912. var examineCostTotal float64 = 0 //诊查总费
  2913. var examineCostSelfTotal float64 = 0 //诊查自费
  2914. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2915. var nursingCostTotal float64 = 0 //护理总费
  2916. var nursingCostSelfTotal float64 = 0 //护理自费
  2917. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2918. var chineseMedicineCostTotal float64 = 0 //中成药
  2919. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2920. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2921. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2922. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2923. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2924. var registerCostTotal float64 = 0 //一般诊疗费
  2925. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2926. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2927. var operationCostTotal float64 = 0 //手术费
  2928. var operationCostSelfTotal float64 = 0 //手术费
  2929. var operationCostPartSelfTotal float64 = 0 //手术费
  2930. var otherCostTotal float64 = 0 //其他费用
  2931. var otherCostSelfTotal float64 = 0 //其他费用
  2932. var otherCostPartSelfTotal float64 = 0 //其他费用
  2933. var materialCostTotal float64 = 0 //材料费
  2934. var materialCostSelfTotal float64 = 0 //材料费
  2935. var materialCostPartSelfTotal float64 = 0 //材料费
  2936. var westernMedicineCostTotal float64 = 0 //西药费
  2937. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2938. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2939. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2940. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2941. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2942. var checkCostTotal float64 = 0 //检查费
  2943. var checkCostSelfTotal float64 = 0 //检查费
  2944. var checkCostPartSelfTotal float64 = 0 //检查费
  2945. var laboratoryCostTotal float64 = 0 //化验费
  2946. var laboratoryCostSelfTotal float64 = 0 //化验费
  2947. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2948. var treatCostTotal float64 = 0 //治疗费用
  2949. var treatCostSelfTotal float64 = 0 //治疗费用
  2950. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2951. decimal.DivisionPrecision = 2
  2952. var bed_fulamt_ownpay_amt float64 = 0
  2953. var examine_fulamt_ownpay_amt float64 = 0
  2954. var nursing_fulamt_ownpay_amt float64 = 0
  2955. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2956. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2957. var register_fulamt_ownpay_amt float64 = 0
  2958. var operation_fulamt_ownpay_amt float64 = 0
  2959. var other_fulamt_ownpay_amt float64 = 0
  2960. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2961. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2962. var check_fulamt_ownpay_amt float64 = 0
  2963. var material_fulamt_ownpay_amt float64 = 0
  2964. var laboratory_fulamt_ownpay_amt float64 = 0
  2965. var treat_fulamt_ownpay_amt float64 = 0
  2966. var bed_claa_sunmfee float64 = 0
  2967. var bed_clab_amt float64 = 0
  2968. var bed_other_amt float64 = 0
  2969. var examine_claa_sunmfee float64 = 0
  2970. var examine_clab_amt float64 = 0
  2971. var examine_other_amt float64 = 0
  2972. var nursing_claa_sunmfee float64 = 0
  2973. var nursing_clab_amt float64 = 0
  2974. var nursing_other_amt float64 = 0
  2975. var chinese_medicine_claa_sunmfee float64 = 0
  2976. var chinese_medicine_clab_amt float64 = 0
  2977. var chinese_medicine_other_amt float64 = 0
  2978. var commonly_treatment_claa_sunmfee float64 = 0
  2979. var commonly_treatment_clab_amt float64 = 0
  2980. var commonly_treatment_other_amt float64 = 0
  2981. var operation_claa_sunmfee float64 = 0
  2982. var operation_clab_amt float64 = 0
  2983. var operation_other_amt float64 = 0
  2984. var other_claa_sunmfee float64 = 0
  2985. var other_clab_amt float64 = 0
  2986. var other_other_amt float64 = 0
  2987. var westernMedicine_claa_sunmfee float64 = 0
  2988. var westernMedicine_clab_amt float64 = 0
  2989. var westernMedicine_other_amt float64 = 0
  2990. var chineseTraditional_claa_sunmfee float64 = 0
  2991. var chineseTraditional_clab_amt float64 = 0
  2992. var chineseTraditional_other_amt float64 = 0
  2993. var check_claa_sunmfee float64 = 0
  2994. var check_clab_amt float64 = 0
  2995. var check_other_amt float64 = 0
  2996. var material_claa_sunmfee float64 = 0
  2997. var material_clab_amt float64 = 0
  2998. var material_other_amt float64 = 0
  2999. var laboratory_claa_sunmfee float64 = 0
  3000. var laboratory_clab_amt float64 = 0
  3001. var laboratory_other_amt float64 = 0
  3002. var treat_claa_sunmfee float64 = 0
  3003. var treat_clab_amt float64 = 0
  3004. var treat_other_amt float64 = 0
  3005. var register_claa_sunmfee float64 = 0
  3006. var register_clab_amt float64 = 0
  3007. var register_other_amt float64 = 0
  3008. for _, item := range order.HisOrderInfo {
  3009. if item.MedChrgitmType == "01" { //床位费
  3010. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3011. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3012. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3013. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3014. if item.ChrgitmLv == "1" {
  3015. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3016. }
  3017. if item.ChrgitmLv == "2" {
  3018. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3019. }
  3020. if item.ChrgitmLv == "3" {
  3021. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3022. }
  3023. }
  3024. if item.MedChrgitmType == "02" { //诊查
  3025. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3026. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3027. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3028. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3029. if item.ChrgitmLv == "1" {
  3030. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3031. }
  3032. if item.ChrgitmLv == "2" {
  3033. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3034. }
  3035. if item.ChrgitmLv == "3" {
  3036. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3037. }
  3038. }
  3039. if item.MedChrgitmType == "03" { //检查费
  3040. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3041. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3042. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3043. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3044. if item.ChrgitmLv == "1" {
  3045. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3046. }
  3047. if item.ChrgitmLv == "2" {
  3048. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3049. }
  3050. if item.ChrgitmLv == "3" {
  3051. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3052. }
  3053. }
  3054. if item.MedChrgitmType == "04" { //化验费
  3055. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3056. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3057. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3058. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3059. if item.ChrgitmLv == "1" {
  3060. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3061. }
  3062. if item.ChrgitmLv == "2" {
  3063. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3064. }
  3065. if item.ChrgitmLv == "3" {
  3066. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3067. }
  3068. }
  3069. if item.MedChrgitmType == "05" { //治疗费
  3070. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3071. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3072. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3073. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3074. if item.ChrgitmLv == "1" {
  3075. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3076. }
  3077. if item.ChrgitmLv == "2" {
  3078. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3079. }
  3080. if item.ChrgitmLv == "3" {
  3081. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3082. }
  3083. }
  3084. if item.MedChrgitmType == "06" { //手术费
  3085. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3086. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3087. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3088. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3089. if item.ChrgitmLv == "1" {
  3090. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3091. }
  3092. if item.ChrgitmLv == "2" {
  3093. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3094. }
  3095. if item.ChrgitmLv == "3" {
  3096. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3097. }
  3098. }
  3099. if item.MedChrgitmType == "07" { //手术费
  3100. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3101. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3102. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3103. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3104. if item.ChrgitmLv == "1" {
  3105. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3106. }
  3107. if item.ChrgitmLv == "2" {
  3108. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3109. }
  3110. if item.ChrgitmLv == "3" {
  3111. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3112. }
  3113. }
  3114. if item.MedChrgitmType == "08" { //材料费
  3115. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3116. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3117. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3118. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3119. if item.ChrgitmLv == "1" {
  3120. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3121. }
  3122. if item.ChrgitmLv == "2" {
  3123. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3124. }
  3125. if item.ChrgitmLv == "3" {
  3126. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3127. }
  3128. }
  3129. if item.MedChrgitmType == "09" { //西药费
  3130. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3131. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3132. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3133. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3134. if item.ChrgitmLv == "1" {
  3135. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3136. }
  3137. if item.ChrgitmLv == "2" {
  3138. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3139. }
  3140. if item.ChrgitmLv == "3" {
  3141. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3142. }
  3143. }
  3144. if item.MedChrgitmType == "10" { //中药饮片
  3145. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3146. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3147. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3148. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3149. if item.ChrgitmLv == "1" {
  3150. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3151. }
  3152. if item.ChrgitmLv == "2" {
  3153. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3154. }
  3155. if item.ChrgitmLv == "3" {
  3156. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3157. }
  3158. }
  3159. if item.MedChrgitmType == "11" { //中成费
  3160. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3161. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3162. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3163. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3164. if item.ChrgitmLv == "1" {
  3165. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3166. }
  3167. if item.ChrgitmLv == "2" {
  3168. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3169. }
  3170. if item.ChrgitmLv == "3" {
  3171. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3172. }
  3173. }
  3174. if item.MedChrgitmType == "12" { //中成费
  3175. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3176. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3177. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3178. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3179. if item.ChrgitmLv == "1" {
  3180. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3181. }
  3182. if item.ChrgitmLv == "2" {
  3183. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3184. }
  3185. if item.ChrgitmLv == "3" {
  3186. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3187. }
  3188. }
  3189. if item.MedChrgitmType == "13" { //中成费
  3190. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3191. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3192. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3193. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3194. if item.ChrgitmLv == "1" {
  3195. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3196. }
  3197. if item.ChrgitmLv == "2" {
  3198. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3199. }
  3200. if item.ChrgitmLv == "3" {
  3201. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3202. }
  3203. }
  3204. if item.MedChrgitmType == "14" { //其他费
  3205. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3206. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3207. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3208. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3209. if item.ChrgitmLv == "1" {
  3210. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3211. }
  3212. if item.ChrgitmLv == "2" {
  3213. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3214. }
  3215. if item.ChrgitmLv == "3" {
  3216. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3217. }
  3218. }
  3219. }
  3220. var iteminfoStructs []service.IteminfoStruct
  3221. if bedCostTotal != 0 {
  3222. iteminfo.MedChrgitm = "01"
  3223. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3224. iteminfo.Amt = bedCostTotal
  3225. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3226. iteminfo.ClabAmt = bed_clab_amt
  3227. iteminfo.OthAmt = bed_other_amt
  3228. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3229. }
  3230. if examineCostTotal != 0 {
  3231. iteminfo.MedChrgitm = "02"
  3232. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3233. iteminfo.Amt = examineCostTotal
  3234. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3235. iteminfo.ClabAmt = examine_clab_amt
  3236. iteminfo.OthAmt = examine_other_amt
  3237. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3238. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3239. }
  3240. if checkCostTotal != 0 {
  3241. iteminfo.MedChrgitm = "03"
  3242. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3243. iteminfo.Amt = checkCostTotal
  3244. iteminfo.ClaaSumfee = check_claa_sunmfee
  3245. iteminfo.ClabAmt = check_clab_amt
  3246. iteminfo.OthAmt = check_other_amt
  3247. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3248. }
  3249. if laboratoryCostTotal != 0 {
  3250. iteminfo.MedChrgitm = "04"
  3251. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3252. iteminfo.Amt = laboratoryCostTotal
  3253. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3254. iteminfo.ClabAmt = laboratory_clab_amt
  3255. iteminfo.OthAmt = laboratory_other_amt
  3256. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3257. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3258. }
  3259. if treatCostTotal != 0 {
  3260. iteminfo.MedChrgitm = "05"
  3261. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3262. iteminfo.Amt = treatCostTotal
  3263. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3264. iteminfo.ClabAmt = treat_clab_amt
  3265. iteminfo.OthAmt = treat_other_amt
  3266. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3267. //(struct4101.IteminfoStruct, iteminfo)
  3268. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3269. }
  3270. if operationCostTotal != 0 {
  3271. iteminfo.MedChrgitm = "06"
  3272. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3273. iteminfo.Amt = operationCostTotal
  3274. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3275. iteminfo.ClabAmt = operation_clab_amt
  3276. iteminfo.OthAmt = operation_other_amt
  3277. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3278. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3279. }
  3280. if nursingCostTotal != 0 {
  3281. iteminfo.MedChrgitm = "07"
  3282. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3283. iteminfo.Amt = nursingCostTotal
  3284. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3285. iteminfo.ClabAmt = nursing_clab_amt
  3286. iteminfo.OthAmt = nursing_other_amt
  3287. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3288. }
  3289. if materialCostTotal != 0 {
  3290. iteminfo.MedChrgitm = "08"
  3291. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3292. iteminfo.Amt = materialCostTotal
  3293. iteminfo.ClaaSumfee = material_claa_sunmfee
  3294. iteminfo.ClabAmt = material_clab_amt
  3295. iteminfo.OthAmt = material_other_amt
  3296. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3297. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3298. }
  3299. if westernMedicineCostTotal != 0 {
  3300. iteminfo.MedChrgitm = "09"
  3301. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3302. iteminfo.Amt = westernMedicineCostTotal
  3303. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3304. iteminfo.ClabAmt = westernMedicine_clab_amt
  3305. iteminfo.OthAmt = westernMedicine_other_amt
  3306. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3307. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3308. }
  3309. if chineseMedicineCostTotal != 0 {
  3310. iteminfo.MedChrgitm = "10"
  3311. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3312. iteminfo.Amt = chineseMedicineCostTotal
  3313. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3314. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3315. iteminfo.OthAmt = chinese_medicine_other_amt
  3316. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3317. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3318. }
  3319. if chineseTraditionalMedicineCostTotal != 0 {
  3320. iteminfo.MedChrgitm = "11"
  3321. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3322. iteminfo.Amt = westernMedicineCostTotal
  3323. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3324. iteminfo.ClabAmt = westernMedicine_clab_amt
  3325. iteminfo.OthAmt = westernMedicine_other_amt
  3326. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3327. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3328. }
  3329. if commonlyTreatmentCostTotal != 0 {
  3330. iteminfo.MedChrgitm = "12"
  3331. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3332. iteminfo.Amt = commonlyTreatmentCostTotal
  3333. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3334. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3335. iteminfo.OthAmt = commonly_treatment_other_amt
  3336. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3337. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3338. }
  3339. if registerCostTotal != 0 {
  3340. iteminfo.MedChrgitm = "13"
  3341. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3342. iteminfo.Amt = registerCostTotal
  3343. iteminfo.ClaaSumfee = register_claa_sunmfee
  3344. iteminfo.ClabAmt = register_clab_amt
  3345. iteminfo.OthAmt = register_other_amt
  3346. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3347. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3348. }
  3349. if otherCostTotal != 0 {
  3350. iteminfo.MedChrgitm = "14"
  3351. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3352. iteminfo.Amt = otherCostTotal
  3353. iteminfo.ClaaSumfee = other_claa_sunmfee
  3354. iteminfo.ClabAmt = other_clab_amt
  3355. iteminfo.OthAmt = other_other_amt
  3356. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3357. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3358. }
  3359. struct4101.IteminfoStruct = iteminfoStructs
  3360. struct4101.Ntly = "中国"
  3361. struct4101.AdmCaty = "A03.06"
  3362. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3363. fmt.Println(result)
  3364. var dat map[string]interface{}
  3365. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3366. fmt.Println(dat)
  3367. } else {
  3368. fmt.Println(err)
  3369. }
  3370. userJSONBytes, _ := json.Marshal(dat)
  3371. var res ResultSeventeen
  3372. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3373. utils.ErrorLog("解析失败:%v", err)
  3374. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3375. adminUser := c.GetAdminUserInfo()
  3376. errlog := &models.HisOrderError{
  3377. UserOrgId: adminUser.CurrentOrgId,
  3378. Ctime: time.Now().Unix(),
  3379. Mtime: time.Now().Unix(),
  3380. ErrMsg: res.ErrMsg + "解析失败",
  3381. Status: 1,
  3382. PatientId: order_id,
  3383. Stage: 10106,
  3384. }
  3385. service.CreateErrMsgLog(errlog)
  3386. continue
  3387. }
  3388. if res.Infcode != 0 {
  3389. adminUser := c.GetAdminUserInfo()
  3390. errlog := &models.HisOrderError{
  3391. UserOrgId: adminUser.CurrentOrgId,
  3392. Ctime: time.Now().Unix(),
  3393. Mtime: time.Now().Unix(),
  3394. ErrMsg: res.ErrMsg,
  3395. Status: 1,
  3396. PatientId: order_id,
  3397. Stage: 10106,
  3398. }
  3399. service.CreateErrMsgLog(errlog)
  3400. continue
  3401. } else {
  3402. hisFundSettleListResult := &models.HisFundSettleListResult{
  3403. Number: res.Output.SetlListId,
  3404. Status: 1,
  3405. Ctime: time.Now().Unix(),
  3406. Mtime: time.Now().Unix(),
  3407. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3408. IsUpload: 1,
  3409. OrderId: order_id,
  3410. }
  3411. service.CreateUploadRecord(hisFundSettleListResult)
  3412. continue
  3413. }
  3414. }
  3415. }
  3416. func (c *HisApiController) GetOrgInfo() {
  3417. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3418. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3419. }
  3420. func (c *HisApiController) GetHisPatientInfo() {
  3421. medical_insurance_card := c.GetString("medical_insurance_card")
  3422. id_card_type, _ := c.GetInt64("id_card_type")
  3423. id_card := c.GetString("id_card")
  3424. adminInfo := c.GetAdminUserInfo()
  3425. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3426. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3427. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3428. IdCardNo := ""
  3429. if id_card_type == 1 {
  3430. IdCardNo = medical_insurance_card
  3431. } else if id_card_type == 2 {
  3432. IdCardNo = id_card
  3433. }
  3434. if config.IsOpen == 1 {
  3435. 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
  3436. resp, requestErr := http.Get(api)
  3437. if requestErr != nil {
  3438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3439. return
  3440. }
  3441. defer resp.Body.Close()
  3442. body, ioErr := ioutil.ReadAll(resp.Body)
  3443. if ioErr != nil {
  3444. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3445. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3446. return
  3447. }
  3448. var respJSON map[string]interface{}
  3449. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3450. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3451. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3452. return
  3453. }
  3454. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3455. userJSONBytes, _ := json.Marshal(userJSON)
  3456. var res ResultTwo
  3457. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3458. utils.ErrorLog("解析失败:%v", err)
  3459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3460. return
  3461. }
  3462. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3463. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3464. infoStr := string(Iinfos)
  3465. idetinfoStr := string(Idetinfos)
  3466. if res.Infcode == 0 {
  3467. his := models.VMHisPatient{
  3468. Status: 1,
  3469. Ctime: time.Now().Unix(),
  3470. Mtime: time.Now().Unix(),
  3471. PsnNo: res.Output.Baseinfo.PsnNo,
  3472. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3473. Certno: res.Output.Baseinfo.Certno,
  3474. PsnName: res.Output.Baseinfo.PsnName,
  3475. Gend: res.Output.Baseinfo.Gend,
  3476. Naty: res.Output.Baseinfo.Naty,
  3477. Brdy: res.Output.Baseinfo.Brdy,
  3478. Age: res.Output.Baseinfo.Age,
  3479. Iinfo: infoStr,
  3480. Idetinfo: idetinfoStr,
  3481. UserOrgId: adminInfo.CurrentOrgId,
  3482. IsReturn: 1,
  3483. IdCardType: id_card_type,
  3484. }
  3485. c.ServeSuccessJSON(map[string]interface{}{
  3486. "info": his,
  3487. })
  3488. } else {
  3489. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3490. return
  3491. }
  3492. }
  3493. }
  3494. //func GetBasBaseInfo() (jsonStr string, err error) {
  3495. //
  3496. // handle := syscall.NewLazyDLL("SSCard.dll")
  3497. // add := handle.NewProc("ReadCardBas")
  3498. // str := make([]byte, 1024)
  3499. // str1 := make([]byte, 1024)
  3500. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3501. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3502. //
  3503. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3504. //
  3505. // fmt.Println("> Add(4,5)的结果为:", ret)
  3506. // handle.Release()
  3507. //
  3508. // return "", nil
  3509. //
  3510. //}
  3511. //func GetQRBaseInfo() (jsonStr string, err error) {
  3512. // handle := syscall.LoadDLL("SSCard.dll")
  3513. // ReadCardBas := handle.FindProc("GetQRBase")
  3514. //
  3515. // str := make([]byte, 256)
  3516. // str1 := make([]byte, 256)
  3517. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3518. //
  3519. // fmt.Println(string(str))
  3520. // fmt.Println(r)
  3521. // return string(str), nil
  3522. //}
  3523. //func CardInit() int {
  3524. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3525. // add := DllTestDef.MustFindProc("Init")
  3526. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3527. // if err != nil {
  3528. // fmt.Println("SSCard的运算结果为:", ret)
  3529. // }
  3530. // result := int(ret)
  3531. // return result
  3532. //}
  3533. //func CardInit() int {
  3534. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3535. // if err != nil {
  3536. // fmt.Println("SSCard的运算结果为:", ret)
  3537. // }
  3538. // fmt.Println(err)
  3539. // result := int(ret)
  3540. // return result
  3541. //}
  3542. func IntPtr(n int) uintptr {
  3543. return uintptr(n)
  3544. }
  3545. func StrPtr(s string) uintptr {
  3546. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3547. }
  3548. type Result2001 struct {
  3549. Cainfo interface{} `json:"cainfo"`
  3550. ErrMsg string `json:"err_msg"`
  3551. InfRefmsgid string `json:"inf_refmsgid"`
  3552. Infcode int64 `json:"infcode"`
  3553. Output struct {
  3554. Trtinfo struct {
  3555. PsnNo string `json:"psn_no"`
  3556. TrtChkType string `json:"trt_chk_type"`
  3557. FundPayType string `json:"fund_pay_type"`
  3558. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3559. Begndate string `json:"begndate"`
  3560. Enddate string `json:"enddate"`
  3561. TrtChkRslt string `json:"trt_chk_rslt"`
  3562. } `json:"trtinfo"`
  3563. } `json:"output"`
  3564. RefmsgTime string `json:"refmsg_time"`
  3565. RespondTime string `json:"respond_time"`
  3566. Signtype interface{} `json:"signtype"`
  3567. WarnMsg interface{} `json:"warn_msg"`
  3568. }
  3569. type Result2001Org10265 struct {
  3570. Cainfo interface{} `json:"cainfo"`
  3571. ErrMsg string `json:"err_msg"`
  3572. InfRefmsgid string `json:"inf_refmsgid"`
  3573. Infcode string `json:"infcode"`
  3574. Output struct {
  3575. Trtinfo struct {
  3576. PsnNo string `json:"psn_no"`
  3577. TrtChkType string `json:"trt_chk_type"`
  3578. FundPayType string `json:"fund_pay_type"`
  3579. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3580. Begndate string `json:"begndate"`
  3581. Enddate string `json:"enddate"`
  3582. TrtChkRslt string `json:"trt_chk_rslt"`
  3583. } `json:"trtinfo"`
  3584. } `json:"output"`
  3585. RefmsgTime string `json:"refmsg_time"`
  3586. RespondTime string `json:"respond_time"`
  3587. Signtype interface{} `json:"signtype"`
  3588. WarnMsg interface{} `json:"warn_msg"`
  3589. }
  3590. type ResultTwo struct {
  3591. ErrMsg string `json:"err_msg"`
  3592. InfRefmsgid string `json:"inf_refmsgid"`
  3593. Infcode int64 `json:"infcode"`
  3594. Output struct {
  3595. Baseinfo struct {
  3596. Age float64 `json:"age"`
  3597. Brdy string `json:"brdy"`
  3598. Certno string `json:"certno"`
  3599. Gend string `json:"gend"`
  3600. Naty string `json:"naty"`
  3601. PsnCertType string `json:"psn_cert_type"`
  3602. PsnName string `json:"psn_name"`
  3603. PsnNo string `json:"psn_no"`
  3604. } `json:"baseinfo"`
  3605. Idetinfo []interface{} `json:"idetinfo"`
  3606. Iinfo []struct {
  3607. Balc float64 `json:"balc"`
  3608. CvlservFlag string `json:"cvlserv_flag"`
  3609. EmpName string `json:"emp_name"`
  3610. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3611. Insutype string `json:"insutype"`
  3612. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3613. PausInsuDate string `json:"paus_insu_date"`
  3614. PsnInsuDate string `json:"psn_insu_date"`
  3615. PsnInsuStas string `json:"psn_insu_stas"`
  3616. PsnType string `json:"psn_type"`
  3617. } `json:"insuinfo"`
  3618. } `json:"output"`
  3619. RefmsgTime string `json:"refmsg_time"`
  3620. RespondTime string `json:"respond_time"`
  3621. Signtype interface{} `json:"signtype"`
  3622. WarnInfo interface{} `json:"warn_info"`
  3623. }
  3624. type ResultTwo10265 struct {
  3625. ErrMsg string `json:"err_msg"`
  3626. InfRefmsgid string `json:"inf_refmsgid"`
  3627. Infcode string `json:"infcode"`
  3628. Output struct {
  3629. Baseinfo struct {
  3630. Age float64 `json:"age"`
  3631. Brdy string `json:"brdy"`
  3632. Certno string `json:"certno"`
  3633. Gend string `json:"gend"`
  3634. Naty string `json:"naty"`
  3635. PsnCertType string `json:"psn_cert_type"`
  3636. PsnName string `json:"psn_name"`
  3637. PsnNo string `json:"psn_no"`
  3638. } `json:"baseinfo"`
  3639. Idetinfo []interface{} `json:"idetinfo"`
  3640. Iinfo []struct {
  3641. Balc float64 `json:"balc"`
  3642. CvlservFlag string `json:"cvlserv_flag"`
  3643. EmpName string `json:"emp_name"`
  3644. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3645. Insutype string `json:"insutype"`
  3646. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3647. PausInsuDate string `json:"paus_insu_date"`
  3648. PsnInsuDate string `json:"psn_insu_date"`
  3649. PsnInsuStas string `json:"psn_insu_stas"`
  3650. PsnType string `json:"psn_type"`
  3651. } `json:"insuinfo"`
  3652. } `json:"output"`
  3653. RefmsgTime string `json:"refmsg_time"`
  3654. RespondTime string `json:"respond_time"`
  3655. Signtype interface{} `json:"signtype"`
  3656. WarnInfo interface{} `json:"warn_info"`
  3657. }
  3658. type ResultThree struct {
  3659. Cainfo interface{} `json:"cainfo"`
  3660. ErrMsg string `json:"err_msg"`
  3661. InfRefmsgid string `json:"inf_refmsgid"`
  3662. Infcode int64 `json:"infcode"`
  3663. Output struct {
  3664. Data struct {
  3665. IptOtpNo string `json:"ipt_otp_no"`
  3666. MdtrtID string `json:"mdtrt_id"`
  3667. PsnNo string `json:"psn_no"`
  3668. } `json:"data"`
  3669. } `json:"output"`
  3670. RefmsgTime string `json:"refmsg_time"`
  3671. RespondTime string `json:"respond_time"`
  3672. Signtype interface{} `json:"signtype"`
  3673. WarnMsg interface{} `json:"warn_msg"`
  3674. }
  3675. type ResultThree10265 struct {
  3676. Cainfo interface{} `json:"cainfo"`
  3677. ErrMsg string `json:"err_msg"`
  3678. InfRefmsgid string `json:"inf_refmsgid"`
  3679. Infcode string `json:"infcode"`
  3680. Output struct {
  3681. Data struct {
  3682. IptOtpNo string `json:"ipt_otp_no"`
  3683. MdtrtID string `json:"mdtrt_id"`
  3684. PsnNo string `json:"psn_no"`
  3685. } `json:"data"`
  3686. } `json:"output"`
  3687. RefmsgTime string `json:"refmsg_time"`
  3688. RespondTime string `json:"respond_time"`
  3689. Signtype interface{} `json:"signtype"`
  3690. WarnMsg interface{} `json:"warn_msg"`
  3691. }
  3692. type ResultFour struct {
  3693. Cainfo string `json:"cainfo"`
  3694. ErrMsg string `json:"err_msg"`
  3695. InfRefmsgid string `json:"inf_refmsgid"`
  3696. Infcode int64 `json:"infcode"`
  3697. Output struct {
  3698. Result []struct {
  3699. BasMednFlag string `json:"bas_medn_flag"`
  3700. ChldMedcFlag string `json:"chld_medc_flag"`
  3701. ChrgitmLv string `json:"chrgitm_lv"`
  3702. Cnt float64 `json:"cnt"`
  3703. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3704. DrtReimFlag string `json:"drt_reim_flag"`
  3705. FeedetlSn string `json:"feedetl_sn"`
  3706. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3707. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3708. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3709. ListSpItemFlag string `json:"list_sp_item_flag"`
  3710. LmtUsedFlag string `json:"lmt_used_flag"`
  3711. MedChrgitmType string `json:"med_chrgitm_type"`
  3712. Memo string `json:"memo"`
  3713. OverlmtAmt float64 `json:"overlmt_amt"`
  3714. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3715. Pric float64 `json:"pric"`
  3716. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3717. SelfpayProp float64 `json:"selfpay_prop"`
  3718. } `json:"result"`
  3719. } `json:"output"`
  3720. RefmsgTime string `json:"refmsg_time"`
  3721. RespondTime string `json:"respond_time"`
  3722. Signtype string `json:"signtype"`
  3723. WarnMsg string `json:"warn_msg"`
  3724. }
  3725. type ResultFour10265 struct {
  3726. Cainfo string `json:"cainfo"`
  3727. ErrMsg string `json:"err_msg"`
  3728. InfRefmsgid string `json:"inf_refmsgid"`
  3729. Infcode string `json:"infcode"`
  3730. Output struct {
  3731. Result []struct {
  3732. BasMednFlag string `json:"bas_medn_flag"`
  3733. ChldMedcFlag string `json:"chld_medc_flag"`
  3734. ChrgitmLv string `json:"chrgitm_lv"`
  3735. Cnt float64 `json:"cnt"`
  3736. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3737. DrtReimFlag string `json:"drt_reim_flag"`
  3738. FeedetlSn string `json:"feedetl_sn"`
  3739. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3740. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3741. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3742. ListSpItemFlag string `json:"list_sp_item_flag"`
  3743. LmtUsedFlag string `json:"lmt_used_flag"`
  3744. MedChrgitmType string `json:"med_chrgitm_type"`
  3745. Memo string `json:"memo"`
  3746. OverlmtAmt float64 `json:"overlmt_amt"`
  3747. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3748. Pric float64 `json:"pric"`
  3749. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3750. SelfpayProp float64 `json:"selfpay_prop"`
  3751. } `json:"result"`
  3752. } `json:"output"`
  3753. RefmsgTime string `json:"refmsg_time"`
  3754. RespondTime string `json:"respond_time"`
  3755. Signtype string `json:"signtype"`
  3756. WarnMsg string `json:"warn_msg"`
  3757. }
  3758. type ResultFive struct {
  3759. Balc float64 `json:"balc"`
  3760. CvlservFlag string `json:"cvlserv_flag"`
  3761. EmpName string `json:"emp_name"`
  3762. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3763. Insutype string `json:"insutype"`
  3764. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3765. PausInsuDate string `json:"paus_insu_date"`
  3766. PsnInsuDate string `json:"psn_insu_date"`
  3767. PsnInsuStas string `json:"psn_insu_stas"`
  3768. PsnType string `json:"psn_type"`
  3769. }
  3770. type ResultSix struct {
  3771. Cainfo interface{} `json:"cainfo"`
  3772. ErrMsg string `json:"err_msg"`
  3773. InfRefmsgid string `json:"inf_refmsgid"`
  3774. Infcode int64 `json:"infcode"`
  3775. Output struct {
  3776. } `json:"output"`
  3777. RefmsgTime string `json:"refmsg_time"`
  3778. RespondTime string `json:"respond_time"`
  3779. Signtype interface{} `json:"signtype"`
  3780. WarnMsg interface{} `json:"warn_msg"`
  3781. }
  3782. type ResultSix10265 struct {
  3783. Cainfo interface{} `json:"cainfo"`
  3784. ErrMsg string `json:"err_msg"`
  3785. InfRefmsgid string `json:"inf_refmsgid"`
  3786. Infcode string `json:"infcode"`
  3787. Output struct {
  3788. } `json:"output"`
  3789. RefmsgTime string `json:"refmsg_time"`
  3790. RespondTime string `json:"respond_time"`
  3791. Signtype interface{} `json:"signtype"`
  3792. WarnMsg interface{} `json:"warn_msg"`
  3793. }
  3794. type ResultSeven struct {
  3795. Cainfo string `json:"cainfo"`
  3796. ErrMsg string `json:"err_msg"`
  3797. InfRefmsgid string `json:"inf_refmsgid"`
  3798. Infcode int64 `json:"infcode"`
  3799. Output struct {
  3800. Setldetail []interface{} `json:"setldetail"`
  3801. Setlinfo struct {
  3802. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3803. AcctPay float64 `json:"acct_pay"`
  3804. ActPayDedc float64 `json:"act_pay_dedc"`
  3805. Age float64 `json:"age"`
  3806. Balc float64 `json:"balc"`
  3807. Brdy string `json:"brdy"`
  3808. Certno string `json:"certno"`
  3809. ClrOptins string `json:"clr_optins"`
  3810. ClrType string `json:"clr_type"`
  3811. ClrWay string `json:"clr_way"`
  3812. CvlservFlag string `json:"cvlserv_flag"`
  3813. CvlservPay float64 `json:"cvlserv_pay"`
  3814. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3815. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3816. Gend string `json:"gend"`
  3817. HifesPay float64 `json:"hifes_pay"`
  3818. HifmiPay float64 `json:"hifmi_pay"`
  3819. HifpPay float64 `json:"hifp_pay"`
  3820. HospPartAmt float64 `json:"hosp_part_amt"`
  3821. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3822. Insutype string `json:"insutype"`
  3823. MafPay float64 `json:"maf_pay"`
  3824. MdtrtCertType string `json:"mdtrt_cert_type"`
  3825. HifobPay float64 `json:"hifob_pay"`
  3826. MdtrtID string `json:"mdtrt_id"`
  3827. MedType string `json:"med_type"`
  3828. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3829. MedinsSetlID string `json:"medins_setl_id"`
  3830. Naty string `json:"naty"`
  3831. OthPay float64 `json:"oth_pay"`
  3832. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3833. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3834. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3835. PsnCashPay float64 `json:"psn_cash_pay"`
  3836. PsnCertType string `json:"psn_cert_type"`
  3837. PsnName string `json:"psn_name"`
  3838. PsnNo string `json:"psn_no"`
  3839. PsnPartAmt float64 `json:"psn_part_amt"`
  3840. PsnType string `json:"psn_type"`
  3841. SetlID string `json:"setl_id"`
  3842. SetlTime string `json:"setl_time"`
  3843. } `json:"setlinfo"`
  3844. } `json:"output"`
  3845. RefmsgTime string `json:"refmsg_time"`
  3846. RespondTime string `json:"respond_time"`
  3847. Signtype interface{} `json:"signtype"`
  3848. WarnMsg interface{} `json:"warn_msg"`
  3849. }
  3850. type ResultSeven10265 struct {
  3851. Cainfo string `json:"cainfo"`
  3852. ErrMsg string `json:"err_msg"`
  3853. InfRefmsgid string `json:"inf_refmsgid"`
  3854. Infcode string `json:"infcode"`
  3855. Output struct {
  3856. Setldetail []interface{} `json:"setldetail"`
  3857. Setlinfo struct {
  3858. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3859. AcctPay float64 `json:"acct_pay"`
  3860. ActPayDedc float64 `json:"act_pay_dedc"`
  3861. Age float64 `json:"age"`
  3862. Balc float64 `json:"balc"`
  3863. Brdy string `json:"brdy"`
  3864. Certno string `json:"certno"`
  3865. ClrOptins string `json:"clr_optins"`
  3866. ClrType string `json:"clr_type"`
  3867. ClrWay string `json:"clr_way"`
  3868. CvlservFlag string `json:"cvlserv_flag"`
  3869. CvlservPay float64 `json:"cvlserv_pay"`
  3870. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3871. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3872. Gend string `json:"gend"`
  3873. HifesPay float64 `json:"hifes_pay"`
  3874. HifmiPay float64 `json:"hifmi_pay"`
  3875. HifpPay float64 `json:"hifp_pay"`
  3876. HospPartAmt float64 `json:"hosp_part_amt"`
  3877. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3878. Insutype string `json:"insutype"`
  3879. MafPay float64 `json:"maf_pay"`
  3880. MdtrtCertType string `json:"mdtrt_cert_type"`
  3881. HifobPay float64 `json:"hifob_pay"`
  3882. MdtrtID string `json:"mdtrt_id"`
  3883. MedType string `json:"med_type"`
  3884. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3885. MedinsSetlID string `json:"medins_setl_id"`
  3886. Naty string `json:"naty"`
  3887. OthPay float64 `json:"oth_pay"`
  3888. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3889. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3890. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3891. PsnCashPay float64 `json:"psn_cash_pay"`
  3892. PsnCertType string `json:"psn_cert_type"`
  3893. PsnName string `json:"psn_name"`
  3894. PsnNo string `json:"psn_no"`
  3895. PsnPartAmt float64 `json:"psn_part_amt"`
  3896. PsnType string `json:"psn_type"`
  3897. SetlID string `json:"setl_id"`
  3898. SetlTime string `json:"setl_time"`
  3899. } `json:"setlinfo"`
  3900. } `json:"output"`
  3901. RefmsgTime string `json:"refmsg_time"`
  3902. RespondTime string `json:"respond_time"`
  3903. Signtype interface{} `json:"signtype"`
  3904. WarnMsg interface{} `json:"warn_msg"`
  3905. }
  3906. type ResultEight struct {
  3907. Cainfo string `json:"cainfo"`
  3908. ErrMsg string `json:"err_msg"`
  3909. InfRefmsgid string `json:"inf_refmsgid"`
  3910. Infcode int64 `json:"infcode"`
  3911. Output struct {
  3912. Stmtinfo struct {
  3913. SetlOptins string `json:"setl_optins"`
  3914. StmtRslt string `json:"stmt_rslt"`
  3915. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3916. } `json:"stmtinfo"`
  3917. } `json:"output"`
  3918. RefmsgTime string `json:"refmsg_time"`
  3919. RespondTime string `json:"respond_time"`
  3920. Signtype interface{} `json:"signtype"`
  3921. WarnMsg interface{} `json:"warn_msg"`
  3922. }
  3923. type ResultEightFor10188 struct {
  3924. Cainfo string `json:"cainfo"`
  3925. ErrMsg string `json:"err_msg"`
  3926. InfRefmsgid string `json:"inf_refmsgid"`
  3927. Infcode string `json:"infcode"`
  3928. Output struct {
  3929. Stmtinfo struct {
  3930. SetlOptins string `json:"setl_optins"`
  3931. StmtRslt string `json:"stmt_rslt"`
  3932. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3933. } `json:"stmtinfo"`
  3934. } `json:"output"`
  3935. RefmsgTime string `json:"refmsg_time"`
  3936. RespondTime string `json:"respond_time"`
  3937. Signtype interface{} `json:"signtype"`
  3938. WarnMsg interface{} `json:"warn_msg"`
  3939. }
  3940. type ResultNine struct {
  3941. Cainfo string `json:"cainfo"`
  3942. ErrMsg string `json:"err_msg"`
  3943. InfRefmsgid string `json:"inf_refmsgid"`
  3944. Infcode int64 `json:"infcode"`
  3945. Output struct {
  3946. FileQuryNo string `json:"file_qury_no"`
  3947. } `json:"output"`
  3948. RefmsgTime string `json:"refmsg_time"`
  3949. RespondTime string `json:"respond_time"`
  3950. Signtype interface{} `json:"signtype"`
  3951. WarnMsg interface{} `json:"warn_msg"`
  3952. }
  3953. type ResultTen struct {
  3954. Cainfo string `json:"cainfo"`
  3955. ErrMsg string `json:"err_msg"`
  3956. InfRefmsgid string `json:"inf_refmsgid"`
  3957. Infcode int64 `json:"infcode"`
  3958. Output struct {
  3959. DldEndtime string `json:"dld_endtime"`
  3960. FileQuryNo string `json:"file_qury_no"`
  3961. Filename string `json:"filename"`
  3962. } `json:"output"`
  3963. RefmsgTime string `json:"refmsg_time"`
  3964. RespondTime string `json:"respond_time"`
  3965. Signtype interface{} `json:"signtype"`
  3966. WarnMsg interface{} `json:"warn_msg"`
  3967. }
  3968. //type Autogenerated struct {
  3969. // Output struct {
  3970. // Setlinfo struct {
  3971. // SetlTime string `json:"setl_time"`
  3972. // CvlservPay float64 `json:"cvlserv_pay"`
  3973. // Year string `json:"year"`
  3974. // MedType string `json:"med_type"`
  3975. // PsnPay float64 `json:"psn_pay"`
  3976. // OpterID string `json:"opter_id"`
  3977. // Begndate string `json:"begndate"`
  3978. // FlxempeFlag string `json:"flxempe_flag"`
  3979. // HifmiPay float64 `json:"hifmi_pay"`
  3980. // PsnNo string `json:"psn_no"`
  3981. // ActPayDedc float64 `json:"act_pay_dedc"`
  3982. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3983. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3984. // ClrWay string `json:"clr_way"`
  3985. // OthPay float64 `json:"oth_pay"`
  3986. // Gend string `json:"gend"`
  3987. // MdtrtID string `json:"mdtrt_id"`
  3988. // AcctPay float64 `json:"acct_pay"`
  3989. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3990. // Insutype string `json:"insutype"`
  3991. // Invono interface{} `json:"invono"`
  3992. // Enddate string `json:"enddate"`
  3993. // CashPayamt float64 `json:"cash_payamt"`
  3994. // PsnType string `json:"psn_type"`
  3995. // FixmedinsName string `json:"fixmedins_name"`
  3996. // HifpPay float64 `json:"hifp_pay"`
  3997. // NewFlag interface{} `json:"new_flag"`
  3998. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3999. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  4000. // PayLoc string `json:"pay_loc"`
  4001. // ClrType string `json:"clr_type"`
  4002. // RefdSetlFlag string `json:"refd_setl_flag"`
  4003. // CvlservFlag string `json:"cvlserv_flag"`
  4004. // EmpName string `json:"emp_name"`
  4005. // Brdy string `json:"brdy"`
  4006. // Naty string `json:"naty"`
  4007. // Certno string `json:"certno"`
  4008. // DiseCode string `json:"dise_code"`
  4009. // FixmedinsCode string `json:"fixmedins_code"`
  4010. // DedcHospLv string `json:"dedc_hosp_lv"`
  4011. // OpterName string `json:"opter_name"`
  4012. // Balc float64 `json:"balc"`
  4013. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4014. // PsnCertType string `json:"psn_cert_type"`
  4015. // HifobPay float64 `json:"hifob_pay"`
  4016. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  4017. // HifesPay float64 `json:"hifes_pay"`
  4018. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4019. // OptTime string `json:"opt_time"`
  4020. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4021. // SetlID string `json:"setl_id"`
  4022. // MafPay float64 `json:"maf_pay"`
  4023. // PsnName string `json:"psn_name"`
  4024. // InsuOptins interface{} `json:"insu_optins"`
  4025. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4026. // ClrOptins string `json:"clr_optins"`
  4027. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4028. // DiseName string `json:"dise_name"`
  4029. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4030. // Age float64 `json:"age"`
  4031. // DtrtCertType string `json:"dtrt_cert_type"`
  4032. // HospLv string `json:"hosp_lv"`
  4033. // } `json:"setlinfo"`
  4034. // Setldetail []struct {
  4035. // FundPayType string `json:"fund_pay_type"`
  4036. // FundPayamt float64 `json:"fund_payamt"`
  4037. // SetlProcInfo interface{} `json:"setl_proc_info"`
  4038. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  4039. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  4040. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  4041. // PrefFundPay interface{} `json:"pref_fund_pay"`
  4042. // } `json:"setldetail"`
  4043. // } `json:"output"`
  4044. // Infcode int `json:"infcode"`
  4045. // WarnMsg interface{} `json:"warn_msg"`
  4046. // Cainfo interface{} `json:"cainfo"`
  4047. // ErrMsg interface{} `json:"err_msg"`
  4048. // RefmsgTime string `json:"refmsg_time"`
  4049. // Signtype interface{} `json:"signtype"`
  4050. // RespondTime string `json:"respond_time"`
  4051. // InfRefmsgid string `json:"inf_refmsgid"`
  4052. //}
  4053. type ResultEleven struct {
  4054. Cainfo string `json:"cainfo"`
  4055. ErrMsg string `json:"err_msg"`
  4056. InfRefmsgid string `json:"inf_refmsgid"`
  4057. Infcode int64 `json:"infcode"`
  4058. Output struct {
  4059. Setlinfo struct {
  4060. SetlTime string `json:"setl_time"`
  4061. CvlservPay float64 `json:"cvlserv_pay"`
  4062. Year string `json:"year"`
  4063. MedType string `json:"med_type"`
  4064. PsnPay float64 `json:"psn_pay"`
  4065. OpterID string `json:"opter_id"`
  4066. Begndate string `json:"begndate"`
  4067. FlxempeFlag string `json:"flxempe_flag"`
  4068. HifmiPay float64 `json:"hifmi_pay"`
  4069. PsnNo string `json:"psn_no"`
  4070. ActPayDedc float64 `json:"act_pay_dedc"`
  4071. MedinsSetlID interface{} `json:"medins_setl_id"`
  4072. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4073. ClrWay string `json:"clr_way"`
  4074. OthPay float64 `json:"oth_pay"`
  4075. Gend string `json:"gend"`
  4076. MdtrtID string `json:"mdtrt_id"`
  4077. AcctPay float64 `json:"acct_pay"`
  4078. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4079. Insutype string `json:"insutype"`
  4080. Invono interface{} `json:"invono"`
  4081. Enddate string `json:"enddate"`
  4082. CashPayamt float64 `json:"cash_payamt"`
  4083. PsnType string `json:"psn_type"`
  4084. FixmedinsName string `json:"fixmedins_name"`
  4085. HifpPay float64 `json:"hifp_pay"`
  4086. NewFlag interface{} `json:"new_flag"`
  4087. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4088. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4089. PayLoc string `json:"pay_loc"`
  4090. ClrType string `json:"clr_type"`
  4091. RefdSetlFlag string `json:"refd_setl_flag"`
  4092. CvlservFlag string `json:"cvlserv_flag"`
  4093. EmpName string `json:"emp_name"`
  4094. Brdy string `json:"brdy"`
  4095. Naty string `json:"naty"`
  4096. Certno string `json:"certno"`
  4097. DiseCode string `json:"dise_code"`
  4098. FixmedinsCode string `json:"fixmedins_code"`
  4099. DedcHospLv string `json:"dedc_hosp_lv"`
  4100. OpterName string `json:"opter_name"`
  4101. Balc float64 `json:"balc"`
  4102. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4103. PsnCertType string `json:"psn_cert_type"`
  4104. HifobPay float64 `json:"hifob_pay"`
  4105. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4106. HifesPay float64 `json:"hifes_pay"`
  4107. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4108. OptTime string `json:"opt_time"`
  4109. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4110. SetlID string `json:"setl_id"`
  4111. MafPay float64 `json:"maf_pay"`
  4112. PsnName string `json:"psn_name"`
  4113. InsuOptins interface{} `json:"insu_optins"`
  4114. PrefFundPay interface{} `json:"pref_fund_pay"`
  4115. ClrOptins string `json:"clr_optins"`
  4116. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4117. DiseName string `json:"dise_name"`
  4118. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4119. Age float64 `json:"age"`
  4120. DtrtCertType string `json:"dtrt_cert_type"`
  4121. HospLv string `json:"hosp_lv"`
  4122. } `json:"setlinfo"`
  4123. } `json:"output"`
  4124. RefmsgTime string `json:"refmsg_time"`
  4125. RespondTime string `json:"respond_time"`
  4126. Signtype interface{} `json:"signtype"`
  4127. WarnMsg interface{} `json:"warn_msg"`
  4128. }
  4129. type ResultEleven10265 struct {
  4130. Cainfo string `json:"cainfo"`
  4131. ErrMsg string `json:"err_msg"`
  4132. InfRefmsgid string `json:"inf_refmsgid"`
  4133. Infcode string `json:"infcode"`
  4134. Output struct {
  4135. Setlinfo struct {
  4136. SetlTime string `json:"setl_time"`
  4137. CvlservPay float64 `json:"cvlserv_pay"`
  4138. Year string `json:"year"`
  4139. MedType string `json:"med_type"`
  4140. PsnPay float64 `json:"psn_pay"`
  4141. OpterID string `json:"opter_id"`
  4142. Begndate string `json:"begndate"`
  4143. FlxempeFlag string `json:"flxempe_flag"`
  4144. HifmiPay float64 `json:"hifmi_pay"`
  4145. PsnNo string `json:"psn_no"`
  4146. ActPayDedc float64 `json:"act_pay_dedc"`
  4147. MedinsSetlID interface{} `json:"medins_setl_id"`
  4148. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  4149. ClrWay string `json:"clr_way"`
  4150. OthPay float64 `json:"oth_pay"`
  4151. Gend string `json:"gend"`
  4152. MdtrtID string `json:"mdtrt_id"`
  4153. AcctPay float64 `json:"acct_pay"`
  4154. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4155. Insutype string `json:"insutype"`
  4156. Invono interface{} `json:"invono"`
  4157. Enddate string `json:"enddate"`
  4158. CashPayamt float64 `json:"cash_payamt"`
  4159. PsnType string `json:"psn_type"`
  4160. FixmedinsName string `json:"fixmedins_name"`
  4161. HifpPay float64 `json:"hifp_pay"`
  4162. NewFlag interface{} `json:"new_flag"`
  4163. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4164. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4165. PayLoc string `json:"pay_loc"`
  4166. ClrType string `json:"clr_type"`
  4167. RefdSetlFlag string `json:"refd_setl_flag"`
  4168. CvlservFlag string `json:"cvlserv_flag"`
  4169. EmpName string `json:"emp_name"`
  4170. Brdy string `json:"brdy"`
  4171. Naty string `json:"naty"`
  4172. Certno string `json:"certno"`
  4173. DiseCode string `json:"dise_code"`
  4174. FixmedinsCode string `json:"fixmedins_code"`
  4175. DedcHospLv string `json:"dedc_hosp_lv"`
  4176. OpterName string `json:"opter_name"`
  4177. Balc float64 `json:"balc"`
  4178. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  4179. PsnCertType string `json:"psn_cert_type"`
  4180. HifobPay float64 `json:"hifob_pay"`
  4181. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4182. HifesPay float64 `json:"hifes_pay"`
  4183. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4184. OptTime string `json:"opt_time"`
  4185. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4186. SetlID string `json:"setl_id"`
  4187. MafPay float64 `json:"maf_pay"`
  4188. PsnName string `json:"psn_name"`
  4189. InsuOptins interface{} `json:"insu_optins"`
  4190. PrefFundPay interface{} `json:"pref_fund_pay"`
  4191. ClrOptins string `json:"clr_optins"`
  4192. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4193. DiseName string `json:"dise_name"`
  4194. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4195. Age float64 `json:"age"`
  4196. DtrtCertType string `json:"dtrt_cert_type"`
  4197. HospLv string `json:"hosp_lv"`
  4198. } `json:"setlinfo"`
  4199. } `json:"output"`
  4200. RefmsgTime string `json:"refmsg_time"`
  4201. RespondTime string `json:"respond_time"`
  4202. Signtype interface{} `json:"signtype"`
  4203. WarnMsg interface{} `json:"warn_msg"`
  4204. }
  4205. type ResultTwelve struct {
  4206. Cainfo string `json:"cainfo"`
  4207. ErrMsg string `json:"err_msg"`
  4208. InfRefmsgid string `json:"inf_refmsgid"`
  4209. Infcode int64 `json:"infcode"`
  4210. Output struct {
  4211. MdtrtId string `json:"mdtrt_id"`
  4212. ChrgBchno string `json:"chrg_bchno"`
  4213. PsnNo string `json:"psn_no"`
  4214. } `json:"output"`
  4215. RefmsgTime string `json:"refmsg_time"`
  4216. RespondTime string `json:"respond_time"`
  4217. Signtype interface{} `json:"signtype"`
  4218. WarnMsg interface{} `json:"warn_msg"`
  4219. }
  4220. type ResultThirteen struct {
  4221. ErrMsg string `json:"err_msg"`
  4222. InfRefmsgid string `json:"inf_refmsgid"`
  4223. Infcode int64 `json:"infcode"`
  4224. Output struct {
  4225. Result struct {
  4226. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4227. } `json:"result"`
  4228. } `json:"output"`
  4229. RefmsgTime string `json:"refmsg_time"`
  4230. RespondTime string `json:"respond_time"`
  4231. Signtype interface{} `json:"signtype"`
  4232. WarnInfo interface{} `json:"warn_info"`
  4233. }
  4234. type ResultThirteen10265 struct {
  4235. ErrMsg string `json:"err_msg"`
  4236. InfRefmsgid string `json:"inf_refmsgid"`
  4237. Infcode string `json:"infcode"`
  4238. Output struct {
  4239. Result struct {
  4240. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4241. } `json:"result"`
  4242. } `json:"output"`
  4243. RefmsgTime string `json:"refmsg_time"`
  4244. RespondTime string `json:"respond_time"`
  4245. Signtype interface{} `json:"signtype"`
  4246. WarnInfo interface{} `json:"warn_info"`
  4247. }
  4248. type ResultFourteen struct {
  4249. ErrMsg string `json:"err_msg"`
  4250. InfRefmsgid string `json:"inf_refmsgid"`
  4251. Infcode int64 `json:"infcode"`
  4252. Output struct {
  4253. } `json:"output"`
  4254. RefmsgTime string `json:"refmsg_time"`
  4255. RespondTime string `json:"respond_time"`
  4256. Signtype interface{} `json:"signtype"`
  4257. WarnInfo interface{} `json:"warn_info"`
  4258. }
  4259. type ResultFourteen10265 struct {
  4260. ErrMsg string `json:"err_msg"`
  4261. InfRefmsgid string `json:"inf_refmsgid"`
  4262. Infcode string `json:"infcode"`
  4263. Output struct {
  4264. } `json:"output"`
  4265. RefmsgTime string `json:"refmsg_time"`
  4266. RespondTime string `json:"respond_time"`
  4267. Signtype interface{} `json:"signtype"`
  4268. WarnInfo interface{} `json:"warn_info"`
  4269. }
  4270. type ResultSixteen struct {
  4271. Cainfo string `json:"cainfo"`
  4272. ErrMsg string `json:"err_msg"`
  4273. InfRefmsgid string `json:"inf_refmsgid"`
  4274. Infcode int64 `json:"infcode"`
  4275. Output struct {
  4276. Setldetail []interface{} `json:"setldetail"`
  4277. Setlinfo struct {
  4278. MdtrtID string `json:"mdtrt_id"`
  4279. SetlID string `json:"setl_id"`
  4280. ClrOptins string `json:"clr_optins"`
  4281. SetlTime string `json:"setl_time"`
  4282. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4283. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4284. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4285. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4286. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4287. ActPayDedc float64 `json:"act_pay_dedc"`
  4288. HifpPay float64 `json:"hifp_pay"`
  4289. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4290. Lfpay float64 `json:"selfpay"`
  4291. CvlservPay float64 `json:"cvlserv_pay"`
  4292. HifesPay float64 `json:"hifes_pay"`
  4293. HifmiPay float64 `json:"hifmi_pay"`
  4294. HifobPay float64 `json:"hifob_pay"`
  4295. MafPay float64 `json:"maf_pay"`
  4296. OthPay float64 `json:"oth_pay"`
  4297. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4298. PsnPartAmt float64 `json:"psn_part_amt"`
  4299. AcctPay float64 `json:"acct_pay"`
  4300. Balc float64 `json:"balc"`
  4301. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4302. HospPartAmt float64 `json:"hosp_part_amt"`
  4303. MedinsSetlID string `json:"medins_setl_id"`
  4304. PdnCashPay string `json:"pdn_cash_pay"`
  4305. } `json:"setlinfo"`
  4306. } `json:"output"`
  4307. RefmsgTime string `json:"refmsg_time"`
  4308. RespondTime string `json:"respond_time"`
  4309. Signtype interface{} `json:"signtype"`
  4310. WarnMsg interface{} `json:"warn_msg"`
  4311. }
  4312. type ResultSixteen10265 struct {
  4313. Cainfo string `json:"cainfo"`
  4314. ErrMsg string `json:"err_msg"`
  4315. InfRefmsgid string `json:"inf_refmsgid"`
  4316. Infcode string `json:"infcode"`
  4317. Output struct {
  4318. Setldetail []interface{} `json:"setldetail"`
  4319. Setlinfo struct {
  4320. MdtrtID string `json:"mdtrt_id"`
  4321. SetlID string `json:"setl_id"`
  4322. ClrOptins string `json:"clr_optins"`
  4323. SetlTime string `json:"setl_time"`
  4324. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4325. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4326. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4327. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4328. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4329. ActPayDedc float64 `json:"act_pay_dedc"`
  4330. HifpPay float64 `json:"hifp_pay"`
  4331. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4332. Lfpay float64 `json:"selfpay"`
  4333. CvlservPay float64 `json:"cvlserv_pay"`
  4334. HifesPay float64 `json:"hifes_pay"`
  4335. HifmiPay float64 `json:"hifmi_pay"`
  4336. HifobPay float64 `json:"hifob_pay"`
  4337. MafPay float64 `json:"maf_pay"`
  4338. OthPay float64 `json:"oth_pay"`
  4339. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4340. PsnPartAmt float64 `json:"psn_part_amt"`
  4341. AcctPay float64 `json:"acct_pay"`
  4342. Balc float64 `json:"balc"`
  4343. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4344. HospPartAmt float64 `json:"hosp_part_amt"`
  4345. MedinsSetlID string `json:"medins_setl_id"`
  4346. PdnCashPay string `json:"pdn_cash_pay"`
  4347. } `json:"setlinfo"`
  4348. } `json:"output"`
  4349. RefmsgTime string `json:"refmsg_time"`
  4350. RespondTime string `json:"respond_time"`
  4351. Signtype interface{} `json:"signtype"`
  4352. WarnMsg interface{} `json:"warn_msg"`
  4353. }
  4354. type ResultSeventeen struct {
  4355. ErrMsg string `json:"err_msg"`
  4356. InfRefmsgid string `json:"inf_refmsgid"`
  4357. Infcode int64 `json:"infcode"`
  4358. Output struct {
  4359. SetlListId string `json:"setl_list_id"`
  4360. } `json:"output"`
  4361. RefmsgTime string `json:"refmsg_time"`
  4362. RespondTime string `json:"respond_time"`
  4363. Signtype string `json:"signtype"`
  4364. WarnInfo string `json:"warn_info"`
  4365. }
  4366. type ResultSeventeenOther struct {
  4367. ErrMsg string `json:"err_msg"`
  4368. InfRefmsgid string `json:"inf_refmsgid"`
  4369. Infcode string `json:"infcode"`
  4370. Output struct {
  4371. SetlListId string `json:"setl_list_id"`
  4372. } `json:"output"`
  4373. RefmsgTime string `json:"refmsg_time"`
  4374. RespondTime string `json:"respond_time"`
  4375. Signtype string `json:"signtype"`
  4376. WarnInfo string `json:"warn_info"`
  4377. }
  4378. type Result90991 struct {
  4379. ErrMsg string `json:"err_msg"`
  4380. InfRefmsgid string `json:"inf_refmsgid"`
  4381. Infcode int64 `json:"infcode"`
  4382. Output struct {
  4383. Result struct {
  4384. PsnNo string `json:"psn_no"`
  4385. CardStat string `json:"card_stat"`
  4386. Certno string `json:"certno"`
  4387. PsnName string `json:"psn_name"`
  4388. CheckStat string `json:"check_stat"`
  4389. SscnoCheckStat string `json:"sscno_check_stat"`
  4390. } `json:"result"`
  4391. } `json:"output"`
  4392. RefmsgTime string `json:"refmsg_time"`
  4393. RespondTime string `json:"respond_time"`
  4394. Signtype interface{} `json:"signtype"`
  4395. WarnInfo interface{} `json:"warn_info"`
  4396. }
  4397. type Result90100 struct {
  4398. ErrMsg string `json:"err_msg"`
  4399. InfRefmsgid string `json:"inf_refmsgid"`
  4400. Infcode int64 `json:"infcode"`
  4401. Output struct {
  4402. PoolareaNo string `json:"poolarea_no"`
  4403. PoolareaNoName string `json:"poolarea_no_name"`
  4404. Insutype string `json:"insutype"`
  4405. InsutypeName string `json:"insutype_name"`
  4406. ClctType string `json:"clct_type"`
  4407. ClctTypeName string `json:"clct_type_name"`
  4408. ClctFlag string `json:"clct_flag"`
  4409. ClctFlagName string `json:"clct_flag_name"`
  4410. AccrymBegn string `json:"accrym_begn"`
  4411. AccrymEnd string `json:"accrym_end"`
  4412. ClctTime string `json:"clct_time"`
  4413. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4414. } `json:"output"`
  4415. RefmsgTime string `json:"refmsg_time"`
  4416. RespondTime string `json:"respond_time"`
  4417. Signtype interface{} `json:"signtype"`
  4418. WarnInfo interface{} `json:"warn_info"`
  4419. }
  4420. type Custom struct {
  4421. DetItemFeeSumamt string
  4422. Cut string
  4423. FeedetlSn string
  4424. Price string
  4425. MedListCodg string
  4426. Type int64
  4427. AdviceId int64
  4428. ProjectId int64
  4429. ItemId int64
  4430. }
  4431. type Result5301 struct {
  4432. ErrMsg string `json:"err_msg"`
  4433. InfRefmsgid string `json:"inf_refmsgid"`
  4434. Infcode int64 `json:"infcode"`
  4435. Output struct {
  4436. Result []struct {
  4437. OpspDiseCode string `json:"opsp_dise_code"`
  4438. OpspDiseName string `json:"opsp_dise_name"`
  4439. Begndate string `json:"begndate"`
  4440. Enddate string `json:"enddate"`
  4441. } `json:"feedetail"`
  4442. } `json:"output"`
  4443. RefmsgTime string `json:"refmsg_time"`
  4444. RespondTime string `json:"respond_time"`
  4445. Signtype interface{} `json:"signtype"`
  4446. WarnInfo interface{} `json:"warn_info"`
  4447. }
  4448. type Result5301For10265 struct {
  4449. ErrMsg string `json:"err_msg"`
  4450. InfRefmsgid string `json:"inf_refmsgid"`
  4451. Infcode string `json:"infcode"`
  4452. Output struct {
  4453. Result []struct {
  4454. OpspDiseCode string `json:"opsp_dise_code"`
  4455. OpspDiseName string `json:"opsp_dise_name"`
  4456. Begndate string `json:"begndate"`
  4457. Enddate string `json:"enddate"`
  4458. } `json:"feedetail"`
  4459. } `json:"output"`
  4460. RefmsgTime string `json:"refmsg_time"`
  4461. RespondTime string `json:"respond_time"`
  4462. Signtype interface{} `json:"signtype"`
  4463. WarnInfo interface{} `json:"warn_info"`
  4464. }
  4465. //获取个人信息----挂号-----上传就诊信息
  4466. func (c *HisApiController) GetRegisterInfo() {
  4467. id, _ := c.GetInt64("id")
  4468. record_time := c.GetString("record_time")
  4469. settlementValue, _ := c.GetInt64("settlement_value")
  4470. medical_insurance_card := c.GetString("medical_insurance_card")
  4471. name := c.GetString("name")
  4472. id_card_type, _ := c.GetInt64("id_card_type")
  4473. certificates, _ := c.GetInt64("certificates")
  4474. medical_care, _ := c.GetInt64("medical_care")
  4475. birthday := c.GetString("birthday")
  4476. id_card := c.GetString("id_card")
  4477. register_type, _ := c.GetInt64("register")
  4478. doctor, _ := c.GetInt64("doctor")
  4479. department, _ := c.GetInt64("department")
  4480. gender, _ := c.GetInt64("sex")
  4481. registration_fee, _ := c.GetFloat("registration_fee")
  4482. medical_expenses, _ := c.GetFloat("medical_expenses")
  4483. social_type, _ := c.GetInt64("social_type")
  4484. med_type := c.GetString("social_type")
  4485. admin_user_id, _ := c.GetInt64("admin_user_id")
  4486. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4487. timeLayout := "2006-01-02"
  4488. loc, _ := time.LoadLocation("Local")
  4489. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4490. birthUnix := birthdays.Unix()
  4491. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4492. if err != nil {
  4493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4494. return
  4495. }
  4496. recordDateTime := theTime.Unix()
  4497. adminInfo := c.GetAdminUserInfo()
  4498. var patient service.Patients
  4499. if id == 0 {
  4500. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4501. } else {
  4502. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4503. }
  4504. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4505. if patientPrescription.ID == 0 {
  4506. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4507. }
  4508. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4509. if patient.ID == 0 {
  4510. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4511. return
  4512. }
  4513. if len(patient.IdCardNo) == 0 {
  4514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4515. return
  4516. }
  4517. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4518. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4519. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4520. //就诊结算未完成,不能进行二次挂号
  4521. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4522. if len(his) >= 1 {
  4523. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4524. if len(his) >= 1 && order.ID == 0 {
  4525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4526. return
  4527. }
  4528. }
  4529. //var register_log string
  4530. if config.IsOpen == 1 {
  4531. var res ResultTwo
  4532. var res10265 ResultTwo10265
  4533. var PsnNo string
  4534. var PsnCertType string
  4535. var Certno string
  4536. var PsnName string
  4537. var Gend string
  4538. var Naty string
  4539. var Brdy string
  4540. var Age float64
  4541. var infoStr string
  4542. var idetinfoStr string
  4543. var infocode int64
  4544. var verify_number string
  4545. fmt.Println(verify_number)
  4546. if miConfig.MdtrtareaAdmvs == "421300" {
  4547. psn_info, _ := service.GetPsnByPatientId(id)
  4548. PsnNo = psn_info.PsnNo
  4549. PsnCertType = psn_info.PsnCertType
  4550. Certno = psn_info.Certno
  4551. PsnName = psn_info.PsnName
  4552. Gend = psn_info.Gend
  4553. Naty = psn_info.Naty
  4554. Brdy = psn_info.Brdy
  4555. Age = psn_info.Age
  4556. infoStr = psn_info.Insuinfo
  4557. idetinfoStr = psn_info.Idetinfo
  4558. infocode = 0
  4559. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4560. psn_info, _ := service.GetPsnByPatientId(id)
  4561. PsnNo = psn_info.PsnNo
  4562. PsnCertType = psn_info.PsnCertType
  4563. Certno = psn_info.Certno
  4564. PsnName = psn_info.PsnName
  4565. Gend = psn_info.Gend
  4566. Naty = psn_info.Naty
  4567. Brdy = psn_info.Brdy
  4568. Age = psn_info.Age
  4569. infoStr = psn_info.Insuinfo
  4570. idetinfoStr = psn_info.Idetinfo
  4571. infocode = 0
  4572. verify_number = psn_info.VerifyNumber
  4573. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4574. psn_info, _ := service.GetPsnByPatientId(id)
  4575. PsnNo = psn_info.PsnNo
  4576. PsnCertType = psn_info.PsnCertType
  4577. Certno = psn_info.Certno
  4578. PsnName = psn_info.PsnName
  4579. Gend = psn_info.Gend
  4580. Naty = psn_info.Naty
  4581. Brdy = psn_info.Brdy
  4582. Age = psn_info.Age
  4583. infoStr = psn_info.Insuinfo
  4584. idetinfoStr = psn_info.Idetinfo
  4585. infocode = 0
  4586. verify_number = psn_info.VerifyNumber
  4587. } else {
  4588. var result string
  4589. var requestLog string
  4590. if miConfig.UserOrgId == 10138 {
  4591. 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)
  4592. } else {
  4593. 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)
  4594. }
  4595. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4596. if miConfig.Code == "H15049901371" {
  4597. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4598. utils.ErrorLog("解析失败:%v", err)
  4599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4600. return
  4601. }
  4602. res.ErrMsg = res10265.ErrMsg
  4603. res.Output = res10265.Output
  4604. res.InfRefmsgid = res10265.InfRefmsgid
  4605. } else {
  4606. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4607. utils.ErrorLog("解析失败:%v", err)
  4608. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4609. return
  4610. }
  4611. }
  4612. PsnNo = res.Output.Baseinfo.PsnNo
  4613. PsnCertType = res.Output.Baseinfo.PsnCertType
  4614. Certno = res.Output.Baseinfo.Certno
  4615. PsnName = res.Output.Baseinfo.PsnName
  4616. Gend = res.Output.Baseinfo.Gend
  4617. Naty = res.Output.Baseinfo.Naty
  4618. Brdy = res.Output.Baseinfo.Brdy
  4619. Age = res.Output.Baseinfo.Age
  4620. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4621. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4622. infoStr = string(Iinfos)
  4623. idetinfoStr = string(Idetinfos)
  4624. if miConfig.Code == "H15049901371" {
  4625. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4626. } else {
  4627. infocode = res.Infcode
  4628. }
  4629. }
  4630. if infocode == 0 {
  4631. his := models.VMHisPatient{
  4632. Name: name,
  4633. Gender: gender,
  4634. Birthday: birthUnix,
  4635. MedicalTreatmentType: medical_care,
  4636. IdType: certificates,
  4637. IdCardNo: id_card,
  4638. BalanceAccountsType: settlementValue,
  4639. SocialType: social_type,
  4640. MedicalInsuranceNumber: medical_insurance_card,
  4641. RegisterType: register_type,
  4642. RegisterCost: registration_fee,
  4643. TreatmentCost: medical_expenses,
  4644. Status: 1,
  4645. Ctime: time.Now().Unix(),
  4646. Mtime: time.Now().Unix(),
  4647. PsnNo: PsnNo,
  4648. PsnCertType: PsnCertType,
  4649. Certno: Certno,
  4650. PsnName: PsnName,
  4651. Gend: Gend,
  4652. Naty: Naty,
  4653. Brdy: Brdy,
  4654. Age: Age,
  4655. Iinfo: infoStr,
  4656. Idetinfo: idetinfoStr,
  4657. PatientId: patient.ID,
  4658. RecordDate: theTime.Unix(),
  4659. UserOrgId: adminInfo.CurrentOrgId,
  4660. AdminUserId: admin_user_id,
  4661. IsReturn: 1,
  4662. IdCardType: id_card_type,
  4663. Doctor: doctor,
  4664. Departments: department,
  4665. }
  4666. timestamp := time.Now().Unix()
  4667. tempTime := time.Unix(timestamp, 0)
  4668. timeFormat := tempTime.Format("20060102150405")
  4669. chrgBchno := rand.Intn(100000) + 10000
  4670. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4671. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4672. department, _ := service.GetDepartMentDetail(department)
  4673. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4674. IdCardNo := ""
  4675. if id_card_type == 1 {
  4676. // IdCardNo = medical_insurance_card
  4677. IdCardNo = patient.IdCardNo
  4678. } else {
  4679. IdCardNo = patient.IdCardNo
  4680. }
  4681. var rf []*ResultFive
  4682. json.Unmarshal([]byte(his.Iinfo), &rf)
  4683. var insutypes []*ResultFive
  4684. var insutype string
  4685. var insuplc_admdvs_temp string
  4686. var is390 int = 0
  4687. var is310 int = 0
  4688. for _, item := range rf {
  4689. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4690. insutypes = append(insutypes, item)
  4691. }
  4692. }
  4693. if len(insutypes) == 1 {
  4694. insutype = insutypes[0].Insutype
  4695. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4696. } else {
  4697. for _, i := range insutypes {
  4698. if i.Insutype == "390" {
  4699. is390 = 1
  4700. }
  4701. if i.Insutype == "310" {
  4702. is310 = 1
  4703. }
  4704. }
  4705. }
  4706. if is390 == 1 {
  4707. insutype = "390"
  4708. }
  4709. if is310 == 1 {
  4710. insutype = "310"
  4711. }
  4712. if len(insutypes) == 0 {
  4713. insutype = "310"
  4714. }
  4715. if len(insutypes) == 2 {
  4716. insutype = med_type
  4717. }
  4718. if len(med_type) > 0 {
  4719. insutype = med_type
  4720. }
  4721. //for _, item := range rf {
  4722. // if item.Insutype == insutype {
  4723. // insuplc_admdvs = item.InsuplcAdmdvs
  4724. // }
  4725. //}
  4726. var infocode int64
  4727. var resThree ResultThree
  4728. var resThree10265 ResultThree10265
  4729. if len(insuplc_admdvs) == 0 {
  4730. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4731. } else {
  4732. insuplc_admdvs_temp = insuplc_admdvs
  4733. }
  4734. if miConfig.MdtrtareaAdmvs == "421300" {
  4735. hb_doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, patientPrescription.DoctorId)
  4736. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4737. "&org_name=" + miConfig.OrgName + "&doctor=" + hb_doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4738. "&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
  4739. resp, requestErr := http.Get(api)
  4740. if requestErr != nil {
  4741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4742. return
  4743. }
  4744. body, ioErr := ioutil.ReadAll(resp.Body)
  4745. if ioErr != nil {
  4746. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4747. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4748. return
  4749. }
  4750. var respJSON map[string]interface{}
  4751. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4752. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4754. return
  4755. }
  4756. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4757. result, _ := json.Marshal(respJSON)
  4758. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4759. utils.ErrorLog("解析失败:%v", err)
  4760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4761. return
  4762. }
  4763. infocode = resThree.Infcode
  4764. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4765. psn_info, _ := service.GetPsnByPatientId(id)
  4766. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4767. var cert_no string
  4768. if id_card_type == 3 {
  4769. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4770. cert_no = IdCardNo
  4771. } else if id_card_type == 4 {
  4772. cert_no = IdCardNo
  4773. psn_info.VerifyNumber = psn_info.VerifyNumber
  4774. } else {
  4775. bas := strings.Split(psn_info.CardInfo, "|")
  4776. cert_no = bas[2]
  4777. }
  4778. var api string
  4779. if miConfig.MdtrtareaAdmvs == "320921" {
  4780. api = "http://192.168.2.110:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4781. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4782. "&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
  4783. } else {
  4784. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4785. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4786. "&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
  4787. }
  4788. resp, requestErr := http.Get(api)
  4789. if requestErr != nil {
  4790. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4791. return
  4792. }
  4793. body, ioErr := ioutil.ReadAll(resp.Body)
  4794. if ioErr != nil {
  4795. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4797. return
  4798. }
  4799. var respJSON map[string]interface{}
  4800. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4801. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4802. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4803. return
  4804. }
  4805. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4806. result, _ := json.Marshal(respJSON)
  4807. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4808. utils.ErrorLog("解析失败:%v", err)
  4809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4810. return
  4811. }
  4812. resThree.ErrMsg = resThree10265.ErrMsg
  4813. resThree.Output = resThree10265.Output
  4814. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4815. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4816. } else if miConfig.MdtrtareaAdmvs == "350500" {
  4817. psn_info, _ := service.GetPsnByPatientId(id)
  4818. var cert_no string
  4819. if id_card_type == 1 {
  4820. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  4821. } else {
  4822. cert_no = strings.Split(psn_info.CardInfo, "|")[1]
  4823. }
  4824. fmt.Println(cert_no)
  4825. result, requestLog, _ := service.FJyb2201(psn_info.PsnNo, insutype, IdCardNo, miConfig.OrgName, doctor_info.UserName, ipt_otp_no, department.Name, miConfig.Code, department.Number, doctor_id, insuplc_admdvs_temp, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, roles.UserName, doctor_info.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey, cert_no)
  4826. saveLog(result, requestLog, "2201", "挂号")
  4827. if miConfig.Code == "H15049901371" {
  4828. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4829. utils.ErrorLog("解析失败:%v", err)
  4830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4831. return
  4832. }
  4833. resThree.ErrMsg = resThree10265.ErrMsg
  4834. resThree.Output = resThree10265.Output
  4835. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4836. } else {
  4837. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4838. utils.ErrorLog("解析失败:%v", err)
  4839. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4840. return
  4841. }
  4842. }
  4843. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4844. } else {
  4845. 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)
  4846. saveLog(result, requestLog, "2201A", "挂号")
  4847. if miConfig.Code == "H15049901371" {
  4848. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4849. utils.ErrorLog("解析失败:%v", err)
  4850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4851. return
  4852. }
  4853. resThree.ErrMsg = resThree10265.ErrMsg
  4854. resThree.Output = resThree10265.Output
  4855. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4856. } else {
  4857. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4858. utils.ErrorLog("解析失败:%v", err)
  4859. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4860. return
  4861. }
  4862. }
  4863. if miConfig.Code == "H15049901371" {
  4864. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4865. } else {
  4866. infocode = resThree.Infcode
  4867. }
  4868. }
  4869. if infocode != 0 {
  4870. adminUser := c.GetAdminUserInfo()
  4871. errlog := &models.HisOrderError{
  4872. UserOrgId: adminUser.CurrentOrgId,
  4873. Ctime: time.Now().Unix(),
  4874. Mtime: time.Now().Unix(),
  4875. ErrMsg: resThree.ErrMsg,
  4876. Status: 1,
  4877. PatientId: id,
  4878. RecordTime: recordDateTime,
  4879. Stage: 2,
  4880. }
  4881. service.CreateErrMsgLog(errlog)
  4882. c.ServeSuccessJSON(map[string]interface{}{
  4883. "failed_code": -10,
  4884. "msg": resThree.ErrMsg,
  4885. })
  4886. return
  4887. }
  4888. his.Number = resThree.Output.Data.MdtrtID
  4889. his.PsnNo = resThree.Output.Data.PsnNo
  4890. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4891. his.IdCardNo = patient.IdCardNo
  4892. his.PhoneNumber = patient.Phone
  4893. his.UserOrgId = adminInfo.CurrentOrgId
  4894. his.Insutype = insutype
  4895. his.Ctime = time.Now().Unix()
  4896. his.Mtime = time.Now().Unix()
  4897. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4898. his.Status = 1
  4899. service.UpdateHisPatientStatus(&his)
  4900. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4901. c.ServeSuccessJSON(map[string]interface{}{
  4902. "his_info": his,
  4903. })
  4904. } else {
  4905. adminUser := c.GetAdminUserInfo()
  4906. errlog := &models.HisOrderError{
  4907. UserOrgId: adminUser.CurrentOrgId,
  4908. Ctime: time.Now().Unix(),
  4909. Mtime: time.Now().Unix(),
  4910. ErrMsg: res.ErrMsg,
  4911. Status: 1,
  4912. PatientId: id,
  4913. RecordTime: recordDateTime,
  4914. Stage: 1,
  4915. }
  4916. service.CreateErrMsgLog(errlog)
  4917. c.ServeSuccessJSON(map[string]interface{}{
  4918. "failed_code": -10,
  4919. "msg": res.ErrMsg,
  4920. })
  4921. return
  4922. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4923. }
  4924. }
  4925. }
  4926. //上传明细----预结算----确认订单
  4927. func (c *HisApiController) GetUploadInfo() {
  4928. id, _ := c.GetInt64("id")
  4929. record_time := c.GetString("record_time")
  4930. his_patient_id, _ := c.GetInt64("his_patient_id")
  4931. order_id, _ := c.GetInt64("order_id")
  4932. pay_way, _ := c.GetInt64("pay_way")
  4933. pay_price, _ := c.GetFloat("pay_price")
  4934. pay_card_no := c.GetString("pay_card_no")
  4935. token := c.GetString("token")
  4936. discount_price, _ := c.GetFloat("discount_price")
  4937. preferential_price, _ := c.GetFloat("preferential_price")
  4938. reality_price, _ := c.GetFloat("reality_price")
  4939. found_price, _ := c.GetFloat("found_price")
  4940. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4941. private_price, _ := c.GetFloat("private_price")
  4942. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4943. admin_user_id, _ := c.GetInt64("admin_user_id")
  4944. fapiao_code := c.GetString("fapiao_code")
  4945. fapiao_number := c.GetString("fapiao_number")
  4946. diagnosis_id := c.GetString("diagnosis")
  4947. sick_type, _ := c.GetInt64("sick_type")
  4948. reg_type, _ := c.GetInt64("p_type")
  4949. begin_time := c.GetString("begin_time")
  4950. id_str := c.GetString("ids")
  4951. ids_arr := strings.Split(id_str, ",")
  4952. timeLayout := "2006-01-02"
  4953. loc, _ := time.LoadLocation("Local")
  4954. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4955. if err != nil {
  4956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4957. return
  4958. }
  4959. recordDateTime := theTime.Unix()
  4960. adminUser := c.GetAdminUserInfo()
  4961. var tempOrder models.HisOrder
  4962. tempOrder, _ = service.GetHisOrderByID(order_id)
  4963. var prescriptions []*models.HisPrescription
  4964. var start_time int64
  4965. var end_time int64
  4966. //押金模块
  4967. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4968. tmp_decimal := c.GetString("tmp_decimal")
  4969. var decimal float64 //本次使用的押金
  4970. var errmsg error
  4971. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4972. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4973. return
  4974. }
  4975. if len(tmp_decimal) > 0 {
  4976. if tmp_decimal[0] == 45 {
  4977. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4978. return
  4979. }
  4980. }
  4981. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4982. fmt.Println(errs)
  4983. decimal = tt
  4984. //if adminUser.CurrentOrgId == 10106{
  4985. // if len(fapiao_code) == 0{
  4986. // fapiao_code = "144072080589"
  4987. // }
  4988. // if len(fapiao_number) == 0{
  4989. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4990. // if order.ID == 0{
  4991. // fapiao_number = "00001520"
  4992. // }else{
  4993. // //fapiao_code = "00001520"
  4994. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4995. // var zero string
  4996. // if fpNumber >= 1000{
  4997. // zero = "0000" + strconv.Itoa(fpNumber)
  4998. // }else if fpNumber >= 10000{
  4999. // zero = "000" + strconv.Itoa(fpNumber)
  5000. // } else if fpNumber >= 100000{
  5001. // zero = "00" + strconv.Itoa(fpNumber)
  5002. // } else if fpNumber >= 1000000{
  5003. // zero = "0" + strconv.Itoa(fpNumber)
  5004. // }else {
  5005. // zero = strconv.Itoa(fpNumber)
  5006. // }
  5007. // fapiao_number = zero
  5008. // }
  5009. // }
  5010. //}
  5011. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5012. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5013. var patientPrescription models.HisPrescriptionInfo
  5014. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  5015. if patientPrescription.ID == 0 {
  5016. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  5017. }
  5018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5019. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  5020. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  5021. diagnosis_ids := strings.Split(diagnosis_id, ",")
  5022. var config []*models.HisXtDiagnoseConfig
  5023. for _, item := range diagnosis_ids {
  5024. id, _ := strconv.ParseInt(item, 10, 64)
  5025. diagnosisConfig, _ := service.FindDiagnoseById(id)
  5026. config = append(config, &diagnosisConfig)
  5027. }
  5028. sickConfig, _ := service.FindSickById(sick_type)
  5029. //if tempOrder.ID == 0 {
  5030. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  5031. //}
  5032. if tempOrder.ID == 0 {
  5033. var result string
  5034. var requestLog string
  5035. var res2 ResultSix
  5036. var ressix10265 ResultSix10265
  5037. if miConfig.MdtrtareaAdmvs == "421300" {
  5038. data := make(map[string]interface{})
  5039. client := &http.Client{}
  5040. data["psn_no"] = his.PsnNo
  5041. data["mdtrt_id"] = his.Number
  5042. data["opter"] = roles.UserName
  5043. data["org_name"] = miConfig.OrgName
  5044. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5045. data["doctor_id"] = doctor_info.DoctorNumber
  5046. data["doctor_name"] = doctor_info.UserName
  5047. data["department"] = department.Name
  5048. data["fixmedins_code"] = miConfig.Code
  5049. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5050. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5051. data["secret_key"] = miConfig.SecretKey
  5052. data["sick_code"] = sickConfig.CountryCode
  5053. data["sick_name"] = sickConfig.ClassName
  5054. data["dept"] = strconv.FormatInt(department.ID, 10)
  5055. data["config"] = config
  5056. data["begin_time"] = begin_time
  5057. bytesData, _ := json.Marshal(data)
  5058. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  5059. resp, _ := client.Do(req)
  5060. defer resp.Body.Close()
  5061. body, ioErr := ioutil.ReadAll(resp.Body)
  5062. if ioErr != nil {
  5063. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5064. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5065. return
  5066. }
  5067. var respJSON map[string]interface{}
  5068. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5069. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5071. return
  5072. }
  5073. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5074. userJSONBytes, _ := json.Marshal(respJSON)
  5075. fmt.Println("log")
  5076. fmt.Println(string(userJSONBytes))
  5077. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  5078. utils.ErrorLog("解析失败:%v", err)
  5079. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5080. return
  5081. }
  5082. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5083. //江苏地区国家医保医疗类别
  5084. //职工透析:医疗类别选特殊情况门诊9933
  5085. //居民血透门慢: 医疗类别选门诊慢病1402
  5086. //var med_type string
  5087. //if his.Insutype == "310" {
  5088. // if reg_type == 14 {
  5089. // med_type = "9933"
  5090. // } else if reg_type == 11 {
  5091. // med_type = "11"
  5092. //
  5093. // }
  5094. //} else if his.Insutype == "390" {
  5095. // if reg_type == 14 {
  5096. // med_type = "1402"
  5097. // } else if reg_type == 11 {
  5098. // med_type = "11"
  5099. // }
  5100. //}
  5101. data := make(map[string]interface{})
  5102. client := &http.Client{}
  5103. data["psn_no"] = his.PsnNo
  5104. data["mdtrt_id"] = his.Number
  5105. data["doctor"] = roles.UserName
  5106. data["department"] = department.Name
  5107. data["org_name"] = miConfig.OrgName
  5108. data["med_type"] = strconv.FormatInt(reg_type, 10)
  5109. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  5110. data["fixmedins_code"] = miConfig.Code
  5111. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5112. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5113. data["secret_key"] = miConfig.SecretKey
  5114. data["sick_code"] = sickConfig.CountryCode
  5115. data["sick_name"] = sickConfig.ClassName
  5116. data["url"] = miConfig.Url
  5117. data["ak"] = miConfig.AccessKey
  5118. data["begin_time"] = begin_time
  5119. data["cainfo"] = miConfig.Cainfo
  5120. data["dept"] = strconv.FormatInt(department.ID, 10)
  5121. data["config"] = config
  5122. bytesData, _ := json.Marshal(data)
  5123. var req *http.Request
  5124. if miConfig.MdtrtareaAdmvs == "320921" {
  5125. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5126. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  5127. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  5128. } else {
  5129. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  5130. }
  5131. resp, _ := client.Do(req)
  5132. defer resp.Body.Close()
  5133. body, ioErr := ioutil.ReadAll(resp.Body)
  5134. if ioErr != nil {
  5135. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5137. return
  5138. }
  5139. var respJSON map[string]interface{}
  5140. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5141. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5142. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5143. return
  5144. }
  5145. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5146. userJSONBytes, _ := json.Marshal(respJSON)
  5147. fmt.Println("log")
  5148. fmt.Println(string(userJSONBytes))
  5149. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  5150. utils.ErrorLog("解析失败:%v", err)
  5151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5152. return
  5153. }
  5154. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5155. res2.Output = ressix10265.Output
  5156. res2.ErrMsg = ressix10265.ErrMsg
  5157. res2.Cainfo = ressix10265.Cainfo
  5158. res2.WarnMsg = ressix10265.WarnMsg
  5159. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5160. res2.Infcode = infocode
  5161. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5162. result, requestLog, _ = service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5163. saveLog(result, requestLog, "2203", "上传就诊信息")
  5164. var respJSON2 map[string]interface{}
  5165. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5166. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5167. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5168. return
  5169. }
  5170. userJSONBytes2, _ := json.Marshal(respJSON2)
  5171. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5172. utils.ErrorLog("解析失败:%v", err)
  5173. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5174. return
  5175. }
  5176. } else {
  5177. if miConfig.MdtrtareaAdmvs == "440781" { //
  5178. 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)
  5179. } else {
  5180. if miConfig.Code == "H15049901371" {
  5181. //赤峰地区国家医保医疗类别
  5182. //职工透析:医疗类别选特殊情况门诊990502
  5183. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5184. var med_type string
  5185. if his.Insutype == "390" {
  5186. if reg_type == 14 {
  5187. med_type = "9933"
  5188. } else if reg_type == 11 {
  5189. med_type = "11"
  5190. }
  5191. } else if his.Insutype == "310" {
  5192. if reg_type == 14 {
  5193. med_type = "990502"
  5194. } else if reg_type == 11 {
  5195. med_type = "11"
  5196. }
  5197. }
  5198. 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)
  5199. } else {
  5200. 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)
  5201. }
  5202. }
  5203. saveLog(result, requestLog, "2203", "上传就诊信息")
  5204. var respJSON2 map[string]interface{}
  5205. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  5206. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5208. return
  5209. }
  5210. userJSONBytes2, _ := json.Marshal(respJSON2)
  5211. if miConfig.Code == "H15049901371" {
  5212. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  5213. utils.ErrorLog("解析失败:%v", err)
  5214. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5215. return
  5216. }
  5217. res2.InfRefmsgid = ressix10265.InfRefmsgid
  5218. res2.Output = ressix10265.Output
  5219. res2.ErrMsg = ressix10265.ErrMsg
  5220. res2.Cainfo = ressix10265.Cainfo
  5221. res2.WarnMsg = ressix10265.WarnMsg
  5222. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  5223. res2.Infcode = infocode
  5224. } else {
  5225. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  5226. utils.ErrorLog("解析失败:%v", err)
  5227. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5228. return
  5229. }
  5230. }
  5231. }
  5232. if res2.Infcode != 0 {
  5233. adminUser := c.GetAdminUserInfo()
  5234. errlog := &models.HisOrderError{
  5235. UserOrgId: adminUser.CurrentOrgId,
  5236. Ctime: time.Now().Unix(),
  5237. Mtime: time.Now().Unix(),
  5238. ErrMsg: res2.ErrMsg,
  5239. Status: 1,
  5240. PatientId: id,
  5241. RecordTime: recordDateTime,
  5242. Stage: 3,
  5243. }
  5244. service.CreateErrMsgLog(errlog)
  5245. c.ServeSuccessJSON(map[string]interface{}{
  5246. "failed_code": -10,
  5247. "msg": res2.ErrMsg,
  5248. })
  5249. return
  5250. } else {
  5251. his.Diagnosis = diagnosis_id
  5252. his.SickType = sickConfig.ID
  5253. //var p_type int64
  5254. //if reg_type == 1111 || reg_type == 1112 {
  5255. // p_type = 11
  5256. //
  5257. //}
  5258. his.PType = fmt.Sprintf("%d", reg_type)
  5259. service.UpdateHisPatientThree(&his)
  5260. data := make(map[string]interface{})
  5261. if settle_accounts_type == 1 { //日结
  5262. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  5263. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  5264. } else {
  5265. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5266. }
  5267. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5268. data["pre"] = prescriptions
  5269. } else { //月结
  5270. start_time_str := c.GetString("start_time")
  5271. end_time_str := c.GetString("end_time")
  5272. timeLayout := "2006-01-02"
  5273. loc, _ := time.LoadLocation("Local")
  5274. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5275. if err != nil {
  5276. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5277. return
  5278. }
  5279. recordStartTime := theStartTime.Unix()
  5280. start_time = recordStartTime
  5281. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5282. if err != nil {
  5283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5284. return
  5285. }
  5286. recordEndTime := theEndTime.Unix()
  5287. end_time = recordEndTime
  5288. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5289. data["pre"] = prescriptions
  5290. }
  5291. timestamp := time.Now().Unix()
  5292. tempTime := time.Unix(timestamp, 0)
  5293. timeFormat := tempTime.Format("20060102150405")
  5294. chrgBchno := rand.Intn(100000) + 10000
  5295. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5296. strconv.FormatInt(his.PatientId, 10)
  5297. client := &http.Client{}
  5298. data["psn_no"] = his.PsnNo
  5299. data["mdtrt_id"] = his.Number
  5300. data["chrg_bchno"] = chrg_bchno
  5301. data["org_name"] = miConfig.OrgName
  5302. data["doctor"] = doctor_info.UserName
  5303. data["doctor_id"] = doctor_info.DoctorNumber
  5304. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5305. data["fixmedins_code"] = miConfig.Code
  5306. data["opter"] = roles.UserName
  5307. data["dept_code"] = department.Number
  5308. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5309. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5310. data["secret_key"] = miConfig.SecretKey
  5311. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5312. data["url"] = miConfig.Url
  5313. data["ak"] = miConfig.AccessKey
  5314. data["new_doctor_name"] = patientPrescription.Doctor
  5315. data["diag_code"] = sickConfig.CountryCode
  5316. data["cainfo"] = miConfig.Cainfo
  5317. var ids []int64
  5318. for _, item := range prescriptions {
  5319. ids = append(ids, item.ID)
  5320. }
  5321. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5322. if config.IsOpen == 1 { //对接了医保,走医保流程
  5323. var res ResultFour
  5324. var resFour10265 ResultFour10265
  5325. if miConfig.MdtrtareaAdmvs == "421300" {
  5326. bytesData, _ := json.Marshal(data)
  5327. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5328. resp, _ := client.Do(req)
  5329. defer resp.Body.Close()
  5330. body, ioErr := ioutil.ReadAll(resp.Body)
  5331. if ioErr != nil {
  5332. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5334. return
  5335. }
  5336. var respJSON map[string]interface{}
  5337. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5338. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5340. return
  5341. }
  5342. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5343. userJSONBytes, _ := json.Marshal(respJSON)
  5344. fmt.Println("log")
  5345. fmt.Println(string(userJSONBytes))
  5346. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5347. utils.ErrorLog("解析失败:%v", err)
  5348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5349. return
  5350. }
  5351. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5352. bytesData, _ := json.Marshal(data)
  5353. var req *http.Request
  5354. if miConfig.MdtrtareaAdmvs == "320921" {
  5355. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5356. } else {
  5357. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5358. }
  5359. resp, _ := client.Do(req)
  5360. defer resp.Body.Close()
  5361. body, ioErr := ioutil.ReadAll(resp.Body)
  5362. if ioErr != nil {
  5363. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5364. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5365. return
  5366. }
  5367. var respJSON map[string]interface{}
  5368. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5369. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5370. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5371. return
  5372. }
  5373. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5374. userJSONBytes, _ := json.Marshal(respJSON)
  5375. fmt.Println("log")
  5376. fmt.Println(string(userJSONBytes))
  5377. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5378. utils.ErrorLog("解析失败:%v", err)
  5379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5380. return
  5381. }
  5382. res.InfRefmsgid = resFour10265.InfRefmsgid
  5383. res.Output = resFour10265.Output
  5384. res.ErrMsg = resFour10265.ErrMsg
  5385. res.Cainfo = resFour10265.Cainfo
  5386. res.WarnMsg = resFour10265.WarnMsg
  5387. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5388. res.Infcode = infocode
  5389. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5390. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5391. var dat map[string]interface{}
  5392. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5393. fmt.Println(dat)
  5394. } else {
  5395. fmt.Println(err)
  5396. }
  5397. saveLog(result, request_log, "2204", "上传费用明细")
  5398. userJSONBytes, _ := json.Marshal(dat)
  5399. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5400. utils.ErrorLog("解析失败:%v", err)
  5401. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5402. return
  5403. }
  5404. res.InfRefmsgid = resFour10265.InfRefmsgid
  5405. res.Output = resFour10265.Output
  5406. res.ErrMsg = resFour10265.ErrMsg
  5407. res.Cainfo = resFour10265.Cainfo
  5408. res.WarnMsg = resFour10265.WarnMsg
  5409. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5410. res.Infcode = infocode
  5411. } else {
  5412. if miConfig.Code == "H15049901371" {
  5413. 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)
  5414. var dat map[string]interface{}
  5415. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5416. fmt.Println(dat)
  5417. } else {
  5418. fmt.Println(err)
  5419. }
  5420. saveLog(result, request_log, "2204", "上传费用明细")
  5421. userJSONBytes, _ := json.Marshal(dat)
  5422. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5423. utils.ErrorLog("解析失败:%v", err)
  5424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5425. return
  5426. }
  5427. res.InfRefmsgid = resFour10265.InfRefmsgid
  5428. res.Output = resFour10265.Output
  5429. res.ErrMsg = resFour10265.ErrMsg
  5430. res.Cainfo = resFour10265.Cainfo
  5431. res.WarnMsg = resFour10265.WarnMsg
  5432. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5433. res.Infcode = infocode
  5434. } else {
  5435. 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)
  5436. var dat map[string]interface{}
  5437. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5438. fmt.Println(dat)
  5439. } else {
  5440. fmt.Println(err)
  5441. }
  5442. saveLog(result, request_log, "2204", "上传费用明细")
  5443. userJSONBytes, _ := json.Marshal(dat)
  5444. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5445. utils.ErrorLog("解析失败:%v", err)
  5446. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5447. return
  5448. }
  5449. }
  5450. }
  5451. if res.Infcode == 0 {
  5452. order := &models.HisOrder{
  5453. UserOrgId: adminUser.CurrentOrgId,
  5454. HisPatientId: his.ID,
  5455. PatientId: his.PatientId,
  5456. SettleAccountsDate: recordDateTime,
  5457. MdtrtId: his.Number,
  5458. PsnNo: his.PsnNo,
  5459. MedType: strconv.FormatInt(reg_type, 10),
  5460. Ctime: time.Now().Unix(),
  5461. Mtime: time.Now().Unix(),
  5462. Status: 1,
  5463. Number: chrg_bchno,
  5464. Infcode: res.Infcode,
  5465. WarnMsg: res.WarnMsg,
  5466. Cainfo: res.Cainfo,
  5467. ErrMsg: res.ErrMsg,
  5468. RespondTime: res.RefmsgTime,
  5469. InfRefmsgid: res.InfRefmsgid,
  5470. OrderStatus: 1,
  5471. PayWay: pay_way,
  5472. PayPrice: pay_price,
  5473. PayCardNo: pay_card_no,
  5474. DiscountPrice: discount_price,
  5475. PreferentialPrice: preferential_price,
  5476. RealityPrice: reality_price,
  5477. FoundPrice: found_price,
  5478. MedicalInsurancePrice: medical_insurance_price,
  5479. PrivatePrice: private_price,
  5480. IsMedicineInsurance: 1,
  5481. SettleType: settle_accounts_type,
  5482. SettleStartTime: start_time,
  5483. SettleEndTime: end_time,
  5484. Creator: roles.AdminUserId,
  5485. Modify: roles.AdminUserId,
  5486. FaPiaoNumber: fapiao_number,
  5487. FaPiaoCode: fapiao_code,
  5488. PType: 2,
  5489. Diagnosis: diagnosis_id,
  5490. }
  5491. err = service.CreateOrder(order)
  5492. if err != nil {
  5493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5494. return
  5495. }
  5496. for _, item := range res.Output.Result {
  5497. temp := strings.Split(item.FeedetlSn, "-")
  5498. var advice_id int64 = 0
  5499. var project_id int64 = 0
  5500. var types int64 = 0
  5501. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5502. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5503. if temp[1] == "1" {
  5504. advice_id = id
  5505. project_id = 0
  5506. } else if temp[1] == "2" {
  5507. advice_id = 0
  5508. project_id = id
  5509. }
  5510. info := &models.HisOrderInfo{
  5511. OrderNumber: order.Number,
  5512. FeedetlSn: item.FeedetlSn,
  5513. UploadDate: time.Now().Unix(),
  5514. AdviceId: advice_id,
  5515. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5516. Cnt: item.Cnt,
  5517. Pric: float64(item.Pric),
  5518. PatientId: his.PatientId,
  5519. PricUplmtAmt: item.PricUplmtAmt,
  5520. SelfpayProp: item.SelfpayProp,
  5521. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5522. OverlmtAmt: item.OverlmtAmt,
  5523. PreselfpayAmt: item.PreselfpayAmt,
  5524. BasMednFlag: item.BasMednFlag,
  5525. MedChrgitmType: item.MedChrgitmType,
  5526. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5527. Status: 1,
  5528. Memo: item.Memo,
  5529. Mtime: time.Now().Unix(),
  5530. InscpScpAmt: item.InscpScpAmt,
  5531. DrtReimFlag: item.DrtReimFlag,
  5532. Ctime: time.Now().Unix(),
  5533. ListSpItemFlag: item.ListSpItemFlag,
  5534. ChldMedcFlag: item.ChldMedcFlag,
  5535. LmtUsedFlag: item.LmtUsedFlag,
  5536. ChrgitmLv: item.ChrgitmLv,
  5537. UserOrgId: adminUser.CurrentOrgId,
  5538. HisPatientId: his.ID,
  5539. OrderId: order.ID,
  5540. ProjectId: project_id,
  5541. Type: types,
  5542. }
  5543. service.CreateOrderInfo(info)
  5544. }
  5545. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5546. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5547. var total float64
  5548. for _, item := range prescriptions {
  5549. if item.Type == 1 { //药品
  5550. for _, subItem := range item.HisDoctorAdviceInfo {
  5551. total = total + (subItem.Price * subItem.PrescribingNumber)
  5552. }
  5553. }
  5554. if item.Type == 2 { //项目
  5555. for _, subItem := range item.HisPrescriptionProject {
  5556. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5557. total = total + (subItem.Price * cnt)
  5558. }
  5559. }
  5560. }
  5561. for _, item := range prescriptions {
  5562. for _, subItem := range item.HisAdditionalCharge {
  5563. total = total + (subItem.Price * float64(subItem.Count))
  5564. }
  5565. }
  5566. var allTotal string
  5567. if adminUser.CurrentOrgId == 9919 {
  5568. allTotal = fmt.Sprintf("%.4f", total)
  5569. } else {
  5570. allTotal = fmt.Sprintf("%.4f", total)
  5571. }
  5572. if res.Infcode == 0 {
  5573. var rf []*ResultFive
  5574. json.Unmarshal([]byte(his.Iinfo), &rf)
  5575. chrg_bchno := chrg_bchno
  5576. cert_no := his.Certno
  5577. var insutypes []string
  5578. var insutype string
  5579. var is390 int = 0
  5580. var is310 int = 0
  5581. for _, item := range rf {
  5582. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5583. insutypes = append(insutypes, item.Insutype)
  5584. }
  5585. }
  5586. if len(insutypes) == 1 {
  5587. insutype = insutypes[0]
  5588. } else {
  5589. for _, i := range insutypes {
  5590. if i == "390" {
  5591. is390 = 1
  5592. }
  5593. if i == "310" {
  5594. is310 = 1
  5595. }
  5596. }
  5597. }
  5598. if is390 == 1 {
  5599. insutype = "390"
  5600. }
  5601. if is310 == 1 {
  5602. insutype = "310"
  5603. }
  5604. if len(insutypes) == 0 {
  5605. insutype = "310"
  5606. }
  5607. if len(insutypes) == 2 {
  5608. insutype = strconv.FormatInt(his.SocialType, 10)
  5609. }
  5610. insutype = strconv.FormatInt(his.SocialType, 10)
  5611. //insutype = "390"
  5612. if his.IdCardType == 1 {
  5613. // cert_no = his.MedicalInsuranceNumber
  5614. cert_no = his.Certno
  5615. } else {
  5616. cert_no = his.Certno
  5617. }
  5618. var res ResultSeven
  5619. var resSeven10265 ResultSeven10265
  5620. var src_resquest string
  5621. var result2 string
  5622. var acct_used_flag string
  5623. fmt.Println("pay_way")
  5624. fmt.Println(pay_way)
  5625. fmt.Println("pay_way")
  5626. if pay_way == 4 {
  5627. acct_used_flag = "1"
  5628. } else {
  5629. acct_used_flag = "0"
  5630. }
  5631. if miConfig.MdtrtareaAdmvs == "421300" {
  5632. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5633. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5634. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5635. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5636. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5637. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5638. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5639. resp, requestErr := http.Get(api)
  5640. if requestErr != nil {
  5641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5642. return
  5643. }
  5644. body, ioErr := ioutil.ReadAll(resp.Body)
  5645. if ioErr != nil {
  5646. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5647. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5648. return
  5649. }
  5650. var respJSON map[string]interface{}
  5651. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5652. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5653. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5654. return
  5655. }
  5656. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5657. result, _ := json.Marshal(respJSON)
  5658. if miConfig.Code == "H15049901371" {
  5659. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5660. utils.ErrorLog("解析失败:%v", err)
  5661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5662. return
  5663. }
  5664. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5665. res.Output = resSeven10265.Output
  5666. res.ErrMsg = resSeven10265.ErrMsg
  5667. res.Cainfo = resSeven10265.Cainfo
  5668. res.WarnMsg = resSeven10265.WarnMsg
  5669. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5670. res.Infcode = infocode
  5671. } else {
  5672. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5673. utils.ErrorLog("解析失败:%v", err)
  5674. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5675. return
  5676. }
  5677. }
  5678. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5679. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5680. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5681. bas := strings.Split(psn_info.CardInfo, "|")
  5682. if his.IdCardType == 1 {
  5683. cert_no = bas[2]
  5684. } else if his.IdCardType == 3 {
  5685. cert_no = his.Certno
  5686. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5687. } else if his.IdCardType == 4 {
  5688. cert_no = his.Certno
  5689. psn_info.VerifyNumber = token
  5690. }
  5691. var api string
  5692. if miConfig.MdtrtareaAdmvs == "320921" {
  5693. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5694. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5695. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5696. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5697. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5698. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5699. "&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
  5700. } else {
  5701. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5702. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5703. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5704. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5705. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5706. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5707. "&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
  5708. }
  5709. resp, requestErr := http.Get(api)
  5710. if requestErr != nil {
  5711. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5712. return
  5713. }
  5714. body, ioErr := ioutil.ReadAll(resp.Body)
  5715. if ioErr != nil {
  5716. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5717. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5718. return
  5719. }
  5720. var respJSON map[string]interface{}
  5721. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5722. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5723. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5724. return
  5725. }
  5726. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5727. result, _ := json.Marshal(respJSON)
  5728. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5729. utils.ErrorLog("解析失败:%v", err)
  5730. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5731. return
  5732. }
  5733. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5734. res.Output = resSeven10265.Output
  5735. res.ErrMsg = resSeven10265.ErrMsg
  5736. res.Cainfo = resSeven10265.Cainfo
  5737. res.WarnMsg = resSeven10265.WarnMsg
  5738. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5739. res.Infcode = infocode
  5740. } else if miConfig.MdtrtareaAdmvs == "350500" {
  5741. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5742. var cert_no string
  5743. if his.IdCardType == 1 {
  5744. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  5745. }
  5746. fmt.Println(cert_no)
  5747. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  5748. //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)
  5749. var dat map[string]interface{}
  5750. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5751. fmt.Println(dat)
  5752. } else {
  5753. fmt.Println(err)
  5754. }
  5755. saveLog(result2, src_resquest, "2207", "结算")
  5756. userJSONBytes, _ := json.Marshal(dat)
  5757. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5758. utils.ErrorLog("解析失败:%v", err)
  5759. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5760. return
  5761. }
  5762. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5763. res.Output = resSeven10265.Output
  5764. res.ErrMsg = resSeven10265.ErrMsg
  5765. res.Cainfo = resSeven10265.Cainfo
  5766. res.WarnMsg = resSeven10265.WarnMsg
  5767. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5768. res.Infcode = infocode
  5769. } else {
  5770. if miConfig.Code == "H15049901371" {
  5771. //赤峰地区国家医保医疗类别
  5772. //职工透析:医疗类别选特殊情况门诊990502
  5773. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5774. var med_type string
  5775. if his.Insutype == "390" {
  5776. if reg_type == 14 {
  5777. med_type = "9933"
  5778. } else if reg_type == 11 {
  5779. med_type = "11"
  5780. }
  5781. } else if his.Insutype == "310" {
  5782. if reg_type == 14 {
  5783. med_type = "990502"
  5784. } else if reg_type == 11 {
  5785. med_type = "11"
  5786. }
  5787. }
  5788. 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)
  5789. } else {
  5790. 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)
  5791. }
  5792. //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)
  5793. var dat map[string]interface{}
  5794. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5795. fmt.Println(dat)
  5796. } else {
  5797. fmt.Println(err)
  5798. }
  5799. saveLog(result2, src_resquest, "2207", "结算")
  5800. userJSONBytes, _ := json.Marshal(dat)
  5801. if miConfig.Code == "H15049901371" {
  5802. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5803. utils.ErrorLog("解析失败:%v", err)
  5804. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5805. return
  5806. }
  5807. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5808. res.Output = resSeven10265.Output
  5809. res.ErrMsg = resSeven10265.ErrMsg
  5810. res.Cainfo = resSeven10265.Cainfo
  5811. res.WarnMsg = resSeven10265.WarnMsg
  5812. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5813. res.Infcode = infocode
  5814. } else {
  5815. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5816. utils.ErrorLog("解析失败:%v", err)
  5817. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5818. return
  5819. }
  5820. }
  5821. }
  5822. if res.Infcode != 0 {
  5823. errlog := &models.HisOrderError{
  5824. UserOrgId: adminUser.CurrentOrgId,
  5825. Ctime: time.Now().Unix(),
  5826. Mtime: time.Now().Unix(),
  5827. Number: chrg_bchno,
  5828. ErrMsg: res.ErrMsg,
  5829. Status: 1,
  5830. PatientId: id,
  5831. RecordTime: recordDateTime,
  5832. Stage: 6,
  5833. }
  5834. service.CreateErrMsgLog(errlog)
  5835. c.ServeSuccessJSON(map[string]interface{}{
  5836. "failed_code": -10,
  5837. "msg": res.ErrMsg,
  5838. })
  5839. return
  5840. } else {
  5841. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5842. order.OrderStatus = 2
  5843. order.Status = 1
  5844. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5845. order.SetlId = res.Output.Setlinfo.SetlID
  5846. order.PsnNo = res.Output.Setlinfo.PsnNo
  5847. order.PsnName = res.Output.Setlinfo.PsnName
  5848. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5849. order.Certno = res.Output.Setlinfo.Certno
  5850. order.Gend = res.Output.Setlinfo.Gend
  5851. order.Naty = res.Output.Setlinfo.Naty
  5852. order.Age = res.Output.Setlinfo.Age
  5853. order.Insutype = res.Output.Setlinfo.Insutype
  5854. order.PsnType = res.Output.Setlinfo.PsnType
  5855. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5856. order.SetlTime = res.Output.Setlinfo.SetlTime
  5857. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5858. if res.Output.Setlinfo.MedType == "140101" {
  5859. order.MedType = "14"
  5860. } else {
  5861. order.MedType = res.Output.Setlinfo.MedType
  5862. }
  5863. if reg_type == 1112 {
  5864. order.MedType = "1112"
  5865. }
  5866. if reg_type == 1111 {
  5867. order.MedType = "1111"
  5868. }
  5869. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5870. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5871. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5872. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5873. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5874. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5875. order.HifpPay = res.Output.Setlinfo.HifpPay
  5876. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5877. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5878. order.HifesPay = res.Output.Setlinfo.HifesPay
  5879. order.HifobPay = res.Output.Setlinfo.HifobPay
  5880. order.MafPay = res.Output.Setlinfo.MafPay
  5881. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5882. order.OthPay = res.Output.Setlinfo.OthPay
  5883. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5884. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5885. order.AcctPay = res.Output.Setlinfo.AcctPay
  5886. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5887. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5888. order.Balc = res.Output.Setlinfo.Balc
  5889. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5890. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5891. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5892. order.ClrType = res.Output.Setlinfo.ClrType
  5893. order.ClrWay = res.Output.Setlinfo.ClrWay
  5894. order.Creator = order.Creator
  5895. order.Modify = roles.AdminUserId
  5896. order.RequestLog = src_resquest
  5897. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5898. detailStr := string(setlDetail)
  5899. order.SetlDetail = detailStr
  5900. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5901. err = service.UpDateOrder(order)
  5902. if err == nil {
  5903. //判断是否使用了押金
  5904. if dec_way == "true" {
  5905. tmpstring := strconv.FormatInt(order.ID, 10)
  5906. order.Decimal = decimal
  5907. service.UpDateOrder(order)
  5908. //扣押金
  5909. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5910. if errmsg != nil {
  5911. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5912. return
  5913. }
  5914. }
  5915. c.ServeSuccessJSON(map[string]interface{}{
  5916. "msg": "结算成功",
  5917. })
  5918. } else {
  5919. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5920. return
  5921. }
  5922. }
  5923. } else {
  5924. adminUser := c.GetAdminUserInfo()
  5925. errlog := &models.HisOrderError{
  5926. UserOrgId: adminUser.CurrentOrgId,
  5927. Ctime: time.Now().Unix(),
  5928. Mtime: time.Now().Unix(),
  5929. ErrMsg: res.ErrMsg,
  5930. Status: 1,
  5931. PatientId: id,
  5932. RecordTime: recordDateTime,
  5933. Stage: 4,
  5934. }
  5935. service.CreateErrMsgLog(errlog)
  5936. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5937. return
  5938. }
  5939. } else {
  5940. adminUser := c.GetAdminUserInfo()
  5941. errlog := &models.HisOrderError{
  5942. UserOrgId: adminUser.CurrentOrgId,
  5943. Ctime: time.Now().Unix(),
  5944. Mtime: time.Now().Unix(),
  5945. ErrMsg: res.ErrMsg,
  5946. Status: 1,
  5947. PatientId: id,
  5948. RecordTime: recordDateTime,
  5949. Stage: 4,
  5950. }
  5951. service.CreateErrMsgLog(errlog)
  5952. c.ServeSuccessJSON(map[string]interface{}{
  5953. "failed_code": -10,
  5954. "msg": res.ErrMsg,
  5955. })
  5956. return
  5957. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5958. //return
  5959. }
  5960. }
  5961. }
  5962. } else if tempOrder.ID > 0 {
  5963. if tempOrder.IsPre == 1 {
  5964. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5965. var rf []*ResultFive
  5966. json.Unmarshal([]byte(his.Iinfo), &rf)
  5967. chrg_bchno := tempOrder.Number
  5968. cert_no := his.Certno
  5969. var insutypes []string
  5970. var insutype string
  5971. var is390 int = 0
  5972. var is310 int = 0
  5973. for _, item := range rf {
  5974. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5975. insutypes = append(insutypes, item.Insutype)
  5976. }
  5977. }
  5978. if len(insutypes) == 1 {
  5979. insutype = insutypes[0]
  5980. } else {
  5981. for _, i := range insutypes {
  5982. if i == "390" {
  5983. is390 = 1
  5984. }
  5985. if i == "310" {
  5986. is310 = 1
  5987. }
  5988. }
  5989. }
  5990. if is390 == 1 {
  5991. insutype = "390"
  5992. }
  5993. if is310 == 1 {
  5994. insutype = "310"
  5995. }
  5996. if len(insutypes) == 0 {
  5997. insutype = "310"
  5998. }
  5999. if len(insutypes) == 2 {
  6000. insutype = strconv.FormatInt(his.SocialType, 64)
  6001. }
  6002. //insutype = "390"
  6003. if his.IdCardType == 1 {
  6004. // cert_no = his.MedicalInsuranceNumber
  6005. cert_no = his.Certno
  6006. } else {
  6007. cert_no = his.Certno
  6008. }
  6009. var res ResultSeven
  6010. var resSeven10265 ResultSeven10265
  6011. var src_resquest string
  6012. var result2 string
  6013. var acct_used_flag string
  6014. fmt.Println("pay_way")
  6015. fmt.Println(pay_way)
  6016. fmt.Println("pay_way")
  6017. if pay_way == 4 {
  6018. acct_used_flag = "1"
  6019. } else {
  6020. acct_used_flag = "0"
  6021. }
  6022. if miConfig.MdtrtareaAdmvs == "421300" {
  6023. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6024. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6025. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6026. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6027. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6028. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6029. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  6030. resp, requestErr := http.Get(api)
  6031. if requestErr != nil {
  6032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6033. return
  6034. }
  6035. body, ioErr := ioutil.ReadAll(resp.Body)
  6036. if ioErr != nil {
  6037. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6039. return
  6040. }
  6041. var respJSON map[string]interface{}
  6042. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6043. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6045. return
  6046. }
  6047. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6048. result, _ := json.Marshal(respJSON)
  6049. fmt.Println("log")
  6050. fmt.Println(string(result))
  6051. if err := json.Unmarshal([]byte(result), &res); err != nil {
  6052. utils.ErrorLog("解析失败:%v", err)
  6053. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6054. return
  6055. }
  6056. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6057. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6058. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  6059. //psn_info, _ := service.GetPsnByPatientId(id)
  6060. bas := strings.Split(psn_info.CardInfo, "|")
  6061. if his.IdCardType == 1 {
  6062. cert_no = bas[2]
  6063. } else {
  6064. cert_no = bas[1]
  6065. }
  6066. //江苏地区国家医保医疗类别
  6067. //职工透析:医疗类别选特殊情况门诊9933
  6068. //居民血透门慢: 医疗类别选门诊慢病1402
  6069. //var med_type string
  6070. //if his.Insutype == "310" {
  6071. // if reg_type == 14 {
  6072. // med_type = "9933"
  6073. // } else if reg_type == 11 {
  6074. // med_type = "11"
  6075. //
  6076. // }
  6077. //} else if his.Insutype == "390" {
  6078. // if reg_type == 14 {
  6079. // med_type = "1402"
  6080. // } else if reg_type == 11 {
  6081. // med_type = "11"
  6082. // }
  6083. //}
  6084. var api string
  6085. if miConfig.MdtrtareaAdmvs == "320921" {
  6086. api = "http://192.168.2.110:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6087. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6088. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6089. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6090. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6091. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6092. "&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
  6093. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6094. } else {
  6095. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6096. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  6097. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  6098. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  6099. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  6100. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  6101. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  6102. "&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
  6103. }
  6104. resp, requestErr := http.Get(api)
  6105. if requestErr != nil {
  6106. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6107. return
  6108. }
  6109. body, ioErr := ioutil.ReadAll(resp.Body)
  6110. if ioErr != nil {
  6111. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6112. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6113. return
  6114. }
  6115. var respJSON map[string]interface{}
  6116. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6117. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6119. return
  6120. }
  6121. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6122. result, _ := json.Marshal(respJSON)
  6123. fmt.Println("log")
  6124. fmt.Println(string(result))
  6125. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  6126. utils.ErrorLog("解析失败:%v", err)
  6127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6128. return
  6129. }
  6130. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6131. res.Output = resSeven10265.Output
  6132. res.ErrMsg = resSeven10265.ErrMsg
  6133. res.Cainfo = resSeven10265.Cainfo
  6134. res.WarnMsg = resSeven10265.WarnMsg
  6135. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6136. res.Infcode = infocode
  6137. } else if miConfig.MdtrtareaAdmvs == "350500" {
  6138. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  6139. var cert_no string
  6140. if his.IdCardType == 1 {
  6141. cert_no = strings.Split(psn_info.CardInfo, "|")[0]
  6142. }
  6143. fmt.Println(cert_no)
  6144. result2, src_resquest, _ = service.FJyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType, acct_used_flag, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  6145. var dat map[string]interface{}
  6146. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6147. fmt.Println(dat)
  6148. } else {
  6149. fmt.Println(err)
  6150. }
  6151. saveLog(result2, src_resquest, "2207", "结算")
  6152. userJSONBytes, _ := json.Marshal(dat)
  6153. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6154. utils.ErrorLog("解析失败:%v", err)
  6155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6156. return
  6157. }
  6158. } else {
  6159. var src_resquest string
  6160. if miConfig.Code == "H15049901371" {
  6161. //赤峰地区国家医保医疗类别
  6162. //职工透析:医疗类别选特殊情况门诊990502
  6163. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6164. var med_type string
  6165. if his.Insutype == "390" {
  6166. if reg_type == 14 {
  6167. med_type = "9933"
  6168. } else if reg_type == 11 {
  6169. med_type = "11"
  6170. }
  6171. } else if his.Insutype == "310" {
  6172. if reg_type == 14 {
  6173. med_type = "990502"
  6174. } else if reg_type == 11 {
  6175. med_type = "11"
  6176. }
  6177. }
  6178. 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)
  6179. } else {
  6180. 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)
  6181. }
  6182. var dat map[string]interface{}
  6183. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  6184. fmt.Println(dat)
  6185. } else {
  6186. fmt.Println(err)
  6187. }
  6188. saveLog(result2, src_resquest, "2207", "结算")
  6189. userJSONBytes, _ := json.Marshal(dat)
  6190. if miConfig.Code == "H15049901371" {
  6191. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  6192. utils.ErrorLog("解析失败:%v", err)
  6193. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6194. return
  6195. }
  6196. res.InfRefmsgid = resSeven10265.InfRefmsgid
  6197. res.Output = resSeven10265.Output
  6198. res.ErrMsg = resSeven10265.ErrMsg
  6199. res.Cainfo = resSeven10265.Cainfo
  6200. res.WarnMsg = resSeven10265.WarnMsg
  6201. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  6202. res.Infcode = infocode
  6203. } else {
  6204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6205. utils.ErrorLog("解析失败:%v", err)
  6206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6207. return
  6208. }
  6209. }
  6210. }
  6211. if res.Infcode != 0 {
  6212. errlog := &models.HisOrderError{
  6213. UserOrgId: adminUser.CurrentOrgId,
  6214. Ctime: time.Now().Unix(),
  6215. Mtime: time.Now().Unix(),
  6216. Number: chrg_bchno,
  6217. ErrMsg: res.ErrMsg,
  6218. Status: 1,
  6219. PatientId: id,
  6220. RecordTime: recordDateTime,
  6221. Stage: 6,
  6222. }
  6223. service.CreateErrMsgLog(errlog)
  6224. c.ServeSuccessJSON(map[string]interface{}{
  6225. "failed_code": -10,
  6226. "msg": res.ErrMsg,
  6227. })
  6228. return
  6229. } else {
  6230. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6231. order.OrderStatus = 2
  6232. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6233. order.SetlId = res.Output.Setlinfo.SetlID
  6234. order.PsnNo = res.Output.Setlinfo.PsnNo
  6235. order.PsnName = res.Output.Setlinfo.PsnName
  6236. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6237. order.Certno = res.Output.Setlinfo.Certno
  6238. order.Gend = res.Output.Setlinfo.Gend
  6239. order.Naty = res.Output.Setlinfo.Naty
  6240. order.Age = res.Output.Setlinfo.Age
  6241. order.Insutype = res.Output.Setlinfo.Insutype
  6242. order.PsnType = res.Output.Setlinfo.PsnType
  6243. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6244. order.SetlTime = res.Output.Setlinfo.SetlTime
  6245. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6246. //order.MedType = res.Output.Setlinfo.MedType
  6247. if reg_type == 1112 {
  6248. order.MedType = "1112"
  6249. }
  6250. if reg_type == 1111 {
  6251. order.MedType = "1111"
  6252. }
  6253. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6254. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6255. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6256. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6257. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6258. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6259. order.HifpPay = res.Output.Setlinfo.HifpPay
  6260. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6261. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6262. order.HifesPay = res.Output.Setlinfo.HifesPay
  6263. order.HifobPay = res.Output.Setlinfo.HifobPay
  6264. order.MafPay = res.Output.Setlinfo.MafPay
  6265. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  6266. order.OthPay = res.Output.Setlinfo.OthPay
  6267. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6268. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6269. order.AcctPay = res.Output.Setlinfo.AcctPay
  6270. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6271. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6272. order.Balc = res.Output.Setlinfo.Balc
  6273. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6274. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6275. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6276. order.ClrWay = res.Output.Setlinfo.ClrWay
  6277. order.Creator = order.Creator
  6278. order.Modify = roles.AdminUserId
  6279. order.RequestLog = src_resquest
  6280. order.Diagnosis = diagnosis_id
  6281. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6282. detailStr := string(setlDetail)
  6283. order.SetlDetail = detailStr
  6284. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6285. err = service.UpDateOrder(order)
  6286. if err == nil {
  6287. //判断是否使用了押金
  6288. if dec_way == "true" {
  6289. tmpstring := strconv.FormatInt(order.ID, 10)
  6290. //扣押金
  6291. order.Decimal = decimal
  6292. service.UpDateOrder(order)
  6293. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  6294. if errmsg != nil {
  6295. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  6296. return
  6297. }
  6298. }
  6299. c.ServeSuccessJSON(map[string]interface{}{
  6300. "msg": "结算成功",
  6301. })
  6302. } else {
  6303. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6304. return
  6305. }
  6306. }
  6307. }
  6308. }
  6309. }
  6310. //func (c *HisApiController) GetPreUploadInfo() {
  6311. // id, _ := c.GetInt64("id")
  6312. // record_time := c.GetString("record_time")
  6313. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6314. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6315. //
  6316. // timeLayout := "2006-01-02"
  6317. // loc, _ := time.LoadLocation("Local")
  6318. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6319. // if err != nil {
  6320. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6321. // return
  6322. // }
  6323. // recordDateTime := theTime.Unix()
  6324. // adminUser := c.GetAdminUserInfo()
  6325. //
  6326. // var prescriptions []*models.HisPrescription
  6327. //
  6328. // var start_time int64
  6329. // var end_time int64
  6330. //
  6331. // data := make(map[string]interface{})
  6332. // if settle_accounts_type == 1 { //日结
  6333. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6334. // data["pre"] = prescriptions
  6335. //
  6336. // } else { //月结
  6337. // start_time_str := c.GetString("start_time")
  6338. // end_time_str := c.GetString("end_time")
  6339. // timeLayout := "2006-01-02"
  6340. // loc, _ := time.LoadLocation("Local")
  6341. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6342. // if err != nil {
  6343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6344. // return
  6345. // }
  6346. // recordStartTime := theStartTime.Unix()
  6347. // start_time = recordStartTime
  6348. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6349. // if err != nil {
  6350. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6351. // return
  6352. // }
  6353. // recordEndTime := theEndTime.Unix()
  6354. // end_time = recordEndTime
  6355. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6356. // data["pre"] = prescriptions
  6357. //
  6358. // }
  6359. //
  6360. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6361. //
  6362. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6363. // timestamp := time.Now().Unix()
  6364. // tempTime := time.Unix(timestamp, 0)
  6365. // timeFormat := tempTime.Format("20060102150405")
  6366. // chrgBchno := rand.Intn(100000) + 10000
  6367. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6368. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6369. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6370. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6371. // strconv.FormatInt(his.PatientId, 10)
  6372. // client := &http.Client{}
  6373. // data["psn_no"] = his.PsnNo
  6374. // data["mdtrt_id"] = his.Number
  6375. // data["chrg_bchno"] = chrg_bchno
  6376. // data["org_name"] = miConfig.OrgName
  6377. // data["doctor"] = roles.UserName
  6378. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6379. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6380. // data["fixmedins_code"] = miConfig.Code
  6381. // data["dept_code"] = department.Number
  6382. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6383. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6384. // data["secret_key"] = miConfig.SecretKey
  6385. // var ids []int64
  6386. //
  6387. // for _, item := range prescriptions {
  6388. // ids = append(ids, item.ID)
  6389. // }
  6390. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6391. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6392. // bytesData, _ := json.Marshal(data)
  6393. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6394. // resp, _ := client.Do(req)
  6395. // defer resp.Body.Close()
  6396. // body, ioErr := ioutil.ReadAll(resp.Body)
  6397. // if ioErr != nil {
  6398. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6399. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6400. // return
  6401. // }
  6402. // var respJSON map[string]interface{}
  6403. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6404. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6405. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6406. // return
  6407. // }
  6408. //
  6409. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6410. // userJSONBytes, _ := json.Marshal(respJSON)
  6411. // var res ResultFour
  6412. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6413. // utils.ErrorLog("解析失败:%v", err)
  6414. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6415. // return
  6416. // }
  6417. //
  6418. // if res.Infcode == 0 {
  6419. // order := &models.HisOrder{
  6420. // UserOrgId: adminUser.CurrentOrgId,
  6421. // HisPatientId: his.ID,
  6422. // PatientId: his.PatientId,
  6423. // SettleAccountsDate: recordDateTime,
  6424. // Ctime: time.Now().Unix(),
  6425. // Mtime: time.Now().Unix(),
  6426. // Status: 1,
  6427. // Number: chrg_bchno,
  6428. // Infcode: res.Infcode,
  6429. // WarnMsg: res.WarnMsg,
  6430. // Cainfo: res.Cainfo,
  6431. // ErrMsg: res.ErrMsg,
  6432. // RespondTime: res.RefmsgTime,
  6433. // InfRefmsgid: res.InfRefmsgid,
  6434. // OrderStatus: 1,
  6435. // IsMedicineInsurance: 1,
  6436. // SettleType: settle_accounts_type,
  6437. // SettleStartTime: start_time,
  6438. // SettleEndTime: end_time,
  6439. // Creator: roles.ID,
  6440. // Modify: roles.ID,
  6441. // PType: 2,
  6442. // }
  6443. // err = service.CreateOrder(order)
  6444. // if err != nil {
  6445. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6446. // return
  6447. // }
  6448. //
  6449. // for _, item := range res.Output.Result {
  6450. // temp := strings.Split(item.FeedetlSn, "-")
  6451. // var advice_id int64 = 0
  6452. // var project_id int64 = 0
  6453. // var types int64 = 0
  6454. //
  6455. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6456. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6457. //
  6458. // if temp[1] == "1" {
  6459. // advice_id = id
  6460. // project_id = 0
  6461. // } else if temp[1] == "2" {
  6462. // advice_id = 0
  6463. // project_id = id
  6464. // }
  6465. //
  6466. // info := &models.HisOrderInfo{
  6467. // OrderNumber: order.Number,
  6468. // FeedetlSn: item.FeedetlSn,
  6469. // UploadDate: time.Now().Unix(),
  6470. // AdviceId: advice_id,
  6471. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6472. // Cnt: item.Cnt,
  6473. // Pric: float64(item.Pric),
  6474. // PatientId: his.PatientId,
  6475. // PricUplmtAmt: item.PricUplmtAmt,
  6476. // SelfpayProp: item.SelfpayProp,
  6477. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6478. // OverlmtAmt: item.OverlmtAmt,
  6479. // PreselfpayAmt: item.PreselfpayAmt,
  6480. // BasMednFlag: item.BasMednFlag,
  6481. // MedChrgitmType: item.MedChrgitmType,
  6482. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6483. // Status: 1,
  6484. // Memo: item.Memo,
  6485. // Mtime: time.Now().Unix(),
  6486. // InscpScpAmt: item.InscpScpAmt,
  6487. // DrtReimFlag: item.DrtReimFlag,
  6488. // Ctime: time.Now().Unix(),
  6489. // ListSpItemFlag: item.ListSpItemFlag,
  6490. // ChldMedcFlag: item.ChldMedcFlag,
  6491. // LmtUsedFlag: item.LmtUsedFlag,
  6492. // ChrgitmLv: item.ChrgitmLv,
  6493. // UserOrgId: adminUser.CurrentOrgId,
  6494. // HisPatientId: his.ID,
  6495. // OrderId: order.ID,
  6496. // ProjectId: project_id,
  6497. // Type: types,
  6498. // }
  6499. // service.CreateOrderInfo(info)
  6500. //
  6501. // }
  6502. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6503. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6504. //
  6505. // var total float64
  6506. // for _, item := range prescriptions {
  6507. // if item.Type == 1 { //药品
  6508. // for _, subItem := range item.HisDoctorAdviceInfo {
  6509. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6510. // }
  6511. // }
  6512. // if item.Type == 2 { //项目
  6513. // for _, subItem := range item.HisPrescriptionProject {
  6514. // total = total + (subItem.Price * float64(subItem.Count))
  6515. // }
  6516. // }
  6517. // }
  6518. //
  6519. // for _, item := range prescriptions {
  6520. // for _, subItem := range item.HisAdditionalCharge {
  6521. // total = total + (subItem.Price * float64(subItem.Count))
  6522. // }
  6523. // }
  6524. //
  6525. // allTotal := fmt.Sprintf("%.2f", total)
  6526. // if res.Infcode == 0 {
  6527. // var rf []*ResultFive
  6528. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6529. // psn_no := his.PsnNo
  6530. // mdtrt_id := his.Number
  6531. // chrg_bchno := chrg_bchno
  6532. // cert_no := his.Certno
  6533. // insutype := rf[0].Insutype
  6534. //
  6535. // if his.IdCardType == 1 {
  6536. // cert_no = his.MedicalInsuranceNumber
  6537. //
  6538. // } else {
  6539. //
  6540. // cert_no = his.Certno
  6541. //
  6542. // }
  6543. //
  6544. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6545. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6546. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6547. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6548. // resp, requestErr := http.Get(api)
  6549. // if requestErr != nil {
  6550. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6551. // return
  6552. // }
  6553. // defer resp.Body.Close()
  6554. // body, ioErr := ioutil.ReadAll(resp.Body)
  6555. // if ioErr != nil {
  6556. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6558. // return
  6559. // }
  6560. // var respJSON map[string]interface{}
  6561. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6562. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6564. // return
  6565. // }
  6566. // fmt.Println(respJSON)
  6567. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6568. // userJSONBytes, _ := json.Marshal(respJSON)
  6569. // var res ResultSeven
  6570. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6571. // utils.ErrorLog("解析失败:%v", err)
  6572. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6573. // return
  6574. // }
  6575. // if res.Infcode != 0 {
  6576. // errlog := &models.HisOrderError{
  6577. // UserOrgId: adminUser.CurrentOrgId,
  6578. // Ctime: time.Now().Unix(),
  6579. // Mtime: time.Now().Unix(),
  6580. // Number: chrg_bchno,
  6581. // ErrMsg: res.ErrMsg,
  6582. // Status: 1,
  6583. // PatientId: id,
  6584. // RecordTime: recordDateTime,
  6585. // Stage: 7,
  6586. // }
  6587. // service.CreateErrMsgLog(errlog)
  6588. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6589. // return
  6590. // } else {
  6591. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6592. // order.OrderStatus = 1
  6593. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6594. // order.SetlId = res.Output.Setlinfo.SetlID
  6595. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6596. // order.PsnName = res.Output.Setlinfo.PsnName
  6597. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6598. // order.Certno = res.Output.Setlinfo.Certno
  6599. // order.Gend = res.Output.Setlinfo.Gend
  6600. // order.Naty = res.Output.Setlinfo.Naty
  6601. // order.Age = res.Output.Setlinfo.Age
  6602. // order.Insutype = res.Output.Setlinfo.Insutype
  6603. // order.PsnType = res.Output.Setlinfo.PsnType
  6604. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6605. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6606. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6607. // order.MedType = res.Output.Setlinfo.MedType
  6608. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6609. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6610. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6611. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6612. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6613. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6614. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6615. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6616. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6617. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6618. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6619. // order.MafPay = res.Output.Setlinfo.MafPay
  6620. // order.OthPay = res.Output.Setlinfo.OthPay
  6621. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6622. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6623. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6624. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6625. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6626. // order.Balc = res.Output.Setlinfo.Balc
  6627. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6628. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6629. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6630. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6631. // order.Creator = order.Creator
  6632. // order.Modify = roles.ID
  6633. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6634. // detailStr := string(setlDetail)
  6635. // order.SetlDetail = detailStr
  6636. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6637. // err = service.UpDateOrder(order)
  6638. // if err == nil {
  6639. // c.ServeSuccessJSON(map[string]interface{}{
  6640. // "msg": "预结算成功",
  6641. // })
  6642. // } else {
  6643. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6644. // return
  6645. // }
  6646. // }
  6647. // } else {
  6648. // adminUser := c.GetAdminUserInfo()
  6649. // errlog := &models.HisOrderError{
  6650. // UserOrgId: adminUser.CurrentOrgId,
  6651. // Ctime: time.Now().Unix(),
  6652. // Mtime: time.Now().Unix(),
  6653. // ErrMsg: res.ErrMsg,
  6654. // Status: 1,
  6655. // PatientId: id,
  6656. // RecordTime: recordDateTime,
  6657. // Stage: 4,
  6658. // }
  6659. // service.CreateErrMsgLog(errlog)
  6660. //
  6661. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6662. // return
  6663. // }
  6664. // } else {
  6665. // adminUser := c.GetAdminUserInfo()
  6666. // errlog := &models.HisOrderError{
  6667. // UserOrgId: adminUser.CurrentOrgId,
  6668. // Ctime: time.Now().Unix(),
  6669. // Mtime: time.Now().Unix(),
  6670. // ErrMsg: res.ErrMsg,
  6671. // Status: 1,
  6672. // PatientId: id,
  6673. // RecordTime: recordDateTime,
  6674. // Stage: 4,
  6675. // }
  6676. // service.CreateErrMsgLog(errlog)
  6677. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6678. // return
  6679. // }
  6680. //
  6681. // } else {
  6682. // var total float64
  6683. // for _, item := range prescriptions {
  6684. // if item.Type == 1 { //药品
  6685. // for _, subItem := range item.HisDoctorAdviceInfo {
  6686. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6687. // }
  6688. // }
  6689. // if item.Type == 2 { //项目
  6690. // for _, subItem := range item.HisPrescriptionProject {
  6691. // total = total + (subItem.Price * float64(subItem.Count))
  6692. // }
  6693. // }
  6694. //
  6695. // for _, subItem := range item.HisAdditionalCharge {
  6696. // total = total + (subItem.Price * float64(subItem.Count))
  6697. // }
  6698. // }
  6699. //
  6700. // allTotal := fmt.Sprintf("%.2f", total)
  6701. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6702. // order := &models.HisOrder{
  6703. // UserOrgId: adminUser.CurrentOrgId,
  6704. // HisPatientId: his.ID,
  6705. // PatientId: id,
  6706. // SettleAccountsDate: recordDateTime,
  6707. // Ctime: time.Now().Unix(),
  6708. // Mtime: time.Now().Unix(),
  6709. // Status: 1,
  6710. // OrderStatus: 2,
  6711. // Number: chrg_bchno,
  6712. // MedfeeSumamt: totals,
  6713. // }
  6714. // err = service.CreateOrder(order)
  6715. // if err != nil {
  6716. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6717. // return
  6718. // }
  6719. //
  6720. // var customs []*Custom
  6721. // for _, item := range prescriptions {
  6722. //
  6723. // if item.Type == 1 { //药品
  6724. // for _, subItem := range item.HisDoctorAdviceInfo {
  6725. // cus := &Custom{
  6726. // AdviceId: subItem.ID,
  6727. // ProjectId: 0,
  6728. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6729. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6730. // FeedetlSn: subItem.FeedetlSn,
  6731. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6732. // MedListCodg: subItem.MedListCodg,
  6733. // Type: 1,
  6734. // }
  6735. // customs = append(customs, cus)
  6736. // }
  6737. // }
  6738. //
  6739. // if item.Type == 2 { //项目
  6740. // for _, subItem := range item.HisPrescriptionProject {
  6741. //
  6742. // cus := &Custom{
  6743. // AdviceId: 0,
  6744. // ProjectId: subItem.ID,
  6745. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6746. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6747. // FeedetlSn: subItem.FeedetlSn,
  6748. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6749. // MedListCodg: subItem.MedListCodg,
  6750. // Type: 2,
  6751. // }
  6752. //
  6753. // customs = append(customs, cus)
  6754. // }
  6755. // }
  6756. //
  6757. // for _, item := range item.HisAdditionalCharge {
  6758. // cus := &Custom{
  6759. // ItemId: item.ID,
  6760. // AdviceId: 0,
  6761. // ProjectId: 0,
  6762. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6763. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6764. // FeedetlSn: item.FeedetlSn,
  6765. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6766. // MedListCodg: item.XtHisAddtionConfig.Code,
  6767. // Type: 3,
  6768. // }
  6769. //
  6770. // customs = append(customs, cus)
  6771. // }
  6772. //
  6773. // }
  6774. //
  6775. // for _, item := range customs {
  6776. // var advice_id int64 = 0
  6777. // var project_id int64 = 0
  6778. // var item_id int64 = 0
  6779. //
  6780. // var types int64 = 0
  6781. //
  6782. // if item.Type == 1 {
  6783. // advice_id = item.AdviceId
  6784. // project_id = 0
  6785. // item_id = 0
  6786. // } else if item.Type == 2 {
  6787. // advice_id = 0
  6788. // item_id = 0
  6789. //
  6790. // project_id = item.ProjectId
  6791. // } else if item.Type == 3 {
  6792. // advice_id = 0
  6793. // item_id = item.ItemId
  6794. // project_id = 0
  6795. // }
  6796. //
  6797. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6798. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6799. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6800. //
  6801. // info := &models.HisOrderInfo{
  6802. // OrderNumber: order.Number,
  6803. // UploadDate: time.Now().Unix(),
  6804. // AdviceId: advice_id,
  6805. // DetItemFeeSumamt: detItemFeeSumamt,
  6806. // Cnt: cut,
  6807. // Pric: pric,
  6808. // PatientId: id,
  6809. // Status: 1,
  6810. // Mtime: time.Now().Unix(),
  6811. // Ctime: time.Now().Unix(),
  6812. // UserOrgId: adminUser.CurrentOrgId,
  6813. // HisPatientId: his.ID,
  6814. // OrderId: order.ID,
  6815. // ProjectId: project_id,
  6816. // Type: types,
  6817. // ItemId: item_id,
  6818. // }
  6819. // service.CreateOrderInfo(info)
  6820. // }
  6821. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6822. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6823. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6824. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6825. // if err == nil {
  6826. // c.ServeSuccessJSON(map[string]interface{}{
  6827. // "msg": "结算成功",
  6828. // })
  6829. // } else {
  6830. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6831. // return
  6832. // }
  6833. // }
  6834. //}
  6835. //上传明细-预结算-
  6836. func (c *HisApiController) GetPreUploadInfo() {
  6837. id, _ := c.GetInt64("id")
  6838. record_time := c.GetString("record_time")
  6839. his_patient_id, _ := c.GetInt64("his_patient_id")
  6840. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6841. admin_user_id, _ := c.GetInt64("admin_user_id")
  6842. diagnosis_id := c.GetString("diagnosis")
  6843. sick_type, _ := c.GetInt64("sick_type")
  6844. reg_type, _ := c.GetInt64("p_type")
  6845. begin_time := c.GetString("begin_time")
  6846. id_str := c.GetString("ids")
  6847. ids_arr := strings.Split(id_str, ",")
  6848. timeLayout := "2006-01-02"
  6849. loc, _ := time.LoadLocation("Local")
  6850. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6851. if err != nil {
  6852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6853. return
  6854. }
  6855. recordDateTime := theTime.Unix()
  6856. adminUser := c.GetAdminUserInfo()
  6857. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6858. var config []*models.HisXtDiagnoseConfig
  6859. for _, item := range diagnosis_ids {
  6860. id, _ := strconv.ParseInt(item, 10, 64)
  6861. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6862. config = append(config, &diagnosisConfig)
  6863. }
  6864. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6865. sickConfig, _ := service.FindSickById(sick_type)
  6866. var prescriptions []*models.HisPrescription
  6867. var start_time int64
  6868. var end_time int64
  6869. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6870. fmt.Println(his_patient_id)
  6871. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6872. timestamp := time.Now().Unix()
  6873. tempTime := time.Unix(timestamp, 0)
  6874. timeFormat := tempTime.Format("20060102150405")
  6875. chrgBchno := rand.Intn(100000) + 10000
  6876. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6877. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6878. var patientPrescription models.HisPrescriptionInfo
  6879. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6880. if patientPrescription.ID == 0 {
  6881. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6882. }
  6883. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6884. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6885. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6886. strconv.FormatInt(his.PatientId, 10)
  6887. var res2 ResultSix
  6888. var resSix10265 ResultSix10265
  6889. var time_stamp string
  6890. if miConfig.MdtrtareaAdmvs == "421300" {
  6891. data := make(map[string]interface{})
  6892. client := &http.Client{}
  6893. data["psn_no"] = his.PsnNo
  6894. data["mdtrt_id"] = his.Number
  6895. data["department"] = department.Name
  6896. data["org_name"] = miConfig.OrgName
  6897. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6898. data["doctor_id"] = doctor_info.DoctorNumber
  6899. data["doctor_name"] = roles.UserName
  6900. data["fixmedins_code"] = miConfig.Code
  6901. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6902. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6903. data["secret_key"] = miConfig.SecretKey
  6904. data["sick_code"] = sickConfig.CountryCode
  6905. data["sick_name"] = sickConfig.ClassName
  6906. data["begin_time"] = begin_time
  6907. data["dept"] = strconv.FormatInt(department.ID, 10)
  6908. data["config"] = config
  6909. data["opter"] = roles.UserName
  6910. fmt.Println(data)
  6911. bytesData, _ := json.Marshal(data)
  6912. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6913. resp, _ := client.Do(req)
  6914. defer resp.Body.Close()
  6915. body, ioErr := ioutil.ReadAll(resp.Body)
  6916. if ioErr != nil {
  6917. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6918. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6919. return
  6920. }
  6921. var respJSON map[string]interface{}
  6922. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6923. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6925. return
  6926. }
  6927. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6928. userJSONBytes, _ := json.Marshal(respJSON)
  6929. fmt.Println("log")
  6930. fmt.Println(string(userJSONBytes))
  6931. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6932. utils.ErrorLog("解析失败:%v", err)
  6933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6934. return
  6935. }
  6936. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6937. data := make(map[string]interface{})
  6938. client := &http.Client{}
  6939. data["psn_no"] = his.PsnNo
  6940. data["mdtrt_id"] = his.Number
  6941. data["doctor"] = roles.UserName
  6942. data["department"] = department.Name
  6943. data["org_name"] = miConfig.OrgName
  6944. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6945. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6946. data["fixmedins_code"] = miConfig.Code
  6947. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6948. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6949. data["secret_key"] = miConfig.SecretKey
  6950. data["sick_code"] = sickConfig.CountryCode
  6951. data["sick_name"] = sickConfig.ClassName
  6952. data["begin_time"] = begin_time
  6953. data["dept"] = strconv.FormatInt(department.ID, 10)
  6954. data["config"] = config
  6955. data["url"] = miConfig.Url
  6956. data["ak"] = miConfig.AccessKey
  6957. data["cainfo"] = miConfig.Cainfo
  6958. bytesData, _ := json.Marshal(data)
  6959. var req *http.Request
  6960. if miConfig.MdtrtareaAdmvs == "320921" {
  6961. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6962. //api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6963. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6964. } else {
  6965. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6966. }
  6967. resp, _ := client.Do(req)
  6968. defer resp.Body.Close()
  6969. body, ioErr := ioutil.ReadAll(resp.Body)
  6970. if ioErr != nil {
  6971. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6973. return
  6974. }
  6975. var respJSON map[string]interface{}
  6976. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6977. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6978. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6979. return
  6980. }
  6981. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6982. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6983. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6984. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6985. userJSONBytes, _ := json.Marshal(respJSON)
  6986. fmt.Println("log")
  6987. fmt.Println(string(userJSONBytes))
  6988. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6989. utils.ErrorLog("解析失败:%v", err)
  6990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6991. return
  6992. }
  6993. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6994. res2.Output = resSix10265.Output
  6995. res2.ErrMsg = resSix10265.ErrMsg
  6996. res2.Cainfo = resSix10265.Cainfo
  6997. res2.WarnMsg = resSix10265.WarnMsg
  6998. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6999. res2.Infcode = infocode
  7000. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7001. result, requestLog, _ := service.FJyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.DoctorNumber, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.ContentCode, sickConfig.ClassName, roles.UserName, config, begin_time, doctor_info.UserName, roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7002. saveLog(result, requestLog, "2203", "上传就诊信息")
  7003. var respJSON2 map[string]interface{}
  7004. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7005. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7006. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7007. return
  7008. }
  7009. userJSONBytes2, _ := json.Marshal(respJSON2)
  7010. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7011. utils.ErrorLog("解析失败:%v", err)
  7012. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7013. return
  7014. }
  7015. } else {
  7016. var result string
  7017. var requestLog string
  7018. if miConfig.MdtrtareaAdmvs == "440781" { //
  7019. 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)
  7020. } else {
  7021. if miConfig.Code == "H15049901371" {
  7022. //赤峰地区国家医保医疗类别
  7023. //职工透析:医疗类别选特殊情况门诊990502
  7024. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7025. var med_type string
  7026. if his.Insutype == "390" {
  7027. if reg_type == 14 {
  7028. med_type = "9933"
  7029. } else if reg_type == 11 {
  7030. med_type = "11"
  7031. }
  7032. } else if his.Insutype == "310" {
  7033. if reg_type == 14 {
  7034. med_type = "990502"
  7035. } else if reg_type == 11 {
  7036. med_type = "11"
  7037. }
  7038. }
  7039. 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)
  7040. } else {
  7041. 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)
  7042. }
  7043. saveLog(result, requestLog, "2203", "上传就诊信息")
  7044. var respJSON2 map[string]interface{}
  7045. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  7046. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7048. return
  7049. }
  7050. userJSONBytes2, _ := json.Marshal(respJSON2)
  7051. if miConfig.Code == "H15049901371" {
  7052. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  7053. utils.ErrorLog("解析失败:%v", err)
  7054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7055. return
  7056. }
  7057. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7058. res2.Output = resSix10265.Output
  7059. res2.ErrMsg = resSix10265.ErrMsg
  7060. res2.Cainfo = resSix10265.Cainfo
  7061. res2.WarnMsg = resSix10265.WarnMsg
  7062. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7063. res2.Infcode = infocode
  7064. } else {
  7065. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  7066. utils.ErrorLog("解析失败:%v", err)
  7067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7068. return
  7069. }
  7070. }
  7071. }
  7072. }
  7073. if res2.Infcode != 0 {
  7074. adminUser := c.GetAdminUserInfo()
  7075. errlog := &models.HisOrderError{
  7076. UserOrgId: adminUser.CurrentOrgId,
  7077. Ctime: time.Now().Unix(),
  7078. Mtime: time.Now().Unix(),
  7079. ErrMsg: res2.ErrMsg,
  7080. Status: 1,
  7081. PatientId: id,
  7082. RecordTime: recordDateTime,
  7083. Stage: 3,
  7084. }
  7085. service.CreateErrMsgLog(errlog)
  7086. c.ServeSuccessJSON(map[string]interface{}{
  7087. "failed_code": -10,
  7088. "msg": res2.ErrMsg,
  7089. })
  7090. return
  7091. } else {
  7092. his.Diagnosis = diagnosis_id
  7093. his.SickType = sickConfig.ID
  7094. his.PType = fmt.Sprintf("%d", reg_type)
  7095. service.UpdateHisPatientThree(&his)
  7096. data := make(map[string]interface{})
  7097. if settle_accounts_type == 1 { //日结
  7098. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  7099. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  7100. } else {
  7101. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  7102. }
  7103. data["pre"] = prescriptions
  7104. } else { //月结
  7105. start_time_str := c.GetString("start_time")
  7106. end_time_str := c.GetString("end_time")
  7107. timeLayout := "2006-01-02"
  7108. loc, _ := time.LoadLocation("Local")
  7109. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7110. if err != nil {
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7112. return
  7113. }
  7114. recordStartTime := theStartTime.Unix()
  7115. start_time = recordStartTime
  7116. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7117. if err != nil {
  7118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7119. return
  7120. }
  7121. recordEndTime := theEndTime.Unix()
  7122. end_time = recordEndTime
  7123. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  7124. data["pre"] = prescriptions
  7125. }
  7126. client := &http.Client{}
  7127. data["psn_no"] = his.PsnNo
  7128. data["mdtrt_id"] = his.Number
  7129. data["chrg_bchno"] = chrg_bchno
  7130. data["org_name"] = miConfig.OrgName
  7131. data["doctor"] = roles.UserName
  7132. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  7133. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  7134. data["fixmedins_code"] = miConfig.Code
  7135. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  7136. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  7137. data["dept_code"] = "15"
  7138. } else {
  7139. data["dept_code"] = department.Number
  7140. }
  7141. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  7142. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  7143. data["secret_key"] = miConfig.SecretKey
  7144. data["url"] = miConfig.Url
  7145. data["ak"] = miConfig.AccessKey
  7146. data["new_doctor_name"] = patientPrescription.Doctor
  7147. data["diag_code"] = sickConfig.CountryCode
  7148. data["time_stamp"] = time_stamp
  7149. data["cainfo"] = miConfig.Cainfo
  7150. var ids []int64
  7151. for _, item := range prescriptions {
  7152. ids = append(ids, item.ID)
  7153. }
  7154. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7155. if config.IsOpen == 1 { //对接了医保,走医保流程
  7156. var res ResultFour
  7157. var resFour10265 ResultFour10265
  7158. if miConfig.MdtrtareaAdmvs == "421300" {
  7159. bytesData, _ := json.Marshal(data)
  7160. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  7161. resp, _ := client.Do(req)
  7162. defer resp.Body.Close()
  7163. body, ioErr := ioutil.ReadAll(resp.Body)
  7164. if ioErr != nil {
  7165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7167. return
  7168. }
  7169. var respJSON map[string]interface{}
  7170. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7173. return
  7174. }
  7175. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7176. userJSONBytes, _ := json.Marshal(respJSON)
  7177. fmt.Println("log")
  7178. fmt.Println(string(userJSONBytes))
  7179. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7180. utils.ErrorLog("解析失败:%v", err)
  7181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7182. return
  7183. }
  7184. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7185. bytesData, _ := json.Marshal(data)
  7186. var req *http.Request
  7187. if miConfig.MdtrtareaAdmvs == "320921" {
  7188. req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7189. } else {
  7190. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7191. }
  7192. resp, _ := client.Do(req)
  7193. defer resp.Body.Close()
  7194. body, ioErr := ioutil.ReadAll(resp.Body)
  7195. if ioErr != nil {
  7196. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7198. return
  7199. }
  7200. var respJSON map[string]interface{}
  7201. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  7202. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7203. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7204. return
  7205. }
  7206. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7207. userJSONBytes, _ := json.Marshal(respJSON)
  7208. fmt.Println("log")
  7209. fmt.Println(string(userJSONBytes))
  7210. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7211. utils.ErrorLog("解析失败:%v", err)
  7212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7213. return
  7214. }
  7215. res.InfRefmsgid = resFour10265.InfRefmsgid
  7216. res.Output = resFour10265.Output
  7217. res.ErrMsg = resFour10265.ErrMsg
  7218. res.Cainfo = resFour10265.Cainfo
  7219. res.WarnMsg = resFour10265.WarnMsg
  7220. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7221. res.Infcode = infocode
  7222. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7223. result, request_log, _ := service.FJyb2204(his.PsnNo, his.Number, prescriptions, chrg_bchno, miConfig.OrgName, roles.UserName, strconv.FormatInt(patientPrescription.Departments, 10), miConfig.Code, department.Number, strconv.FormatInt(roles.AdminUserId, 10), his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(his.BalanceAccountsType, 10), roles.UserName, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7224. var dat map[string]interface{}
  7225. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7226. fmt.Println(dat)
  7227. } else {
  7228. fmt.Println(err)
  7229. }
  7230. saveLog(result, request_log, "2204", "上传费用明细")
  7231. userJSONBytes, _ := json.Marshal(dat)
  7232. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7233. utils.ErrorLog("解析失败:%v", err)
  7234. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7235. return
  7236. }
  7237. } else {
  7238. if miConfig.Code == "H15049901371" {
  7239. 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)
  7240. var dat map[string]interface{}
  7241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7242. fmt.Println(dat)
  7243. } else {
  7244. fmt.Println(err)
  7245. }
  7246. saveLog(result, request_log, "2204", "上传费用明细")
  7247. userJSONBytes, _ := json.Marshal(dat)
  7248. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  7249. utils.ErrorLog("解析失败:%v", err)
  7250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7251. return
  7252. }
  7253. res.InfRefmsgid = resFour10265.InfRefmsgid
  7254. res.Output = resFour10265.Output
  7255. res.ErrMsg = resFour10265.ErrMsg
  7256. res.Cainfo = resFour10265.Cainfo
  7257. res.WarnMsg = resFour10265.WarnMsg
  7258. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  7259. res.Infcode = infocode
  7260. } else {
  7261. 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)
  7262. var dat map[string]interface{}
  7263. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7264. fmt.Println(dat)
  7265. } else {
  7266. fmt.Println(err)
  7267. }
  7268. saveLog(result, request_log, "2204", "上传费用明细")
  7269. userJSONBytes, _ := json.Marshal(dat)
  7270. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7271. utils.ErrorLog("解析失败:%v", err)
  7272. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7273. return
  7274. }
  7275. }
  7276. }
  7277. if res.Infcode == 0 {
  7278. order := &models.HisOrder{
  7279. UserOrgId: adminUser.CurrentOrgId,
  7280. HisPatientId: his.ID,
  7281. PatientId: his.PatientId,
  7282. SettleAccountsDate: recordDateTime,
  7283. Ctime: time.Now().Unix(),
  7284. Mtime: time.Now().Unix(),
  7285. MdtrtId: his.Number,
  7286. PsnNo: his.PsnNo,
  7287. MedType: strconv.FormatInt(reg_type, 10),
  7288. Status: 1,
  7289. Number: chrg_bchno,
  7290. Infcode: res.Infcode,
  7291. WarnMsg: res.WarnMsg,
  7292. Cainfo: res.Cainfo,
  7293. ErrMsg: res.ErrMsg,
  7294. RespondTime: res.RefmsgTime,
  7295. InfRefmsgid: res.InfRefmsgid,
  7296. OrderStatus: 1,
  7297. IsMedicineInsurance: 1,
  7298. SettleType: settle_accounts_type,
  7299. SettleStartTime: start_time,
  7300. SettleEndTime: end_time,
  7301. Creator: roles.AdminUserId,
  7302. Modify: roles.AdminUserId,
  7303. PType: 2,
  7304. Diagnosis: diagnosis_id,
  7305. }
  7306. err = service.CreateOrder(order)
  7307. if err != nil {
  7308. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  7309. return
  7310. }
  7311. for _, item := range res.Output.Result {
  7312. temp := strings.Split(item.FeedetlSn, "-")
  7313. var advice_id int64 = 0
  7314. var project_id int64 = 0
  7315. var types int64 = 0
  7316. id, _ := strconv.ParseInt(temp[2], 10, 64)
  7317. types, _ = strconv.ParseInt(temp[1], 10, 64)
  7318. if temp[1] == "1" {
  7319. advice_id = id
  7320. project_id = 0
  7321. } else if temp[1] == "2" {
  7322. advice_id = 0
  7323. project_id = id
  7324. }
  7325. info := &models.HisOrderInfo{
  7326. OrderNumber: order.Number,
  7327. FeedetlSn: item.FeedetlSn,
  7328. UploadDate: time.Now().Unix(),
  7329. AdviceId: advice_id,
  7330. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7331. Cnt: item.Cnt,
  7332. Pric: float64(item.Pric),
  7333. PatientId: his.PatientId,
  7334. PricUplmtAmt: item.PricUplmtAmt,
  7335. SelfpayProp: item.SelfpayProp,
  7336. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7337. OverlmtAmt: item.OverlmtAmt,
  7338. PreselfpayAmt: item.PreselfpayAmt,
  7339. BasMednFlag: item.BasMednFlag,
  7340. MedChrgitmType: item.MedChrgitmType,
  7341. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7342. Status: 1,
  7343. Memo: item.Memo,
  7344. Mtime: time.Now().Unix(),
  7345. InscpScpAmt: item.InscpScpAmt,
  7346. DrtReimFlag: item.DrtReimFlag,
  7347. Ctime: time.Now().Unix(),
  7348. ListSpItemFlag: item.ListSpItemFlag,
  7349. ChldMedcFlag: item.ChldMedcFlag,
  7350. LmtUsedFlag: item.LmtUsedFlag,
  7351. ChrgitmLv: item.ChrgitmLv,
  7352. UserOrgId: adminUser.CurrentOrgId,
  7353. HisPatientId: his.ID,
  7354. OrderId: order.ID,
  7355. ProjectId: project_id,
  7356. Type: types,
  7357. }
  7358. service.CreateOrderInfo(info)
  7359. }
  7360. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7361. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7362. var total float64
  7363. for _, item := range prescriptions {
  7364. if item.Type == 1 { //药品
  7365. for _, subItem := range item.HisDoctorAdviceInfo {
  7366. total = total + (subItem.Price * subItem.PrescribingNumber)
  7367. }
  7368. }
  7369. if item.Type == 2 { //项目
  7370. for _, subItem := range item.HisPrescriptionProject {
  7371. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7372. total = total + (subItem.Price * cnt)
  7373. }
  7374. }
  7375. }
  7376. for _, item := range prescriptions {
  7377. for _, subItem := range item.HisAdditionalCharge {
  7378. total = total + (subItem.Price * float64(subItem.Count))
  7379. }
  7380. }
  7381. allTotal := fmt.Sprintf("%.4f", total)
  7382. if res.Infcode == 0 {
  7383. var rf []*ResultFive
  7384. json.Unmarshal([]byte(his.Iinfo), &rf)
  7385. chrg_bchno := chrg_bchno
  7386. cert_no := his.Certno
  7387. var insutypes []string
  7388. var insutype string
  7389. var is390 int = 0
  7390. var is310 int = 0
  7391. for _, item := range rf {
  7392. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7393. insutypes = append(insutypes, item.Insutype)
  7394. }
  7395. }
  7396. if len(insutypes) == 1 {
  7397. insutype = insutypes[0]
  7398. } else {
  7399. for _, i := range insutypes {
  7400. if i == "390" {
  7401. is390 = 1
  7402. }
  7403. if i == "310" {
  7404. is310 = 1
  7405. }
  7406. }
  7407. }
  7408. if is390 == 1 {
  7409. insutype = "390"
  7410. }
  7411. if is310 == 1 {
  7412. insutype = "310"
  7413. }
  7414. if len(insutypes) == 0 {
  7415. insutype = "310"
  7416. }
  7417. if len(insutypes) == 2 {
  7418. insutype = strconv.FormatInt(his.SocialType, 64)
  7419. }
  7420. //insutype = "390"
  7421. if his.IdCardType == 1 {
  7422. cert_no = his.MedicalInsuranceNumber
  7423. } else {
  7424. cert_no = his.Certno
  7425. }
  7426. var res ResultSeven
  7427. var resSeven10265 ResultSeven10265
  7428. if miConfig.MdtrtareaAdmvs == "421300" {
  7429. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7430. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7431. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7432. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7433. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7434. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7435. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7436. resp, requestErr := http.Get(api)
  7437. if requestErr != nil {
  7438. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7439. return
  7440. }
  7441. body, ioErr := ioutil.ReadAll(resp.Body)
  7442. if ioErr != nil {
  7443. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7444. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7445. return
  7446. }
  7447. var respJSON map[string]interface{}
  7448. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7449. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7451. return
  7452. }
  7453. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7454. result, _ := json.Marshal(respJSON)
  7455. fmt.Println("log")
  7456. fmt.Println(string(result))
  7457. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7458. utils.ErrorLog("解析失败:%v", err)
  7459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7460. return
  7461. }
  7462. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7463. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7464. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7465. bas := strings.Split(psn_info.CardInfo, "|")
  7466. if his.IdCardType == 1 {
  7467. cert_no = bas[2]
  7468. } else {
  7469. cert_no = bas[1]
  7470. }
  7471. //江苏地区国家医保医疗类别
  7472. //职工透析:医疗类别选特殊情况门诊9933
  7473. //居民血透门慢: 医疗类别选门诊慢病1402
  7474. //var med_type string
  7475. //if his.Insutype == "310" {
  7476. // if reg_type == 14 {
  7477. // med_type = "9933"
  7478. // } else if reg_type == 11 {
  7479. // med_type = "11"
  7480. //
  7481. // }
  7482. //} else if his.Insutype == "390" {
  7483. // if reg_type == 14 {
  7484. // med_type = "1402"
  7485. // } else if reg_type == 11 {
  7486. // med_type = "11"
  7487. // }
  7488. //}
  7489. var api string
  7490. if miConfig.MdtrtareaAdmvs == "320921" {
  7491. api = "http://192.168.2.110:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7492. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7493. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7494. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7495. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7496. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7497. "&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
  7498. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7499. } else {
  7500. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7501. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7502. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7503. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7504. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7505. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7506. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7507. "&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
  7508. }
  7509. resp, requestErr := http.Get(api)
  7510. if requestErr != nil {
  7511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7512. return
  7513. }
  7514. body, ioErr := ioutil.ReadAll(resp.Body)
  7515. if ioErr != nil {
  7516. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7518. return
  7519. }
  7520. var respJSON map[string]interface{}
  7521. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7522. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7524. return
  7525. }
  7526. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7527. result, _ := json.Marshal(respJSON)
  7528. fmt.Println("log")
  7529. fmt.Println(string(result))
  7530. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7531. utils.ErrorLog("解析失败:%v", err)
  7532. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7533. return
  7534. }
  7535. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7536. res.Output = resSeven10265.Output
  7537. res.ErrMsg = resSeven10265.ErrMsg
  7538. res.Cainfo = resSeven10265.Cainfo
  7539. res.WarnMsg = resSeven10265.WarnMsg
  7540. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7541. res.Infcode = infocode
  7542. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7543. result, request_log, _ := service.FJyb2206(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, allTotal, miConfig.OrgName, roles.UserName, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(reg_type, 10), his.IdCardType, 0, 0, 0, 0, his.IdType, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7544. var dat map[string]interface{}
  7545. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7546. fmt.Println(dat)
  7547. } else {
  7548. fmt.Println(err)
  7549. }
  7550. saveLog(result, request_log, "2206", "预结算")
  7551. userJSONBytes, _ := json.Marshal(dat)
  7552. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7553. utils.ErrorLog("解析失败:%v", err)
  7554. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7555. return
  7556. }
  7557. } else {
  7558. var result string
  7559. var request_log string
  7560. if miConfig.Code == "H15049901371" {
  7561. //赤峰地区国家医保医疗类别
  7562. //职工透析:医疗类别选特殊情况门诊990502
  7563. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7564. var med_type string
  7565. if his.Insutype == "390" {
  7566. if reg_type == 14 {
  7567. med_type = "9933"
  7568. } else if reg_type == 11 {
  7569. med_type = "11"
  7570. }
  7571. } else if his.Insutype == "310" {
  7572. if reg_type == 14 {
  7573. med_type = "990502"
  7574. } else if reg_type == 11 {
  7575. med_type = "11"
  7576. }
  7577. }
  7578. 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)
  7579. } else {
  7580. 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)
  7581. }
  7582. var dat map[string]interface{}
  7583. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7584. fmt.Println(dat)
  7585. } else {
  7586. fmt.Println(err)
  7587. }
  7588. saveLog(result, request_log, "2206", "预结算")
  7589. //userJSONBytes, _ := json.Marshal(dat)
  7590. //
  7591. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7592. // utils.ErrorLog("解析失败:%v", err)
  7593. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7594. // return
  7595. //}
  7596. userJSONBytes, _ := json.Marshal(dat)
  7597. if miConfig.Code == "H15049901371" {
  7598. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7599. utils.ErrorLog("解析失败:%v", err)
  7600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7601. return
  7602. }
  7603. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7604. res.Output = resSeven10265.Output
  7605. res.ErrMsg = resSeven10265.ErrMsg
  7606. res.Cainfo = resSeven10265.Cainfo
  7607. res.WarnMsg = resSeven10265.WarnMsg
  7608. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7609. res.Infcode = infocode
  7610. } else {
  7611. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7612. utils.ErrorLog("解析失败:%v", err)
  7613. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7614. return
  7615. }
  7616. }
  7617. }
  7618. if res.Infcode != 0 {
  7619. errlog := &models.HisOrderError{
  7620. UserOrgId: adminUser.CurrentOrgId,
  7621. Ctime: time.Now().Unix(),
  7622. Mtime: time.Now().Unix(),
  7623. Number: chrg_bchno,
  7624. ErrMsg: res.ErrMsg,
  7625. Status: 1,
  7626. PatientId: id,
  7627. RecordTime: recordDateTime,
  7628. Stage: 20,
  7629. }
  7630. service.CreateErrMsgLog(errlog)
  7631. c.ServeSuccessJSON(map[string]interface{}{
  7632. "failed_code": -10,
  7633. "msg": res.ErrMsg,
  7634. })
  7635. return
  7636. } else {
  7637. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7638. order.OrderStatus = 1
  7639. order.IsPre = 1
  7640. order.Status = 1
  7641. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7642. order.SetlId = res.Output.Setlinfo.SetlID
  7643. order.PsnNo = res.Output.Setlinfo.PsnNo
  7644. order.PsnName = res.Output.Setlinfo.PsnName
  7645. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7646. order.Certno = res.Output.Setlinfo.Certno
  7647. order.Gend = res.Output.Setlinfo.Gend
  7648. order.Naty = res.Output.Setlinfo.Naty
  7649. order.Age = res.Output.Setlinfo.Age
  7650. order.Insutype = res.Output.Setlinfo.Insutype
  7651. order.PsnType = res.Output.Setlinfo.PsnType
  7652. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7653. order.SetlTime = res.Output.Setlinfo.SetlTime
  7654. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7655. if res.Output.Setlinfo.MedType == "140101" {
  7656. order.MedType = "14"
  7657. } else {
  7658. order.MedType = res.Output.Setlinfo.MedType
  7659. }
  7660. if reg_type == 1112 {
  7661. order.MedType = "1112"
  7662. }
  7663. if reg_type == 1111 {
  7664. order.MedType = "1111"
  7665. }
  7666. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7667. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7668. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7669. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7670. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7671. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7672. order.HifpPay = res.Output.Setlinfo.HifpPay
  7673. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7674. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7675. order.HifesPay = res.Output.Setlinfo.HifesPay
  7676. order.HifobPay = res.Output.Setlinfo.HifobPay
  7677. order.MafPay = res.Output.Setlinfo.MafPay
  7678. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7679. order.OthPay = res.Output.Setlinfo.OthPay
  7680. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7681. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7682. order.AcctPay = res.Output.Setlinfo.AcctPay
  7683. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7684. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7685. order.Balc = res.Output.Setlinfo.Balc
  7686. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7687. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7688. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7689. order.ClrWay = res.Output.Setlinfo.ClrWay
  7690. order.Creator = order.Creator
  7691. order.Modify = roles.AdminUserId
  7692. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7693. detailStr := string(setlDetail)
  7694. order.SetlDetail = detailStr
  7695. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7696. err = service.UpDateOrder(order)
  7697. if err == nil {
  7698. c.ServeSuccessJSON(map[string]interface{}{
  7699. "msg": "预结算成功",
  7700. })
  7701. } else {
  7702. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7703. return
  7704. }
  7705. }
  7706. } else {
  7707. adminUser := c.GetAdminUserInfo()
  7708. errlog := &models.HisOrderError{
  7709. UserOrgId: adminUser.CurrentOrgId,
  7710. Ctime: time.Now().Unix(),
  7711. Mtime: time.Now().Unix(),
  7712. ErrMsg: res.ErrMsg,
  7713. Status: 1,
  7714. PatientId: id,
  7715. RecordTime: recordDateTime,
  7716. Stage: 4,
  7717. }
  7718. service.CreateErrMsgLog(errlog)
  7719. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7720. return
  7721. }
  7722. } else {
  7723. adminUser := c.GetAdminUserInfo()
  7724. errlog := &models.HisOrderError{
  7725. UserOrgId: adminUser.CurrentOrgId,
  7726. Ctime: time.Now().Unix(),
  7727. Mtime: time.Now().Unix(),
  7728. ErrMsg: res.ErrMsg,
  7729. Status: 1,
  7730. PatientId: id,
  7731. RecordTime: recordDateTime,
  7732. Stage: 4,
  7733. }
  7734. service.CreateErrMsgLog(errlog)
  7735. c.ServeSuccessJSON(map[string]interface{}{
  7736. "failed_code": -10,
  7737. "msg": res.ErrMsg,
  7738. })
  7739. return
  7740. }
  7741. }
  7742. }
  7743. }
  7744. //退款
  7745. func (c *HisApiController) Refund() {
  7746. order_id, _ := c.GetInt64("order_id")
  7747. admin_user_id, _ := c.GetInt64("admin_user_id")
  7748. adminUser := c.GetAdminUserInfo()
  7749. var order models.HisOrder
  7750. order, _ = service.GetHisOrderByID(order_id)
  7751. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7752. if order.ID == 0 {
  7753. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7754. return
  7755. }
  7756. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7757. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7758. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7759. if config.IsOpen == 1 { //对接了医保,走医保流程
  7760. var res ResultSixteen
  7761. var resSixteen10265 ResultSixteen10265
  7762. var src_resquest string
  7763. var result string
  7764. if miConfig.MdtrtareaAdmvs == "421300" {
  7765. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7766. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7767. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7768. resp3, requestErr3 := http.Get(api3)
  7769. if requestErr3 != nil {
  7770. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7771. return
  7772. }
  7773. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7774. if ioErr3 != nil {
  7775. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7776. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7777. return
  7778. }
  7779. var respJSON3 map[string]interface{}
  7780. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7781. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7782. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7783. return
  7784. }
  7785. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7786. userJSONBytes3, _ := json.Marshal(respJSON3)
  7787. fmt.Println("log")
  7788. fmt.Println(string(userJSONBytes3))
  7789. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7790. utils.ErrorLog("解析失败:%v", err)
  7791. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7792. return
  7793. }
  7794. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7795. var api3 string
  7796. if miConfig.MdtrtareaAdmvs == "320921" {
  7797. api3 = "http://192.168.2.110:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7798. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7799. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7800. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7801. } else {
  7802. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7803. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7804. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7805. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7806. }
  7807. resp3, requestErr3 := http.Get(api3)
  7808. if requestErr3 != nil {
  7809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7810. return
  7811. }
  7812. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7813. if ioErr3 != nil {
  7814. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7816. return
  7817. }
  7818. var respJSON3 map[string]interface{}
  7819. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7820. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7821. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7822. return
  7823. }
  7824. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7825. userJSONBytes3, _ := json.Marshal(respJSON3)
  7826. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7827. utils.ErrorLog("解析失败:%v", err)
  7828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7829. return
  7830. }
  7831. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7832. res.Output = resSixteen10265.Output
  7833. res.ErrMsg = resSixteen10265.ErrMsg
  7834. res.Cainfo = resSixteen10265.Cainfo
  7835. res.WarnMsg = resSixteen10265.WarnMsg
  7836. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7837. res.Infcode = infocode
  7838. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7839. result, src_resquest, _ = service.FJyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7840. var dat map[string]interface{}
  7841. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7842. fmt.Println(dat)
  7843. } else {
  7844. fmt.Println(err)
  7845. }
  7846. saveLog(result, src_resquest, "2208", "退费")
  7847. userJSONBytes, _ := json.Marshal(dat)
  7848. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7849. utils.ErrorLog("解析失败:%v", err)
  7850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7851. return
  7852. }
  7853. } else {
  7854. if miConfig.Code == "H15049901371" {
  7855. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7856. var dat map[string]interface{}
  7857. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7858. fmt.Println(dat)
  7859. } else {
  7860. fmt.Println(err)
  7861. }
  7862. saveLog(result, src_resquest, "2208", "退费")
  7863. userJSONBytes, _ := json.Marshal(dat)
  7864. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7865. utils.ErrorLog("解析失败:%v", err)
  7866. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7867. return
  7868. }
  7869. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7870. res.Output = resSixteen10265.Output
  7871. res.ErrMsg = resSixteen10265.ErrMsg
  7872. res.Cainfo = resSixteen10265.Cainfo
  7873. res.WarnMsg = resSixteen10265.WarnMsg
  7874. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7875. res.Infcode = infocode
  7876. } else {
  7877. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7878. var dat map[string]interface{}
  7879. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7880. fmt.Println(dat)
  7881. } else {
  7882. fmt.Println(err)
  7883. }
  7884. saveLog(result, src_resquest, "2208", "退费")
  7885. userJSONBytes, _ := json.Marshal(dat)
  7886. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7887. utils.ErrorLog("解析失败:%v", err)
  7888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7889. return
  7890. }
  7891. }
  7892. }
  7893. if res.Infcode == 0 {
  7894. var res2 ResultSix
  7895. var resSix10265 ResultSix10265
  7896. if miConfig.MdtrtareaAdmvs == "421300" {
  7897. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7898. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7899. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7900. resp3, requestErr3 := http.Get(api3)
  7901. if requestErr3 != nil {
  7902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7903. return
  7904. }
  7905. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7906. if ioErr3 != nil {
  7907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7909. return
  7910. }
  7911. var respJSON3 map[string]interface{}
  7912. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7915. return
  7916. }
  7917. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7918. userJSONBytes3, _ := json.Marshal(respJSON3)
  7919. fmt.Println("log")
  7920. fmt.Println(string(userJSONBytes3))
  7921. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7922. utils.ErrorLog("解析失败:%v", err)
  7923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7924. return
  7925. }
  7926. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7927. var api3 string
  7928. if miConfig.MdtrtareaAdmvs == "320921" {
  7929. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7930. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7931. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7932. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7933. } else {
  7934. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7935. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7936. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7937. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7938. }
  7939. resp3, requestErr3 := http.Get(api3)
  7940. if requestErr3 != nil {
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7945. if ioErr3 != nil {
  7946. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7947. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7948. return
  7949. }
  7950. var respJSON3 map[string]interface{}
  7951. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7952. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7954. return
  7955. }
  7956. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7957. userJSONBytes3, _ := json.Marshal(respJSON3)
  7958. fmt.Println("log")
  7959. fmt.Println(string(userJSONBytes3))
  7960. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7961. utils.ErrorLog("解析失败:%v", err)
  7962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7963. return
  7964. }
  7965. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7966. res2.Output = resSix10265.Output
  7967. res2.ErrMsg = resSix10265.ErrMsg
  7968. res2.Cainfo = resSix10265.Cainfo
  7969. res2.WarnMsg = resSix10265.WarnMsg
  7970. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7971. res2.Infcode = infocode
  7972. } else if miConfig.MdtrtareaAdmvs == "350500" {
  7973. result2, src_request, _ := service.FJyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  7974. var dat map[string]interface{}
  7975. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7976. fmt.Println(dat)
  7977. } else {
  7978. fmt.Println(err)
  7979. }
  7980. saveLog(result2, src_request, "2205", "撤销明细")
  7981. userJSONBytes, _ := json.Marshal(dat)
  7982. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7983. utils.ErrorLog("解析失败:%v", err)
  7984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7985. return
  7986. }
  7987. } else {
  7988. if miConfig.Code == "H15049901371" {
  7989. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7990. var dat map[string]interface{}
  7991. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7992. fmt.Println(dat)
  7993. } else {
  7994. fmt.Println(err)
  7995. }
  7996. saveLog(result2, src_request, "2205", "撤销明细")
  7997. userJSONBytes, _ := json.Marshal(dat)
  7998. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7999. utils.ErrorLog("解析失败:%v", err)
  8000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8001. return
  8002. }
  8003. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8004. res2.Output = resSix10265.Output
  8005. res2.ErrMsg = resSix10265.ErrMsg
  8006. res2.Cainfo = resSix10265.Cainfo
  8007. res2.WarnMsg = resSix10265.WarnMsg
  8008. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8009. res2.Infcode = infocode
  8010. } else {
  8011. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  8012. var dat map[string]interface{}
  8013. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8014. fmt.Println(dat)
  8015. } else {
  8016. fmt.Println(err)
  8017. }
  8018. saveLog(result2, src_request, "2205", "撤销明细")
  8019. userJSONBytes, _ := json.Marshal(dat)
  8020. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8021. utils.ErrorLog("解析失败:%v", err)
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8023. return
  8024. }
  8025. }
  8026. }
  8027. if res2.Infcode == 0 {
  8028. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  8029. if err == nil {
  8030. //当押金不为零时产生退费记录
  8031. if order.Decimal != 0 {
  8032. tmp := strconv.FormatInt(order.ID, 10)
  8033. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  8034. if err != nil {
  8035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8036. return
  8037. }
  8038. }
  8039. c.ServeSuccessJSON(map[string]interface{}{
  8040. "msg": "退费成功",
  8041. })
  8042. } else {
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. } else {
  8047. c.ServeSuccessJSON(map[string]interface{}{
  8048. "code": -10,
  8049. "msg": res2.ErrMsg,
  8050. })
  8051. }
  8052. } else {
  8053. c.ServeSuccessJSON(map[string]interface{}{
  8054. "code": -10,
  8055. "msg": res.ErrMsg,
  8056. })
  8057. }
  8058. }
  8059. }
  8060. func (c *HisApiController) RefundNumber() {
  8061. record_time := c.GetString("record_time")
  8062. //patient_id, _ := c.GetInt64("patient_id")
  8063. admin_user_id, _ := c.GetInt64("admin_user_id")
  8064. his_patient_id, _ := c.GetInt64("id")
  8065. timeLayout := "2006-01-02"
  8066. loc, _ := time.LoadLocation("Local")
  8067. adminUser := c.GetAdminUserInfo()
  8068. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8069. fmt.Println(err)
  8070. if err != nil {
  8071. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8072. return
  8073. }
  8074. recordDateTime := theTime.Unix()
  8075. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8076. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  8077. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8078. //order, _ := service.GetHisOrderByID(order_id)
  8079. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8080. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8081. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8082. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  8083. if count > 0 {
  8084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  8085. return
  8086. }
  8087. if config.IsOpen == 1 { //对接了医保,走医保流程
  8088. var res2 ResultSix
  8089. var resSix10265 ResultSix10265
  8090. if miConfig.MdtrtareaAdmvs == "421300" {
  8091. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  8092. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8093. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8094. resp3, requestErr3 := http.Get(api3)
  8095. if requestErr3 != nil {
  8096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8097. return
  8098. }
  8099. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8100. if ioErr3 != nil {
  8101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8103. return
  8104. }
  8105. var respJSON3 map[string]interface{}
  8106. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8109. return
  8110. }
  8111. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8112. userJSONBytes3, _ := json.Marshal(respJSON3)
  8113. fmt.Println("log")
  8114. fmt.Println(string(userJSONBytes3))
  8115. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8116. utils.ErrorLog("解析失败:%v", err)
  8117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8118. return
  8119. }
  8120. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8121. var api3 string
  8122. if miConfig.MdtrtareaAdmvs == "320921" {
  8123. api3 = "http://192.168.2.110:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8124. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8125. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8126. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8127. } else {
  8128. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8129. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  8130. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8131. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8132. }
  8133. resp3, requestErr3 := http.Get(api3)
  8134. if requestErr3 != nil {
  8135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8136. return
  8137. }
  8138. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8139. if ioErr3 != nil {
  8140. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. var respJSON3 map[string]interface{}
  8145. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8146. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8147. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8148. return
  8149. }
  8150. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8151. userJSONBytes3, _ := json.Marshal(respJSON3)
  8152. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8153. utils.ErrorLog("解析失败:%v", err)
  8154. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8155. return
  8156. }
  8157. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8158. res2.Output = resSix10265.Output
  8159. res2.ErrMsg = resSix10265.ErrMsg
  8160. res2.Cainfo = resSix10265.Cainfo
  8161. res2.WarnMsg = resSix10265.WarnMsg
  8162. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8163. res2.Infcode = infocode
  8164. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8165. result, request, _ := service.FJyb2202(his.PsnNo, his.Number, his.IptOtpNo, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8166. var dat map[string]interface{}
  8167. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8168. fmt.Println(dat)
  8169. } else {
  8170. fmt.Println(err)
  8171. }
  8172. saveLog(result, request, "2202", "退号")
  8173. userJSONBytes, _ := json.Marshal(dat)
  8174. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8175. utils.ErrorLog("解析失败:%v", err)
  8176. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8177. return
  8178. }
  8179. } else {
  8180. var api3 string
  8181. if miConfig.Code == "H15049901371" {
  8182. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8183. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8184. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8185. } else {
  8186. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8187. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8188. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8189. }
  8190. resp3, requestErr3 := http.Get(api3)
  8191. if requestErr3 != nil {
  8192. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8193. return
  8194. }
  8195. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8196. if ioErr3 != nil {
  8197. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. var respJSON3 map[string]interface{}
  8202. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8203. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8204. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8205. return
  8206. }
  8207. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8208. userJSONBytes3, _ := json.Marshal(respJSON3)
  8209. if miConfig.Code == "H15049901371" {
  8210. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8211. utils.ErrorLog("解析失败:%v", err)
  8212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8213. return
  8214. }
  8215. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8216. res2.Output = resSix10265.Output
  8217. res2.ErrMsg = resSix10265.ErrMsg
  8218. res2.Cainfo = resSix10265.Cainfo
  8219. res2.WarnMsg = resSix10265.WarnMsg
  8220. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8221. res2.Infcode = infocode
  8222. } else {
  8223. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8224. utils.ErrorLog("解析失败:%v", err)
  8225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8226. return
  8227. }
  8228. }
  8229. }
  8230. if res2.Infcode == 0 {
  8231. if err == nil {
  8232. c.ServeSuccessJSON(map[string]interface{}{
  8233. "msg": "退号成功",
  8234. })
  8235. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8236. } else {
  8237. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8238. return
  8239. }
  8240. } else {
  8241. c.ServeSuccessJSON(map[string]interface{}{
  8242. "code": -10,
  8243. "msg": res2.ErrMsg,
  8244. })
  8245. }
  8246. } else {
  8247. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8248. //if err == nil {
  8249. // c.ServeSuccessJSON(map[string]interface{}{
  8250. // "msg": "退费成功",
  8251. // })
  8252. //} else {
  8253. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8254. // return
  8255. //}
  8256. }
  8257. }
  8258. func (c *HisApiController) RefundDetail() {
  8259. order_id, _ := c.GetInt64("order_id")
  8260. admin_user_id, _ := c.GetInt64("admin_user_id")
  8261. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8262. number := c.GetString("number")
  8263. record_time := c.GetString("record_time")
  8264. patient_id, _ := c.GetInt64("patient_id")
  8265. //med_type, _ := c.GetInt64("med_type")
  8266. timeLayout := "2006-01-02"
  8267. loc, _ := time.LoadLocation("Local")
  8268. adminUser := c.GetAdminUserInfo()
  8269. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8270. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8271. fmt.Println(err)
  8272. if err != nil {
  8273. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8274. return
  8275. }
  8276. recordDateTime := theTime.Unix()
  8277. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8278. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8279. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8280. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8281. var order models.HisOrder
  8282. order, _ = service.GetHisOrderByID(order_id)
  8283. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8284. if config.IsOpen == 1 { //对接了医保,走医保流程
  8285. var res2 ResultSix
  8286. if miConfig.MdtrtareaAdmvs == "421300" {
  8287. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8288. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8289. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8290. resp3, requestErr3 := http.Get(api3)
  8291. if requestErr3 != nil {
  8292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8293. return
  8294. }
  8295. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8296. if ioErr3 != nil {
  8297. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8299. return
  8300. }
  8301. var respJSON3 map[string]interface{}
  8302. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8303. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8308. userJSONBytes3, _ := json.Marshal(respJSON3)
  8309. fmt.Println("log")
  8310. fmt.Println(string(userJSONBytes3))
  8311. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8312. utils.ErrorLog("解析失败:%v", err)
  8313. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8314. return
  8315. }
  8316. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8317. if err == nil {
  8318. c.ServeSuccessJSON(map[string]interface{}{
  8319. "msg": "撤销明细成功",
  8320. })
  8321. return
  8322. } else {
  8323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8324. return
  8325. }
  8326. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8327. var resSix10265 ResultSix10265
  8328. var api3 string
  8329. if miConfig.MdtrtareaAdmvs == "320921" {
  8330. api3 = "http://192.168.2.110:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8331. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8332. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8333. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8334. } else {
  8335. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8336. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8337. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8338. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8339. }
  8340. resp3, requestErr3 := http.Get(api3)
  8341. if requestErr3 != nil {
  8342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8343. return
  8344. }
  8345. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8346. if ioErr3 != nil {
  8347. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8349. return
  8350. }
  8351. var respJSON3 map[string]interface{}
  8352. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8353. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8354. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8355. return
  8356. }
  8357. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8358. userJSONBytes3, _ := json.Marshal(respJSON3)
  8359. fmt.Println("log")
  8360. fmt.Println(string(userJSONBytes3))
  8361. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8362. utils.ErrorLog("解析失败:%v", err)
  8363. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8364. return
  8365. }
  8366. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8367. res2.Output = resSix10265.Output
  8368. res2.ErrMsg = resSix10265.ErrMsg
  8369. res2.Cainfo = resSix10265.Cainfo
  8370. res2.WarnMsg = resSix10265.WarnMsg
  8371. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8372. res2.Infcode = infocode
  8373. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8374. if err == nil {
  8375. c.ServeSuccessJSON(map[string]interface{}{
  8376. "msg": "撤销明细成功",
  8377. })
  8378. return
  8379. } else {
  8380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8381. return
  8382. }
  8383. } else if miConfig.MdtrtareaAdmvs == "350500" {
  8384. result2, src_request, _ := service.FJyb2205(his.PsnNo, his.Number, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  8385. var dat map[string]interface{}
  8386. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  8387. fmt.Println(dat)
  8388. } else {
  8389. fmt.Println(err)
  8390. }
  8391. saveLog(result2, src_request, "2205", "撤销明细")
  8392. userJSONBytes, _ := json.Marshal(dat)
  8393. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  8394. utils.ErrorLog("解析失败:%v", err)
  8395. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8396. return
  8397. }
  8398. if res2.Infcode == 0 {
  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. } else {
  8410. c.ServeSuccessJSON(map[string]interface{}{
  8411. "code": -10,
  8412. "msg": res2.ErrMsg,
  8413. })
  8414. }
  8415. } else {
  8416. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8417. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8418. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8419. resp2, requestErr2 := http.Get(api2)
  8420. if requestErr2 != nil {
  8421. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8422. return
  8423. }
  8424. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8425. if ioErr2 != nil {
  8426. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8428. return
  8429. }
  8430. var respJSON2 map[string]interface{}
  8431. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8432. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8433. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8434. return
  8435. }
  8436. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8437. if err == nil {
  8438. c.ServeSuccessJSON(map[string]interface{}{
  8439. "msg": "撤销明细成功",
  8440. })
  8441. return
  8442. } else {
  8443. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8444. return
  8445. }
  8446. }
  8447. } else {
  8448. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8449. if err == nil {
  8450. c.ServeSuccessJSON(map[string]interface{}{
  8451. "msg": "退费成功",
  8452. })
  8453. } else {
  8454. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8455. return
  8456. }
  8457. }
  8458. }
  8459. //对账
  8460. func (c *HisApiController) GetCheckAccount() {
  8461. start_time := c.GetString("start_time")
  8462. end_time := c.GetString("end_time")
  8463. insutype := c.GetString("insutype")
  8464. clr_type := c.GetString("clr_type")
  8465. clr_org := c.GetString("clr_optins")
  8466. admin_user_id, _ := c.GetInt64("admin_user_id")
  8467. adminUser := c.GetAdminUserInfo()
  8468. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8469. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8470. if len(clr_org) == 0 {
  8471. clr_org = miConfig.MdtrtareaAdmvs
  8472. }
  8473. timeLayout := "2006-01-02"
  8474. loc, _ := time.LoadLocation("Local")
  8475. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8476. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8477. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8478. fixmedins_setl_cnt := int64(len(orders))
  8479. var medfee_sumamt float64
  8480. var acct_pay float64
  8481. var fund_pay_sumamt float64
  8482. for _, item := range orders {
  8483. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8484. acct_pay = acct_pay + item.AcctPay
  8485. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8486. }
  8487. var user_name string
  8488. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8489. if role.ID == 0 {
  8490. user_name = "xxx"
  8491. } else {
  8492. user_name = role.UserName
  8493. }
  8494. var res ResultEight
  8495. var res10188 ResultEightFor10188
  8496. if config.IsOpen == 1 {
  8497. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8498. api := "http://192.168.2.110:9532/" + "jsyb/3201?" +
  8499. "insutype=" + insutype +
  8500. "&clr_type=" + clr_type +
  8501. "&setl_optins=" + clr_org +
  8502. "&stmt_begndate=" + start_time +
  8503. "&stm_enddate=" + end_time +
  8504. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8505. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8506. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8507. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8508. "&fixmedins_code=" + miConfig.Code +
  8509. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8510. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8511. "&secret_key=" + miConfig.SecretKey +
  8512. "&org_name=" + miConfig.OrgName +
  8513. "&doctor=" + user_name +
  8514. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8515. fmt.Println(api)
  8516. resp, requestErr := http.Get(api)
  8517. if requestErr != nil {
  8518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8519. return
  8520. }
  8521. body, ioErr := ioutil.ReadAll(resp.Body)
  8522. fmt.Println(body)
  8523. if ioErr != nil {
  8524. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8525. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8526. return
  8527. }
  8528. var respJSON map[string]interface{}
  8529. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8530. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8532. return
  8533. }
  8534. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8535. userJSONBytes, _ := json.Marshal(respJSON)
  8536. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8537. utils.ErrorLog("解析失败:%v", err)
  8538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8539. return
  8540. }
  8541. res.InfRefmsgid = res10188.InfRefmsgid
  8542. res.Output = res10188.Output
  8543. res.ErrMsg = res10188.ErrMsg
  8544. res.Cainfo = res10188.Cainfo
  8545. res.WarnMsg = res10188.WarnMsg
  8546. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8547. res.Infcode = infocode
  8548. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8549. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8550. "insutype=" + insutype +
  8551. "&clr_type=" + clr_type +
  8552. "&setl_optins=" + clr_org +
  8553. "&stmt_begndate=" + start_time +
  8554. "&stm_enddate=" + end_time +
  8555. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8556. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8557. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8558. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8559. "&fixmedins_code=" + miConfig.Code +
  8560. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8561. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8562. "&secret_key=" + miConfig.SecretKey +
  8563. "&org_name=" + miConfig.OrgName +
  8564. "&doctor=" + user_name
  8565. resp, requestErr := http.Get(api)
  8566. if requestErr != nil {
  8567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8568. return
  8569. }
  8570. body, ioErr := ioutil.ReadAll(resp.Body)
  8571. if ioErr != nil {
  8572. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8573. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8574. return
  8575. }
  8576. var respJSON map[string]interface{}
  8577. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8578. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8580. return
  8581. }
  8582. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8583. result, _ := json.Marshal(respJSON)
  8584. fmt.Println("log")
  8585. fmt.Println(string(result))
  8586. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8587. utils.ErrorLog("解析失败:%v", err)
  8588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8589. return
  8590. }
  8591. res.InfRefmsgid = res10188.InfRefmsgid
  8592. res.Output = res10188.Output
  8593. res.ErrMsg = res10188.ErrMsg
  8594. res.Cainfo = res10188.Cainfo
  8595. res.WarnMsg = res10188.WarnMsg
  8596. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8597. res.Infcode = infocode
  8598. } else {
  8599. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8600. "insutype=" + insutype +
  8601. "&clr_type=" + clr_type +
  8602. "&setl_optins=" + clr_org +
  8603. "&stmt_begndate=" + start_time +
  8604. "&stm_enddate=" + end_time +
  8605. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8606. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8607. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8608. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8609. "&fixmedins_code=" + miConfig.Code +
  8610. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8611. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8612. "&secret_key=" + miConfig.SecretKey +
  8613. "&org_name=" + miConfig.OrgName +
  8614. "&doctor=" + user_name
  8615. fmt.Println(api)
  8616. resp, requestErr := http.Get(api)
  8617. if requestErr != nil {
  8618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8619. return
  8620. }
  8621. body, ioErr := ioutil.ReadAll(resp.Body)
  8622. fmt.Println(body)
  8623. if ioErr != nil {
  8624. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8625. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8626. return
  8627. }
  8628. var respJSON map[string]interface{}
  8629. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8630. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8631. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8632. return
  8633. }
  8634. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8635. userJSONBytes, _ := json.Marshal(respJSON)
  8636. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8637. utils.ErrorLog("解析失败:%v", err)
  8638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8639. return
  8640. }
  8641. }
  8642. if res.Infcode == 0 {
  8643. if res.Output.Stmtinfo.StmtRslt == "0" {
  8644. micc := &models.MedicalInsuranceCostCompare{
  8645. StartTime: startime.Unix(),
  8646. EndTime: endtime.Unix(),
  8647. Insutype: insutype,
  8648. CheckType: 1,
  8649. Num: fixmedins_setl_cnt,
  8650. Mtime: time.Now().Unix(),
  8651. Status: 1,
  8652. UserOrgId: adminUser.CurrentOrgId,
  8653. CostTotal: medfee_sumamt,
  8654. FuncTotal: fund_pay_sumamt,
  8655. PsnPay: acct_pay,
  8656. Creator: admin_user_id,
  8657. Ctime: time.Now().Unix(),
  8658. ClrType: clr_type,
  8659. }
  8660. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8661. if err == nil {
  8662. c.ServeSuccessJSON(map[string]interface{}{
  8663. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8664. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8665. })
  8666. } else {
  8667. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8668. }
  8669. } else {
  8670. c.ServeSuccessJSON(map[string]interface{}{
  8671. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8672. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8673. })
  8674. }
  8675. } else {
  8676. c.ServeSuccessJSON(map[string]interface{}{
  8677. "code": -10,
  8678. "msg": res.ErrMsg,
  8679. })
  8680. }
  8681. }
  8682. }
  8683. func (c *HisApiController) Check310() {
  8684. adminUser := c.GetAdminUserInfo()
  8685. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8686. var user_name string
  8687. user_name = "高慧裕"
  8688. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8689. "insutype=" + "310" +
  8690. "&clr_type=" + "" +
  8691. "&setl_optins=" + "441202" +
  8692. "&stmt_begndate=" + "2022-03-01" +
  8693. "&stm_enddate=" + "2022-03-31" +
  8694. "&medfee_sumamt=" + "194930.12" +
  8695. "&fund_pay_sumamt=" + "188741.46" +
  8696. "&acct_pay=" + "0" +
  8697. "&fixmedins_setl_cnt=" + "452" +
  8698. "&fixmedins_code=" + miConfig.Code +
  8699. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8700. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8701. "&secret_key=" + miConfig.SecretKey +
  8702. "&org_name=" + miConfig.OrgName +
  8703. "&doctor=" + user_name
  8704. fmt.Println(api)
  8705. resp, requestErr := http.Get(api)
  8706. if requestErr != nil {
  8707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8708. return
  8709. }
  8710. body, ioErr := ioutil.ReadAll(resp.Body)
  8711. fmt.Println(body)
  8712. if ioErr != nil {
  8713. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8715. return
  8716. }
  8717. var respJSON map[string]interface{}
  8718. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8719. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8721. return
  8722. }
  8723. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8724. userJSONBytes, _ := json.Marshal(respJSON)
  8725. var res ResultEight
  8726. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8727. utils.ErrorLog("解析失败:%v", err)
  8728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8729. return
  8730. }
  8731. }
  8732. func (c *HisApiController) Check390() {
  8733. adminUser := c.GetAdminUserInfo()
  8734. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8735. var user_name string
  8736. user_name = "高慧裕"
  8737. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8738. "insutype=" + "390" +
  8739. "&clr_type=" + "" +
  8740. "&setl_optins=" + "441202" +
  8741. "&stmt_begndate=" + "2022-03-01" +
  8742. "&stm_enddate=" + "2022-03-31" +
  8743. "&medfee_sumamt=" + "1068448.89" +
  8744. "&fund_pay_sumamt=" + "1014677.62" +
  8745. "&acct_pay=" + "0" +
  8746. "&fixmedins_setl_cnt=" + "1950" +
  8747. "&fixmedins_code=" + miConfig.Code +
  8748. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8749. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8750. "&secret_key=" + miConfig.SecretKey +
  8751. "&org_name=" + miConfig.OrgName +
  8752. "&doctor=" + user_name
  8753. fmt.Println(api)
  8754. resp, requestErr := http.Get(api)
  8755. if requestErr != nil {
  8756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8757. return
  8758. }
  8759. body, ioErr := ioutil.ReadAll(resp.Body)
  8760. fmt.Println(body)
  8761. if ioErr != nil {
  8762. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8763. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8764. return
  8765. }
  8766. var respJSON map[string]interface{}
  8767. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8768. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8769. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8770. return
  8771. }
  8772. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8773. userJSONBytes, _ := json.Marshal(respJSON)
  8774. var res ResultEight
  8775. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8776. utils.ErrorLog("解析失败:%v", err)
  8777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8778. return
  8779. }
  8780. }
  8781. //对账明细
  8782. func (c *HisApiController) GetCheckDetailAccount() {
  8783. start_time := c.GetString("start_time")
  8784. end_time := c.GetString("end_time")
  8785. admin_user_id, _ := c.GetInt64("admin_user_id")
  8786. adminUser := c.GetAdminUserInfo()
  8787. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8788. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8789. timeLayout := "2006-01-02"
  8790. loc, _ := time.LoadLocation("Local")
  8791. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8792. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8793. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8794. rand.Seed(time.Now().UnixNano())
  8795. num := rand.Intn(30000)
  8796. Mkdir(miConfig.OrgName)
  8797. file := strconv.FormatInt(int64(num), 10)
  8798. file_name := file + ".txt"
  8799. zip_name := file + ".zip"
  8800. zip_path := miConfig.OrgName + "/" + zip_name
  8801. file_path := miConfig.OrgName + "/" + file_name
  8802. decimal.DivisionPrecision = 2
  8803. var medfee_sumamt float64
  8804. var psn_cash_pay float64
  8805. var fund_pay_sumamt float64
  8806. fixmedins_setl_cnt := int64(len(orders))
  8807. for _, item := range orders {
  8808. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8809. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8810. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8811. }
  8812. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8813. defer f.Close()
  8814. if err != nil {
  8815. fmt.Println(err.Error())
  8816. } else {
  8817. for _, item := range orders {
  8818. var refd_setl_flag string
  8819. if item.OrderStatus == 2 {
  8820. refd_setl_flag = "0"
  8821. var str string
  8822. str = item.SetlId + " " +
  8823. item.MdtrtId + " " +
  8824. item.PsnNo + " " +
  8825. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8826. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8827. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8828. _, err = f.Write([]byte(str))
  8829. }
  8830. if item.OrderStatus == 3 {
  8831. var str string
  8832. str = item.SetlId + " " +
  8833. item.MdtrtId + " " +
  8834. item.PsnNo + " " +
  8835. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8836. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8837. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8838. _, err = f.Write([]byte(str))
  8839. var str2 string
  8840. str2 = item.SetlId + " " +
  8841. item.MdtrtId + " " +
  8842. item.PsnNo + " " +
  8843. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8844. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8845. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8846. _, err = f.Write([]byte(str2))
  8847. }
  8848. }
  8849. }
  8850. Zip(file_path, zip_path)
  8851. fmt.Println(ReadFile(zip_path))
  8852. fmt.Println(string(ReadFile(zip_path)))
  8853. if config.IsOpen == 1 {
  8854. var user_name string
  8855. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8856. if role.ID == 0 {
  8857. user_name = "管理员"
  8858. } else {
  8859. user_name = role.UserName
  8860. }
  8861. baseParams := models.BaseParams{
  8862. SecretKey: miConfig.SecretKey,
  8863. FixmedinsCode: miConfig.Code,
  8864. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8865. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8866. OrgName: miConfig.OrgName,
  8867. Doctor: user_name,
  8868. }
  8869. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8870. var dat map[string]interface{}
  8871. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8872. fmt.Println(dat)
  8873. } else {
  8874. fmt.Println(err)
  8875. }
  8876. userJSONBytes, _ := json.Marshal(dat)
  8877. var res ResultNine
  8878. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8879. utils.ErrorLog("解析失败:%v", err)
  8880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8881. return
  8882. }
  8883. if res.Infcode == 0 {
  8884. fileNo := res.Output.FileQuryNo
  8885. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8886. "file_qury_no=" + fileNo +
  8887. "&setl_optins=" + "定点医保中心" +
  8888. "&stmt_begndate=" + start_time +
  8889. "&stm_enddate=" + end_time +
  8890. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8891. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8892. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8893. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8894. "&fixmedins_code=" + miConfig.Code +
  8895. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8896. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8897. "&secret_key=" + miConfig.SecretKey +
  8898. "&org_name=" + miConfig.OrgName +
  8899. "&doctor=" + user_name
  8900. resp, requestErr := http.Get(api)
  8901. if requestErr != nil {
  8902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8903. return
  8904. }
  8905. body, ioErr := ioutil.ReadAll(resp.Body)
  8906. if ioErr != nil {
  8907. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8909. return
  8910. }
  8911. var respJSON map[string]interface{}
  8912. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8913. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8914. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8915. return
  8916. }
  8917. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8918. userJSONBytes, _ := json.Marshal(respJSON)
  8919. var res ResultTen
  8920. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8921. utils.ErrorLog("解析失败:%v", err)
  8922. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8923. return
  8924. }
  8925. if res.Infcode == 0 {
  8926. service.Gdyb9102(baseParams, zip_name, fileNo)
  8927. micc := &models.MedicalInsuranceCostCompare{
  8928. StartTime: startime.Unix(),
  8929. EndTime: endtime.Unix(),
  8930. Insutype: "0",
  8931. CheckType: 2,
  8932. Num: fixmedins_setl_cnt,
  8933. Mtime: time.Now().Unix(),
  8934. Status: 1,
  8935. UserOrgId: adminUser.CurrentOrgId,
  8936. CostTotal: medfee_sumamt,
  8937. FuncTotal: fund_pay_sumamt,
  8938. PsnPay: psn_cash_pay,
  8939. Creator: admin_user_id,
  8940. Ctime: time.Now().Unix(),
  8941. }
  8942. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8943. c.ServeSuccessJSON(map[string]interface{}{
  8944. "msg": "明细对账成功",
  8945. })
  8946. }
  8947. } else {
  8948. }
  8949. }
  8950. }
  8951. type CustomOrderInfo struct {
  8952. Name string
  8953. Spec string
  8954. Unit string
  8955. Count float64
  8956. Price float64
  8957. Total float64
  8958. }
  8959. func (c *HisApiController) GetSettleAccounts() {
  8960. //id, _ := c.GetInt64("id")
  8961. //record_time := c.GetString("record_time")
  8962. order_id, _ := c.GetInt64("order_id")
  8963. admin_user_id, _ := c.GetInt64("admin_user_id")
  8964. //timeLayout := "2006-01-02"
  8965. //loc, _ := time.LoadLocation("Local")
  8966. //
  8967. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8968. //if err != nil {
  8969. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8970. // return
  8971. //}
  8972. //recordDateTime := theTime.Unix()
  8973. adminUser := c.GetAdminUserInfo()
  8974. order, _ := service.GetHisOrderByID(order_id)
  8975. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8976. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8977. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8978. orderInfos = append(orderInfos, orderInfos_two...)
  8979. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8980. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8981. var diagnosis_ids []string
  8982. if his.ID > 0 {
  8983. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8984. } else {
  8985. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8986. }
  8987. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8988. var dia_config []*models.HisXtDiagnoseConfig
  8989. var name string
  8990. for _, item := range diagnosis_ids {
  8991. id, _ := strconv.ParseInt(item, 10, 64)
  8992. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8993. dia_config = append(dia_config, &diagnosisConfig)
  8994. if len(name) == 0 {
  8995. name = diagnosisConfig.ClassName
  8996. } else {
  8997. name = name + "," + diagnosisConfig.ClassName
  8998. }
  8999. }
  9000. var bedCostTotal float64 = 0 //床位总费
  9001. var bedCostSelfTotal float64 = 0 //床位自费
  9002. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  9003. var operationCostTotal float64 = 0 //手术费
  9004. var operationCostSelfTotal float64 = 0 //手术费
  9005. var operationCostPartSelfTotal float64 = 0 //手术费
  9006. var otherCostTotal float64 = 0 //其他费用
  9007. var otherCostSelfTotal float64 = 0 //其他费用
  9008. var otherCostPartSelfTotal float64 = 0 //其他费用
  9009. var materialCostTotal float64 = 0 //材料费
  9010. var materialCostSelfTotal float64 = 0 //材料费
  9011. var materialCostPartSelfTotal float64 = 0 //材料费
  9012. var westernMedicineCostTotal float64 = 0 //西药费
  9013. var westernMedicineCostSelfTotal float64 = 0 //西药费
  9014. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  9015. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  9016. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  9017. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  9018. var checkCostTotal float64 = 0 //检查费
  9019. var checkCostSelfTotal float64 = 0 //检查费
  9020. var checkCostPartSelfTotal float64 = 0 //检查费
  9021. var laboratoryCostTotal float64 = 0 //化验费
  9022. var laboratoryCostSelfTotal float64 = 0 //化验费
  9023. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  9024. var treatCostTotal float64 = 0 //治疗费用
  9025. var treatCostSelfTotal float64 = 0 //治疗费用
  9026. var treatCostPartSelfTotal float64 = 0 //治疗费用
  9027. decimal.DivisionPrecision = 2
  9028. for _, item := range orderInfos {
  9029. if item.MedChrgitmType == "01" { //床位费
  9030. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9031. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9032. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9033. }
  9034. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  9035. if item.MedChrgitmType == "03" { //检查费
  9036. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9037. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9038. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9039. }
  9040. } else {
  9041. if item.MedChrgitmType == "03" { //检查费
  9042. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9043. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9044. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9045. }
  9046. }
  9047. if item.MedChrgitmType == "04" { //化验费
  9048. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9049. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9050. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9051. }
  9052. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  9053. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9054. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9055. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9056. }
  9057. if item.MedChrgitmType == "06" { //手术费
  9058. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9059. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9060. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9061. }
  9062. if item.MedChrgitmType == "08" { //材料费
  9063. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9064. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9065. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9066. }
  9067. if item.MedChrgitmType == "09" { //西药费
  9068. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9069. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9070. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9071. }
  9072. if item.MedChrgitmType == "11" { //中成费
  9073. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9074. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9075. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9076. }
  9077. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  9078. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  9079. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  9080. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  9081. }
  9082. }
  9083. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9084. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9085. var user_name string
  9086. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9087. if role.ID == 0 {
  9088. user_name = "管理员"
  9089. } else {
  9090. user_name = role.UserName
  9091. }
  9092. baseParams := models.BaseParams{
  9093. SecretKey: miConfig.SecretKey,
  9094. FixmedinsCode: miConfig.Code,
  9095. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9096. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9097. OrgName: miConfig.OrgName,
  9098. Doctor: user_name,
  9099. }
  9100. businessParams := models.BusinessParams{
  9101. PsnNo: order.PsnNo,
  9102. MdtrtId: order.MdtrtId,
  9103. SetlId: order.SetlId,
  9104. }
  9105. var res ResultEleven
  9106. var resEleven10265 ResultEleven10265
  9107. if config.IsOpen == 1 {
  9108. if miConfig.MdtrtareaAdmvs == "421300" {
  9109. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9110. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9111. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9112. resp, requestErr := http.Get(api)
  9113. if requestErr != nil {
  9114. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9115. return
  9116. }
  9117. body, ioErr := ioutil.ReadAll(resp.Body)
  9118. if ioErr != nil {
  9119. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9120. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9121. return
  9122. }
  9123. var respJSON map[string]interface{}
  9124. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9125. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9127. return
  9128. }
  9129. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9130. result, _ := json.Marshal(respJSON)
  9131. fmt.Println("log")
  9132. fmt.Println(string(result))
  9133. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9134. utils.ErrorLog("解析失败:%v", err)
  9135. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9136. return
  9137. }
  9138. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9139. var api string
  9140. if miConfig.MdtrtareaAdmvs == "320921" {
  9141. api = "http://192.168.2.110:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9142. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9143. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9144. //req, _ = http.NewRequest("POST", "http://192.168.2.110:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9145. } else {
  9146. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  9147. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9148. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9149. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  9150. }
  9151. resp, requestErr := http.Get(api)
  9152. if requestErr != nil {
  9153. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9154. return
  9155. }
  9156. body, ioErr := ioutil.ReadAll(resp.Body)
  9157. if ioErr != nil {
  9158. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9160. return
  9161. }
  9162. var respJSON map[string]interface{}
  9163. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9164. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9165. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9166. return
  9167. }
  9168. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9169. result, _ := json.Marshal(respJSON)
  9170. fmt.Println("log")
  9171. fmt.Println(string(result))
  9172. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9173. utils.ErrorLog("解析失败:%v", err)
  9174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9175. return
  9176. }
  9177. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9178. res.Output = resEleven10265.Output
  9179. res.ErrMsg = resEleven10265.ErrMsg
  9180. res.Cainfo = resEleven10265.Cainfo
  9181. res.WarnMsg = resEleven10265.WarnMsg
  9182. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9183. res.Infcode = infocode
  9184. } else if miConfig.MdtrtareaAdmvs == "350500" {
  9185. result, requestLog, _ := service.FJyb5203(baseParams, businessParams, miConfig.Url, miConfig.Code, miConfig.AppSecret, miConfig.SignKey, miConfig.EncKey)
  9186. saveLog(result, requestLog, "5203", "结算单")
  9187. var dat map[string]interface{}
  9188. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9189. fmt.Println(dat)
  9190. } else {
  9191. fmt.Println(err)
  9192. }
  9193. userJSONBytes, _ := json.Marshal(dat)
  9194. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9195. utils.ErrorLog("解析失败:%v", err)
  9196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9197. return
  9198. }
  9199. } else if miConfig.MdtrtareaAdmvs == "150499" {
  9200. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  9201. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  9202. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  9203. resp, requestErr := http.Get(api)
  9204. if requestErr != nil {
  9205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9206. return
  9207. }
  9208. body, ioErr := ioutil.ReadAll(resp.Body)
  9209. if ioErr != nil {
  9210. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9212. return
  9213. }
  9214. var respJSON map[string]interface{}
  9215. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9216. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9217. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9218. return
  9219. }
  9220. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9221. result, _ := json.Marshal(respJSON)
  9222. fmt.Println("log")
  9223. fmt.Println(string(result))
  9224. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  9225. utils.ErrorLog("解析失败:%v", err)
  9226. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9227. return
  9228. }
  9229. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9230. res.Output = resEleven10265.Output
  9231. res.ErrMsg = resEleven10265.ErrMsg
  9232. res.Cainfo = resEleven10265.Cainfo
  9233. res.WarnMsg = resEleven10265.WarnMsg
  9234. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9235. res.Infcode = infocode
  9236. } else {
  9237. result := service.Gdyb5203(baseParams, businessParams)
  9238. //service.Gdyb5204(baseParams, businessParams)
  9239. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9240. var dat map[string]interface{}
  9241. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9242. fmt.Println(dat)
  9243. } else {
  9244. fmt.Println(err)
  9245. }
  9246. userJSONBytes, _ := json.Marshal(dat)
  9247. if miConfig.Code == "H15049901371" {
  9248. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9249. utils.ErrorLog("解析失败:%v", err)
  9250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9251. return
  9252. }
  9253. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9254. res.Output = resEleven10265.Output
  9255. res.ErrMsg = resEleven10265.ErrMsg
  9256. res.Cainfo = resEleven10265.Cainfo
  9257. res.WarnMsg = resEleven10265.WarnMsg
  9258. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9259. res.Infcode = infocode
  9260. } else {
  9261. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9262. utils.ErrorLog("解析失败:%v", err)
  9263. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9264. return
  9265. }
  9266. }
  9267. }
  9268. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9269. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9270. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9271. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9272. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9273. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9274. var doctor_name string
  9275. if roles.ID == 0 {
  9276. doctor_name = "管理员"
  9277. } else {
  9278. doctor_name = roles.UserName
  9279. }
  9280. yiliao_leibie := ""
  9281. switch order.MedType {
  9282. case "11":
  9283. yiliao_leibie = "普通门诊"
  9284. break
  9285. case "12":
  9286. yiliao_leibie = "门诊挂号"
  9287. break
  9288. case "13":
  9289. yiliao_leibie = "急诊"
  9290. break
  9291. case "14":
  9292. yiliao_leibie = "门诊特殊病"
  9293. break
  9294. case "15":
  9295. yiliao_leibie = "门诊统筹"
  9296. break
  9297. case "16":
  9298. yiliao_leibie = "门诊慢性病"
  9299. break
  9300. case "21":
  9301. yiliao_leibie = "普通住院"
  9302. break
  9303. }
  9304. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9305. if res.Infcode == 0 {
  9306. c.ServeSuccessJSON(map[string]interface{}{
  9307. "diagnosis": name,
  9308. "order_infos": orderInfos,
  9309. "number": order.MdtrtId,
  9310. "date": order.SettleAccountsDate,
  9311. "charge_admin": charge_admin,
  9312. "printor_admin": printor_admin,
  9313. "info": res.Output.Setlinfo,
  9314. "order": order,
  9315. "bedCostTotal": bedCostTotal,
  9316. "bedCostSelfTotal": bedCostSelfTotal,
  9317. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9318. "operationCostTotal": operationCostTotal,
  9319. "operationCostSelfTotal": operationCostSelfTotal,
  9320. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9321. "otherCostTotal": otherCostTotal,
  9322. "otherCostSelfTotal": otherCostSelfTotal,
  9323. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9324. "materialCostTotal": materialCostTotal,
  9325. "materialCostSelfTotal": materialCostSelfTotal,
  9326. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9327. "westernMedicineCostTotal": westernMedicineCostTotal,
  9328. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9329. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9330. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9331. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9332. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9333. "checkCostTotal": checkCostTotal,
  9334. "checkCostSelfTotal": checkCostSelfTotal,
  9335. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9336. "laboratoryCostTotal": laboratoryCostTotal,
  9337. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9338. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9339. "treatCostTotal": treatCostTotal,
  9340. "treatCostSelfTotal": treatCostSelfTotal,
  9341. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9342. "doctor_info": doctor_info,
  9343. "doctor_code": adminRole_two.DoctorCode,
  9344. "doctor_name": doctor_name,
  9345. "health_card_no": order.PsnNo,
  9346. "department": departments.Name,
  9347. "yiliao_leibie": yiliao_leibie,
  9348. "after_money": order.AccountPrice,
  9349. "patient": patient,
  9350. "org_name": miConfig.OrgName,
  9351. "org_code": miConfig.Code,
  9352. "order_number": order.Number,
  9353. "his_hospital": his_hospital,
  9354. "his": his,
  9355. "dia_config": dia_config,
  9356. //"check_order_info": cus_slice,
  9357. })
  9358. }
  9359. }
  9360. }
  9361. func (c *HisApiController) CheckTreatment() {
  9362. patient_id, _ := c.GetInt64("patient_id")
  9363. id_card_no := c.GetString("id_card_no")
  9364. insutype := c.GetString("insutype")
  9365. med_type := c.GetString("med_type")
  9366. admin_user_id, _ := c.GetInt64("admin_user_id")
  9367. adminUser := c.GetAdminUserInfo()
  9368. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9369. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9370. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9371. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9372. if miConfig.MdtrtareaAdmvs == "421300" {
  9373. var res ResultTwo
  9374. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9375. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9376. "&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)
  9377. resp, requestErr := http.Get(api)
  9378. if requestErr != nil {
  9379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9380. return
  9381. }
  9382. body, ioErr := ioutil.ReadAll(resp.Body)
  9383. if ioErr != nil {
  9384. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9385. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9386. return
  9387. }
  9388. var respJSON map[string]interface{}
  9389. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9390. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9392. return
  9393. }
  9394. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9395. result, _ := json.Marshal(respJSON)
  9396. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9397. utils.ErrorLog("解析失败:%v", err)
  9398. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9399. return
  9400. }
  9401. if res.Infcode == 0 {
  9402. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9403. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9404. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9405. resp, requestErr := http.Get(api)
  9406. if requestErr != nil {
  9407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9408. return
  9409. }
  9410. body, ioErr := ioutil.ReadAll(resp.Body)
  9411. if ioErr != nil {
  9412. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9413. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9414. return
  9415. }
  9416. var respJSON map[string]interface{}
  9417. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9418. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9419. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9420. return
  9421. }
  9422. var res Result2001
  9423. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9424. result2, _ := json.Marshal(respJSON)
  9425. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9426. utils.ErrorLog("解析失败:%v", err)
  9427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9428. return
  9429. }
  9430. if res.Infcode == 0 {
  9431. c.ServeSuccessJSON(map[string]interface{}{
  9432. "msg": res.Output.Trtinfo,
  9433. })
  9434. }
  9435. } else {
  9436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9437. return
  9438. }
  9439. } else {
  9440. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9441. var dat map[string]interface{}
  9442. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9443. fmt.Println(dat)
  9444. } else {
  9445. fmt.Println(err)
  9446. }
  9447. userJSONBytes, _ := json.Marshal(dat)
  9448. var res ResultTwo
  9449. var res10265 ResultTwo10265
  9450. if miConfig.Code == "H15049901371" {
  9451. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9452. utils.ErrorLog("解析失败:%v", err)
  9453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9454. return
  9455. }
  9456. res.ErrMsg = res10265.ErrMsg
  9457. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9458. res.Infcode = infocode
  9459. res.Output = res10265.Output
  9460. res.InfRefmsgid = res10265.InfRefmsgid
  9461. } else {
  9462. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9463. utils.ErrorLog("解析失败:%v", err)
  9464. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9465. return
  9466. }
  9467. }
  9468. var user_name string
  9469. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9470. if role.ID == 0 {
  9471. user_name = "xxx"
  9472. } else {
  9473. user_name = role.UserName
  9474. }
  9475. baseParams := models.BaseParams{
  9476. SecretKey: miConfig.SecretKey,
  9477. FixmedinsCode: miConfig.Code,
  9478. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9479. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9480. OrgName: miConfig.OrgName,
  9481. Doctor: user_name,
  9482. }
  9483. if config.IsOpen == 1 {
  9484. if miConfig.Code == "H15049901371" {
  9485. if med_type == "14" {
  9486. if insutype == "390" {
  9487. med_type = "9933"
  9488. } else if insutype == "310" {
  9489. med_type = "990502"
  9490. }
  9491. } else if med_type == "11" {
  9492. med_type = "11"
  9493. }
  9494. }
  9495. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9496. var dat map[string]interface{}
  9497. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9498. fmt.Println(dat)
  9499. } else {
  9500. fmt.Println(err)
  9501. }
  9502. var res Result2001
  9503. var res10265 Result2001Org10265
  9504. if miConfig.Code == "H15049901371" {
  9505. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9506. utils.ErrorLog("解析失败:%v", err)
  9507. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9508. return
  9509. }
  9510. res.ErrMsg = res10265.ErrMsg
  9511. res.Output = res10265.Output
  9512. res.InfRefmsgid = res10265.InfRefmsgid
  9513. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9514. res.Infcode = infocode
  9515. } else {
  9516. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9517. utils.ErrorLog("解析失败:%v", err)
  9518. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9519. return
  9520. }
  9521. }
  9522. if res.Infcode == 0 {
  9523. c.ServeSuccessJSON(map[string]interface{}{
  9524. "msg": res.Output.Trtinfo,
  9525. })
  9526. }
  9527. }
  9528. }
  9529. }
  9530. //func (c *HisApiController) PutRecord() {
  9531. // id, _ := c.GetInt64("id")
  9532. // record_time := c.GetString("record_time")
  9533. // timeLayout := "2006-01-02"
  9534. // loc, _ := time.LoadLocation("Local")
  9535. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9536. // if err != nil {
  9537. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9538. // return
  9539. // }
  9540. // recordDateTime := theTime.Unix()
  9541. //
  9542. // adminInfo := c.GetAdminUserInfo()
  9543. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9544. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9545. //
  9546. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9547. //
  9548. // fmt.Println(miConfig.SecretKey)
  9549. //
  9550. // if patient == nil {
  9551. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9552. // return
  9553. // }
  9554. // if len(patient.IdCardNo) == 0 {
  9555. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9556. // return
  9557. // }
  9558. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9559. // if config.IsOpen == 1 {
  9560. // 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
  9561. // resp, requestErr := http.Get(api)
  9562. // if requestErr != nil {
  9563. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9564. // return
  9565. // }
  9566. // defer resp.Body.Close()
  9567. // body, ioErr := ioutil.ReadAll(resp.Body)
  9568. // if ioErr != nil {
  9569. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9570. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9571. // return
  9572. // }
  9573. // var respJSON map[string]interface{}
  9574. //
  9575. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9576. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9577. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9578. // return
  9579. // }
  9580. //
  9581. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9582. // userJSONBytes, _ := json.Marshal(userJSON)
  9583. // var res ResultTwo
  9584. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9585. // utils.ErrorLog("解析失败:%v", err)
  9586. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9587. // return
  9588. // }
  9589. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9590. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9591. // infoStr := string(Iinfos)
  9592. // idetinfoStr := string(Idetinfos)
  9593. //
  9594. // if res.Infcode == 0 {
  9595. // his := models.VMHisPatient{
  9596. // Status: 1,
  9597. // Ctime: time.Now().Unix(),
  9598. // Mtime: time.Now().Unix(),
  9599. // PsnNo: res.Output.Baseinfo.PsnNo,
  9600. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9601. // Certno: res.Output.Baseinfo.Certno,
  9602. // PsnName: res.Output.Baseinfo.PsnName,
  9603. // Gend: res.Output.Baseinfo.Gend,
  9604. // Naty: res.Output.Baseinfo.Naty,
  9605. // Brdy: res.Output.Baseinfo.Brdy,
  9606. // Age: res.Output.Baseinfo.Age,
  9607. // Iinfo: infoStr,
  9608. // Idetinfo: idetinfoStr,
  9609. // PatientId: patient.ID,
  9610. // RecordDate: theTime.Unix(),
  9611. // UserOrgId: adminInfo.CurrentOrgId,
  9612. // AdminUserId: adminInfo.AdminUser.Id,
  9613. // IsReturn: 1,
  9614. // }
  9615. //
  9616. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9617. // //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")
  9618. // //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")
  9619. //
  9620. // //var dat map[string]interface{}
  9621. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9622. // // fmt.Println(dat)
  9623. // //} else {
  9624. // // fmt.Println(err)
  9625. // //}
  9626. //
  9627. // var dat2 map[string]interface{}
  9628. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9629. // fmt.Println(dat2)
  9630. // } else {
  9631. // fmt.Println(err)
  9632. // }
  9633. //
  9634. // } else {
  9635. // adminUser := c.GetAdminUserInfo()
  9636. // errlog := &models.HisOrderError{
  9637. // UserOrgId: adminUser.CurrentOrgId,
  9638. // Ctime: time.Now().Unix(),
  9639. // Mtime: time.Now().Unix(),
  9640. // ErrMsg: res.ErrMsg,
  9641. // Status: 1,
  9642. // PatientId: id,
  9643. // RecordTime: recordDateTime,
  9644. // Stage: 1,
  9645. // }
  9646. // service.CreateErrMsgLog(errlog)
  9647. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9648. // return
  9649. // }
  9650. // }
  9651. //
  9652. //}
  9653. //func (c *HisApiController) GetUploadDiag() {
  9654. // id, _ := c.GetInt64("id")
  9655. // record_time := c.GetString("record_time")
  9656. //
  9657. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9658. // sick_type, _ := c.GetInt64("sick_type")
  9659. // reg_type, _ := c.GetInt64("reg_type")
  9660. //
  9661. // timeLayout := "2006-01-02"
  9662. // loc, _ := time.LoadLocation("Local")
  9663. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9664. // if err != nil {
  9665. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9666. // return
  9667. // }
  9668. //
  9669. // var patientPrescription models.HisPrescriptionInfo
  9670. // recordDateTime := theTime.Unix()
  9671. // adminInfo := c.GetAdminUserInfo()
  9672. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9673. //
  9674. // if patientPrescription.ID == 0 {
  9675. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9676. // }
  9677. //
  9678. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9679. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9680. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9681. // sickConfig, _ := service.FindSickById(sick_type)
  9682. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9683. //
  9684. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9685. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9686. // "&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 +
  9687. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9688. // resp2, requestErr2 := http.Get(api2)
  9689. // if requestErr2 != nil {
  9690. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9691. // return
  9692. // }
  9693. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9694. // if ioErr2 != nil {
  9695. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9697. // return
  9698. // }
  9699. // var respJSON2 map[string]interface{}
  9700. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9701. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9702. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9703. // return
  9704. // }
  9705. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9706. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9707. //
  9708. // var res2 ResultSix
  9709. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9710. // utils.ErrorLog("解析失败:%v", err)
  9711. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9712. // return
  9713. // }
  9714. // if res2.Infcode != 0 {
  9715. // adminUser := c.GetAdminUserInfo()
  9716. // errlog := &models.HisOrderError{
  9717. // UserOrgId: adminUser.CurrentOrgId,
  9718. // Ctime: time.Now().Unix(),
  9719. // Mtime: time.Now().Unix(),
  9720. // ErrMsg: res2.ErrMsg,
  9721. // Status: 1,
  9722. // PatientId: id,
  9723. // RecordTime: recordDateTime,
  9724. // Stage: 3,
  9725. // }
  9726. // service.CreateErrMsgLog(errlog)
  9727. //
  9728. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9729. // return
  9730. // }
  9731. //
  9732. // c.ServeSuccessJSON(map[string]interface{}{
  9733. // "msg": "上传成功",
  9734. // })
  9735. //
  9736. //}
  9737. type QueryResult struct {
  9738. ID int64
  9739. Name string
  9740. Code string
  9741. List_type_code string
  9742. }
  9743. func (c *HisApiController) GetCheckCode() {
  9744. ids_str := c.GetString("ids")
  9745. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9746. ids_arr := strings.Split(ids_str, ",")
  9747. var queryResult []QueryResult
  9748. ids := make([]int64, 0)
  9749. for _, item := range ids_arr {
  9750. id, _ := strconv.ParseInt(item, 10, 64)
  9751. ids = append(ids, id)
  9752. }
  9753. if record_type == 1 {
  9754. drugs, _ := service.GetBatchDrugList(ids)
  9755. for _, item := range drugs {
  9756. result := QueryResult{
  9757. ID: item.ID,
  9758. Name: item.DrugName,
  9759. Code: item.MedicalInsuranceNumber,
  9760. List_type_code: "101",
  9761. }
  9762. queryResult = append(queryResult, result)
  9763. }
  9764. } else if record_type == 2 {
  9765. goods, _ := service.GetBatchGoodInformationList(ids)
  9766. for _, item := range goods {
  9767. result := QueryResult{
  9768. ID: item.ID,
  9769. Name: item.GoodName,
  9770. Code: item.MedicalInsuranceNumber,
  9771. List_type_code: "301",
  9772. }
  9773. queryResult = append(queryResult, result)
  9774. }
  9775. } else if record_type == 3 {
  9776. projects, _ := service.GetBathchMyPorjecgList(ids)
  9777. for _, item := range projects {
  9778. result := QueryResult{
  9779. ID: item.ID,
  9780. Name: item.ProjectName,
  9781. Code: item.MedicalCode,
  9782. List_type_code: "201",
  9783. }
  9784. queryResult = append(queryResult, result)
  9785. }
  9786. }
  9787. admin_user_id, _ := c.GetInt64("admin_user_id")
  9788. adminUser := c.GetAdminUserInfo()
  9789. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9790. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9791. var user_name string
  9792. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9793. if role.ID == 0 {
  9794. user_name = "xxx"
  9795. } else {
  9796. user_name = role.UserName
  9797. }
  9798. baseParams := &models.BaseParams{
  9799. SecretKey: miConfig.SecretKey,
  9800. FixmedinsCode: miConfig.Code,
  9801. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9802. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9803. OrgName: miConfig.OrgName,
  9804. Doctor: user_name,
  9805. }
  9806. if config.IsOpen == 1 {
  9807. for _, item := range queryResult {
  9808. var result string
  9809. if record_type == 1 {
  9810. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9811. } else if record_type == 2 {
  9812. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9813. } else if record_type == 3 {
  9814. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9815. }
  9816. var dat map[string]interface{}
  9817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9818. fmt.Println(dat)
  9819. } else {
  9820. fmt.Println(err)
  9821. }
  9822. userJSONBytes, _ := json.Marshal(dat)
  9823. var res ResultSix
  9824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9825. utils.ErrorLog("解析失败:%v", err)
  9826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9827. return
  9828. }
  9829. if res.Infcode == 0 {
  9830. if record_type == 1 {
  9831. service.UpdateBaseDrugById(item.ID)
  9832. } else if record_type == 2 {
  9833. service.UpdateGoodInformaitonByDetail(item.ID)
  9834. } else if record_type == 3 {
  9835. service.UpdateProjectById(item.ID)
  9836. }
  9837. c.ServeSuccessJSON(map[string]interface{}{
  9838. "failed_code": 0,
  9839. "msg": "目录对照成功",
  9840. })
  9841. } else {
  9842. c.ServeSuccessJSON(map[string]interface{}{
  9843. "failed_code": -10,
  9844. "msg": res.ErrMsg,
  9845. })
  9846. }
  9847. }
  9848. }
  9849. }
  9850. func (c *HisApiController) UnCheckCode() {
  9851. ids_str := c.GetString("ids")
  9852. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9853. admin_user_id, _ := c.GetInt64("admin_user_id")
  9854. ids_arr := strings.Split(ids_str, ",")
  9855. var queryResult []QueryResult
  9856. ids := make([]int64, 0)
  9857. for _, item := range ids_arr {
  9858. id, _ := strconv.ParseInt(item, 10, 64)
  9859. ids = append(ids, id)
  9860. }
  9861. if record_type == 1 {
  9862. drugs, _ := service.GetBatchDrugList(ids)
  9863. for _, item := range drugs {
  9864. result := QueryResult{
  9865. ID: item.ID,
  9866. Name: item.DrugName,
  9867. Code: item.MedicalInsuranceNumber,
  9868. List_type_code: "101",
  9869. }
  9870. queryResult = append(queryResult, result)
  9871. }
  9872. } else if record_type == 2 {
  9873. goods, _ := service.GetBatchGoodInformationList(ids)
  9874. for _, item := range goods {
  9875. result := QueryResult{
  9876. ID: item.ID,
  9877. Name: item.GoodName,
  9878. Code: item.MedicalInsuranceNumber,
  9879. List_type_code: "301",
  9880. }
  9881. queryResult = append(queryResult, result)
  9882. }
  9883. } else if record_type == 3 {
  9884. projects, _ := service.GetBathchMyPorjecgList(ids)
  9885. for _, item := range projects {
  9886. result := QueryResult{
  9887. ID: item.ID,
  9888. Name: item.ProjectName,
  9889. Code: item.MedicalCode,
  9890. List_type_code: "201",
  9891. }
  9892. queryResult = append(queryResult, result)
  9893. }
  9894. }
  9895. adminUser := c.GetAdminUserInfo()
  9896. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9897. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9898. var user_name string
  9899. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9900. if role.ID == 0 {
  9901. user_name = "xxx"
  9902. } else {
  9903. user_name = role.UserName
  9904. }
  9905. baseParams := &models.BaseParams{
  9906. SecretKey: miConfig.SecretKey,
  9907. FixmedinsCode: miConfig.Code,
  9908. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9909. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9910. OrgName: miConfig.OrgName,
  9911. Doctor: user_name,
  9912. }
  9913. if config.IsOpen == 1 {
  9914. for _, item := range queryResult {
  9915. var result string
  9916. if record_type == 1 {
  9917. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9918. } else if record_type == 2 {
  9919. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9920. } else if record_type == 3 {
  9921. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9922. }
  9923. var dat2 map[string]interface{}
  9924. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9925. fmt.Println(dat2)
  9926. } else {
  9927. fmt.Println(err)
  9928. }
  9929. userJSONBytes, _ := json.Marshal(dat2)
  9930. var res ResultSix
  9931. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9932. utils.ErrorLog("解析失败:%v", err)
  9933. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9934. return
  9935. }
  9936. if res.Infcode == 0 {
  9937. if record_type == 1 {
  9938. service.UpdateDrugByIdDetail(item.ID)
  9939. } else if record_type == 2 {
  9940. service.UpdateGoodInfoById(item.ID)
  9941. } else if record_type == 3 {
  9942. service.UpdateMyProjectById(item.ID)
  9943. }
  9944. c.ServeSuccessJSON(map[string]interface{}{
  9945. "failed_code": 0,
  9946. "msg": "撤销目录对照成功",
  9947. })
  9948. } else {
  9949. c.ServeSuccessJSON(map[string]interface{}{
  9950. "failed_code": -10,
  9951. "msg": res.ErrMsg,
  9952. })
  9953. }
  9954. }
  9955. }
  9956. }
  9957. func (c *HisApiController) GetPatientInfo() {
  9958. id_card_no := c.GetString("id_card_no")
  9959. admin_user_id, _ := c.GetInt64("admin_user_id")
  9960. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9961. if patient.ID == 0 {
  9962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9963. return
  9964. }
  9965. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9966. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9967. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9968. if config.IsOpen == 1 {
  9969. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9970. var dat map[string]interface{}
  9971. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9972. fmt.Println(dat)
  9973. } else {
  9974. fmt.Println(err)
  9975. }
  9976. userJSONBytes, _ := json.Marshal(dat)
  9977. var res ResultTwo
  9978. var res10265 ResultTwo10265
  9979. if miConfig.Code == "H15049901371" {
  9980. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9981. utils.ErrorLog("解析失败:%v", err)
  9982. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9983. return
  9984. }
  9985. res.ErrMsg = res10265.ErrMsg
  9986. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9987. res.Infcode = infocode
  9988. res.Output = res10265.Output
  9989. res.InfRefmsgid = res10265.InfRefmsgid
  9990. } else {
  9991. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9992. utils.ErrorLog("解析失败:%v", err)
  9993. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9994. return
  9995. }
  9996. }
  9997. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9998. // utils.ErrorLog("解析失败:%v", err)
  9999. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10000. // return
  10001. //}
  10002. if res.Infcode != 0 {
  10003. c.ServeSuccessJSON(map[string]interface{}{
  10004. "failed_code": -10,
  10005. "msg": res.ErrMsg,
  10006. })
  10007. } else {
  10008. c.ServeSuccessJSON(map[string]interface{}{
  10009. "failed_code": 0,
  10010. "info": res,
  10011. })
  10012. }
  10013. }
  10014. }
  10015. func (c *HisApiController) PsnPutOnRecord() {
  10016. record_type, _ := c.GetInt64("type")
  10017. patient_id, _ := c.GetInt64("patient_id")
  10018. admin_user_id, _ := c.GetInt64("admin_user_id")
  10019. start_time := c.GetString("start_time")
  10020. end_time := c.GetString("end_time")
  10021. adminUser := c.GetAdminUserInfo()
  10022. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10023. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10024. var patients []*models.Patients
  10025. if record_type == 1 { //全部备案
  10026. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  10027. patients = append(patients, patient...)
  10028. } else { //单个备案
  10029. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10030. patients = append(patients, patient)
  10031. }
  10032. var user_name string
  10033. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10034. if role.ID == 0 {
  10035. user_name = "xxx"
  10036. } else {
  10037. user_name = role.UserName
  10038. }
  10039. if config.IsOpen == 1 {
  10040. for _, item := range patients {
  10041. 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
  10042. resp, requestErr := http.Get(api)
  10043. if requestErr != nil {
  10044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10045. return
  10046. }
  10047. defer resp.Body.Close()
  10048. body, ioErr := ioutil.ReadAll(resp.Body)
  10049. if ioErr != nil {
  10050. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10052. return
  10053. }
  10054. var respJSON map[string]interface{}
  10055. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10056. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10057. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10058. return
  10059. }
  10060. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10061. userJSONBytes, _ := json.Marshal(userJSON)
  10062. var res ResultTwo
  10063. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10064. utils.ErrorLog("解析失败:%v", err)
  10065. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10066. return
  10067. }
  10068. if res.Infcode == 0 {
  10069. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  10070. var dat map[string]interface{}
  10071. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10072. fmt.Println(dat)
  10073. } else {
  10074. fmt.Println(err)
  10075. }
  10076. userJSONBytes, _ := json.Marshal(dat)
  10077. var res2 ResultThirteen
  10078. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10079. utils.ErrorLog("解析失败:%v", err)
  10080. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10081. return
  10082. }
  10083. if res2.Infcode == 0 {
  10084. psnResult := &models.GdybPsnRecord{
  10085. UserOrgId: adminUser.CurrentOrgId,
  10086. PatientId: item.ID,
  10087. PsnNo: res.Output.Baseinfo.PsnNo,
  10088. Ctime: time.Now().Unix(),
  10089. Mtime: time.Now().Unix(),
  10090. Status: 1,
  10091. IsCancel: 1,
  10092. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10093. }
  10094. service.CreatePsnRecord(psnResult)
  10095. } else {
  10096. c.ServeSuccessJSON(map[string]interface{}{
  10097. "failed_code": -10,
  10098. "msg": res2.ErrMsg,
  10099. })
  10100. return
  10101. }
  10102. }
  10103. }
  10104. }
  10105. }
  10106. func (c *HisApiController) PsnUnPutOnRecord() {
  10107. id, _ := c.GetInt64("id")
  10108. //record_type, _ := c.GetInt64("type")
  10109. admin_user_id, _ := c.GetInt64("admin_user_id")
  10110. adminUser := c.GetAdminUserInfo()
  10111. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10112. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10113. var user_name string
  10114. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10115. if role.ID == 0 {
  10116. user_name = "xxx"
  10117. } else {
  10118. user_name = role.UserName
  10119. }
  10120. psn_record, _ := service.GetPsnRecordById(id)
  10121. if psn_record.ID == 0 {
  10122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10123. return
  10124. }
  10125. if config.IsOpen == 1 {
  10126. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10127. var dat map[string]interface{}
  10128. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10129. fmt.Println(dat)
  10130. } else {
  10131. fmt.Println(err)
  10132. }
  10133. userJSONBytes, _ := json.Marshal(dat)
  10134. var res ResultFourteen
  10135. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10136. utils.ErrorLog("解析失败:%v", err)
  10137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10138. return
  10139. }
  10140. if res.Infcode == 0 {
  10141. psn_record.IsCancel = 2
  10142. service.CreatePsnRecord(&psn_record)
  10143. } else {
  10144. c.ServeSuccessJSON(map[string]interface{}{
  10145. "failed_code": -10,
  10146. "msg": res.ErrMsg,
  10147. })
  10148. return
  10149. }
  10150. }
  10151. }
  10152. func (c *HisApiController) PsnPutNCDSOnRecord() {
  10153. patient_id, _ := c.GetInt64("patient_id")
  10154. insutype_two := c.GetString("insutype")
  10155. psn_no := c.GetString("psn_no")
  10156. doctor_id, _ := c.GetInt64("doctor_id")
  10157. sick_id, _ := c.GetInt64("sick_id")
  10158. department_id, _ := c.GetInt64("department_id")
  10159. start_time := c.GetString("start_time")
  10160. end_time := c.GetString("end_time")
  10161. check_time := c.GetString("check_time")
  10162. adminUser := c.GetAdminUserInfo()
  10163. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  10164. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10165. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10166. sick, _ := service.FindSickById(sick_id)
  10167. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10168. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  10169. var res ResultTwo
  10170. var res10265 ResultTwo10265
  10171. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10172. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  10173. api := "http://192.168.2.110:9532/" + "hbyb/1101?cert_no=" + "" +
  10174. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  10175. "&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
  10176. resp, requestErr := http.Get(api)
  10177. if requestErr != nil {
  10178. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10179. return
  10180. }
  10181. body, ioErr := ioutil.ReadAll(resp.Body)
  10182. if ioErr != nil {
  10183. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  10184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10185. return
  10186. }
  10187. var respJSON map[string]interface{}
  10188. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  10189. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  10190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10191. return
  10192. }
  10193. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  10194. result, _ := json.Marshal(respJSON)
  10195. fmt.Println("log")
  10196. fmt.Println(string(result))
  10197. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10198. utils.ErrorLog("解析失败:%v", err)
  10199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10200. return
  10201. }
  10202. res.ErrMsg = res10265.ErrMsg
  10203. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10204. res.Infcode = infocode
  10205. res.Output = res10265.Output
  10206. res.InfRefmsgid = res10265.InfRefmsgid
  10207. } else {
  10208. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10209. if miConfig.Code == "H15049901371" {
  10210. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10211. utils.ErrorLog("解析失败:%v", err)
  10212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10213. return
  10214. }
  10215. res.ErrMsg = res10265.ErrMsg
  10216. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10217. res.Infcode = infocode
  10218. res.Output = res10265.Output
  10219. res.InfRefmsgid = res10265.InfRefmsgid
  10220. } else {
  10221. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10222. utils.ErrorLog("解析失败:%v", err)
  10223. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10224. return
  10225. }
  10226. }
  10227. }
  10228. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10229. infoStr := string(Iinfos)
  10230. var rf []*ResultFive
  10231. json.Unmarshal([]byte(infoStr), &rf)
  10232. var insuplc_admdvs string
  10233. var insutype string
  10234. var is390 int = 0
  10235. var is310 int = 0
  10236. var insutypes []*ResultFive
  10237. for _, item := range rf {
  10238. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10239. insutypes = append(insutypes, item)
  10240. }
  10241. }
  10242. if len(insutypes) == 1 {
  10243. insutype = insutypes[0].Insutype
  10244. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10245. } else {
  10246. for _, i := range insutypes {
  10247. if i.Insutype == "390" {
  10248. is390 = 1
  10249. }
  10250. if i.Insutype == "310" {
  10251. is310 = 1
  10252. }
  10253. }
  10254. }
  10255. if is390 == 1 {
  10256. insutype = "390"
  10257. }
  10258. if is310 == 1 {
  10259. insutype = "310"
  10260. }
  10261. if len(insutypes) == 2 {
  10262. insutype = insutype_two
  10263. }
  10264. if len(insutypes) == 0 {
  10265. insutype = "310"
  10266. }
  10267. insutype = insutype_two
  10268. fmt.Println(insutype)
  10269. for _, item := range rf {
  10270. fmt.Println(item.Insutype)
  10271. fmt.Println(insutype)
  10272. if item.Insutype == insutype {
  10273. fmt.Println(item.Insutype)
  10274. fmt.Println(insutype)
  10275. insuplc_admdvs = item.InsuplcAdmdvs
  10276. }
  10277. }
  10278. fmt.Println(insuplc_admdvs)
  10279. var res2 ResultThirteen
  10280. var res10265_2 ResultThirteen10265
  10281. if config.IsOpen == 1 {
  10282. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10283. } else {
  10284. 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)
  10285. var dat map[string]interface{}
  10286. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10287. fmt.Println(dat)
  10288. } else {
  10289. fmt.Println(err)
  10290. }
  10291. userJSONBytes, _ := json.Marshal(dat)
  10292. if miConfig.Code == "H15049901371" {
  10293. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10294. utils.ErrorLog("解析失败:%v", err)
  10295. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10296. return
  10297. }
  10298. res2.ErrMsg = res10265_2.ErrMsg
  10299. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10300. res2.Infcode = infocode
  10301. res2.Output = res10265_2.Output
  10302. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10303. } else {
  10304. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10305. utils.ErrorLog("解析失败:%v", err)
  10306. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10307. return
  10308. }
  10309. }
  10310. }
  10311. if res2.Infcode == 0 {
  10312. psnResult := &models.GdybPsnNcdsRecord{
  10313. UserOrgId: adminUser.CurrentOrgId,
  10314. PatientId: patient.ID,
  10315. PsnNo: psn_no,
  10316. DoctorId: doctor.AdminUserId,
  10317. DepartmentId: department_id,
  10318. SickType: sick_id,
  10319. Insutype: insutype,
  10320. Ctime: time.Now().Unix(),
  10321. Mtime: time.Now().Unix(),
  10322. Status: 1,
  10323. IsCancel: 1,
  10324. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10325. }
  10326. service.CreatePsnNCDSRecord(psnResult)
  10327. c.ServeSuccessJSON(map[string]interface{}{
  10328. "failed_code": 0,
  10329. "msg": "备案成功",
  10330. "result": psnResult,
  10331. })
  10332. } else {
  10333. c.ServeSuccessJSON(map[string]interface{}{
  10334. "failed_code": -10,
  10335. "msg": res2.ErrMsg,
  10336. })
  10337. return
  10338. }
  10339. }
  10340. }
  10341. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10342. id, _ := c.GetInt64("id")
  10343. admin_user_id, _ := c.GetInt64("admin_user_id")
  10344. adminUser := c.GetAdminUserInfo()
  10345. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10346. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10347. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10348. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10349. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10350. //var user_name string
  10351. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10352. //if role.ID == 0 {
  10353. // user_name = "xxx"
  10354. //} else {
  10355. // user_name = role.UserName
  10356. //}
  10357. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10358. if psn_record.ID == 0 {
  10359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10360. return
  10361. }
  10362. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10363. var res ResultTwo
  10364. var res10265 ResultTwo10265
  10365. if miConfig.Code == "H15049901371" {
  10366. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10367. utils.ErrorLog("解析失败:%v", err)
  10368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10369. return
  10370. }
  10371. res.ErrMsg = res10265.ErrMsg
  10372. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10373. res.Infcode = infocode
  10374. res.Output = res10265.Output
  10375. res.InfRefmsgid = res10265.InfRefmsgid
  10376. } else {
  10377. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10378. utils.ErrorLog("解析失败:%v", err)
  10379. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10380. return
  10381. }
  10382. }
  10383. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10384. infoStr := string(Iinfos)
  10385. var rf []*ResultFive
  10386. json.Unmarshal([]byte(infoStr), &rf)
  10387. var insuplc_admdvs string
  10388. var insutype string
  10389. var is390 int = 0
  10390. var is310 int = 0
  10391. var insutypes []*ResultFive
  10392. for _, item := range rf {
  10393. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10394. insutypes = append(insutypes, item)
  10395. }
  10396. }
  10397. if len(insutypes) == 1 {
  10398. insutype = insutypes[0].Insutype
  10399. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10400. } else {
  10401. for _, i := range insutypes {
  10402. if i.Insutype == "390" {
  10403. is390 = 1
  10404. }
  10405. if i.Insutype == "310" {
  10406. is310 = 1
  10407. }
  10408. }
  10409. }
  10410. if is390 == 1 {
  10411. insutype = "390"
  10412. }
  10413. if is310 == 1 {
  10414. insutype = "310"
  10415. }
  10416. if len(insutypes) == 0 {
  10417. insutype = "310"
  10418. }
  10419. insutype = psn_record.Insutype
  10420. for _, item := range rf {
  10421. if item.Insutype == insutype {
  10422. insuplc_admdvs = item.InsuplcAdmdvs
  10423. }
  10424. }
  10425. if config.IsOpen == 1 {
  10426. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10427. var dat map[string]interface{}
  10428. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10429. fmt.Println(dat)
  10430. } else {
  10431. fmt.Println(err)
  10432. }
  10433. userJSONBytes, _ := json.Marshal(dat)
  10434. var res ResultFourteen
  10435. var res10265 ResultFourteen10265
  10436. if miConfig.Code == "H15049901371" {
  10437. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10438. utils.ErrorLog("解析失败:%v", err)
  10439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10440. return
  10441. }
  10442. res.ErrMsg = res10265.ErrMsg
  10443. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10444. res.Infcode = infocode
  10445. res.Output = res10265.Output
  10446. res.InfRefmsgid = res10265.InfRefmsgid
  10447. } else {
  10448. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10449. utils.ErrorLog("解析失败:%v", err)
  10450. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10451. return
  10452. }
  10453. }
  10454. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10455. // utils.ErrorLog("解析失败:%v", err)
  10456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10457. // return
  10458. //}
  10459. if res.Infcode == 0 {
  10460. psn_record.IsCancel = 2
  10461. service.CreatePsnNCDSRecord(&psn_record)
  10462. c.ServeSuccessJSON(map[string]interface{}{
  10463. "failed_code": 0,
  10464. "msg": "撤销备案成功",
  10465. })
  10466. } else {
  10467. c.ServeSuccessJSON(map[string]interface{}{
  10468. "failed_code": -10,
  10469. "msg": res.ErrMsg,
  10470. })
  10471. return
  10472. }
  10473. }
  10474. }
  10475. func (c *HisApiController) TestTest() {
  10476. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10477. fmt.Println(patient.Iinfo)
  10478. }
  10479. type CustomData struct {
  10480. MsgId string
  10481. PsnNo string
  10482. Info string
  10483. }
  10484. func (c *HisApiController) ReversalData() {
  10485. var customData []*CustomData
  10486. custom := &CustomData{
  10487. MsgId: "H44022900158202103301714472004",
  10488. PsnNo: "44020000001101329945",
  10489. Info: "2207",
  10490. }
  10491. customData = append(customData, custom)
  10492. custom1 := &CustomData{
  10493. MsgId: "H4402290015820210330172057803",
  10494. PsnNo: "44020000001101161813",
  10495. Info: "2207",
  10496. }
  10497. customData = append(customData, custom1)
  10498. custom2 := &CustomData{
  10499. MsgId: "H44022900158202103301705198813",
  10500. PsnNo: "44190000133097375417",
  10501. Info: "2207",
  10502. }
  10503. customData = append(customData, custom2)
  10504. custom3 := &CustomData{
  10505. MsgId: "H44022900158202103301715524756",
  10506. PsnNo: "44020000001100187221",
  10507. Info: "2207",
  10508. }
  10509. customData = append(customData, custom3)
  10510. custom4 := &CustomData{
  10511. MsgId: "H44022900158202103301730376224",
  10512. PsnNo: "44020000001101959155",
  10513. Info: "2207",
  10514. }
  10515. customData = append(customData, custom4)
  10516. custom5 := &CustomData{
  10517. MsgId: "H44022900158202103301748008725",
  10518. PsnNo: "44020000001104246641",
  10519. Info: "2207",
  10520. }
  10521. customData = append(customData, custom5)
  10522. custom6 := &CustomData{
  10523. MsgId: "H44022900158202103301718096755",
  10524. PsnNo: "44020000001102211860",
  10525. Info: "2207",
  10526. }
  10527. customData = append(customData, custom6)
  10528. custom7 := &CustomData{
  10529. MsgId: "H44022900158202103301736551640",
  10530. PsnNo: "44020000001102687718",
  10531. Info: "2207",
  10532. }
  10533. customData = append(customData, custom7)
  10534. custom8 := &CustomData{
  10535. MsgId: "H44022900158202103301743097676",
  10536. PsnNo: "44020000001102127785",
  10537. Info: "2207",
  10538. }
  10539. customData = append(customData, custom8)
  10540. custom9 := &CustomData{
  10541. MsgId: "H44022900158202103301712304203",
  10542. PsnNo: "44020000001101518097",
  10543. Info: "2207",
  10544. }
  10545. customData = append(customData, custom9)
  10546. custom10 := &CustomData{
  10547. MsgId: "H44022900158202103301738448785",
  10548. PsnNo: "44020000001100500813",
  10549. Info: "2207",
  10550. }
  10551. customData = append(customData, custom10)
  10552. custom11 := &CustomData{
  10553. MsgId: "H44022900158202103301732455843",
  10554. PsnNo: "44020000001102690557",
  10555. Info: "2207",
  10556. }
  10557. customData = append(customData, custom11)
  10558. custom12 := &CustomData{
  10559. MsgId: "H44022900158202103301745421708",
  10560. PsnNo: "44020000001102211928",
  10561. Info: "2207",
  10562. }
  10563. customData = append(customData, custom12)
  10564. custom1212 := &CustomData{
  10565. MsgId: "H440229001582021033017351627",
  10566. PsnNo: "44020000001102481733",
  10567. Info: "2207",
  10568. }
  10569. customData = append(customData, custom1212)
  10570. custom13 := &CustomData{
  10571. MsgId: "H44022900158202103301740327951",
  10572. PsnNo: "44020000001103174866",
  10573. Info: "2207",
  10574. }
  10575. customData = append(customData, custom13)
  10576. custom14 := &CustomData{
  10577. MsgId: "H4402290015820210330174922668",
  10578. PsnNo: "44020000001102927272",
  10579. Info: "2207",
  10580. }
  10581. customData = append(customData, custom14)
  10582. custom15 := &CustomData{
  10583. MsgId: "H44022900158202103301752362273",
  10584. PsnNo: "44020000001102942890",
  10585. Info: "2207",
  10586. }
  10587. customData = append(customData, custom15)
  10588. custom16 := &CustomData{
  10589. MsgId: "H44022900158202103301751082917",
  10590. PsnNo: "44020000001101662162",
  10591. Info: "2207",
  10592. }
  10593. customData = append(customData, custom16)
  10594. custom17 := &CustomData{
  10595. MsgId: "H44022900158202103301754147728",
  10596. PsnNo: "44020000000229014511",
  10597. Info: "2207",
  10598. }
  10599. customData = append(customData, custom17)
  10600. adminUser := c.GetAdminUserInfo()
  10601. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10602. for _, item := range customData {
  10603. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10604. fmt.Println(result)
  10605. }
  10606. }
  10607. //func (c *HisApiController) GetAllopatry() {
  10608. // year := c.GetString("year")
  10609. // month := c.GetString("month")
  10610. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10611. // adminUser := c.GetAdminUserInfo()
  10612. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10613. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10614. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10615. //
  10616. // var dat map[string]interface{}
  10617. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10618. // fmt.Println(dat)
  10619. // } else {
  10620. // fmt.Println(err)
  10621. // }
  10622. // userJSONBytes, _ := json.Marshal(dat)
  10623. // var res models.Result9001
  10624. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10625. // utils.ErrorLog("解析失败:%v", err)
  10626. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10627. // return
  10628. // }
  10629. //
  10630. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10631. // var dat2 map[string]interface{}
  10632. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10633. // fmt.Println(dat)
  10634. // } else {
  10635. // fmt.Println(err)
  10636. // }
  10637. // userJSONBytes2, _ := json.Marshal(dat2)
  10638. // var res2 models.Result3260
  10639. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10640. // utils.ErrorLog("解析失败:%v", err)
  10641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10642. // return
  10643. // }
  10644. // if res2.Infcode == 0 {
  10645. // c.ServeSuccessJSON(map[string]interface{}{
  10646. // "list": res2.Output.Data,
  10647. // })
  10648. // return
  10649. // } else {
  10650. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10651. // return
  10652. // }
  10653. //
  10654. //}
  10655. //func (c *HisApiController) ComfirmAllopatry() {
  10656. // year := c.GetString("year")
  10657. // month := c.GetString("month")
  10658. // admin_user_id, _ := c.GetInt64("admin_user_id")
  10659. // adminUser := c.GetAdminUserInfo()
  10660. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10661. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10662. // result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10663. // var dat map[string]interface{}
  10664. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10665. // fmt.Println(dat)
  10666. // } else {
  10667. // fmt.Println(err)
  10668. // }
  10669. // userJSONBytes, _ := json.Marshal(dat)
  10670. // var res models.Result9001
  10671. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10672. // utils.ErrorLog("解析失败:%v", err)
  10673. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10674. // return
  10675. // }
  10676. //
  10677. // result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10678. // var dat2 map[string]interface{}
  10679. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10680. // fmt.Println(dat)
  10681. // } else {
  10682. // fmt.Println(err)
  10683. // }
  10684. // userJSONBytes2, _ := json.Marshal(dat2)
  10685. // var res2 models.Result3260
  10686. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10687. // utils.ErrorLog("解析失败:%v", err)
  10688. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10689. // return
  10690. // }
  10691. //
  10692. // if res2.Infcode == 0 {
  10693. // result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10694. // var dat map[string]interface{}
  10695. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10696. // fmt.Println(dat)
  10697. // } else {
  10698. // fmt.Println(err)
  10699. // }
  10700. // userJSONBytes, _ := json.Marshal(dat)
  10701. // var res3 models.Result3261
  10702. // if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10703. // utils.ErrorLog("解析失败:%v", err)
  10704. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10705. // return
  10706. // }
  10707. //
  10708. // if res3.Infcode == 0 {
  10709. // record := &models.HisYidiClearRecord{
  10710. // UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10711. // Ctime: time.Now().Unix(),
  10712. // Mtime: time.Now().Unix(),
  10713. // Status: 1,
  10714. // MsgId: msgId,
  10715. // }
  10716. // service.SaveClearRecord(record)
  10717. // c.ServeSuccessJSON(map[string]interface{}{
  10718. // "msg": "提取成功",
  10719. // })
  10720. // }
  10721. // }
  10722. //}
  10723. func (c *HisApiController) RefundAllopatry() {
  10724. year := c.GetString("year")
  10725. month := c.GetString("month")
  10726. id, _ := c.GetInt64("id")
  10727. admin_user_id, _ := c.GetInt64("admin_user_id")
  10728. adminUser := c.GetAdminUserInfo()
  10729. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10730. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10731. record, _ := service.GetClearRecordById(id)
  10732. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10733. var dat map[string]interface{}
  10734. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10735. fmt.Println(dat)
  10736. } else {
  10737. fmt.Println(err)
  10738. }
  10739. userJSONBytes, _ := json.Marshal(dat)
  10740. var empty ResultFourteen
  10741. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10742. utils.ErrorLog("解析失败:%v", err)
  10743. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10744. return
  10745. }
  10746. if empty.Infcode == 0 {
  10747. c.ServeSuccessJSON(map[string]interface{}{
  10748. "msg": "撤销成功",
  10749. })
  10750. return
  10751. }
  10752. }
  10753. func (c *HisApiController) ReversalOtherData() {
  10754. var customData []*CustomData
  10755. custom := &CustomData{
  10756. MsgId: "H44022900158202103301714472004",
  10757. PsnNo: "44020000001101329945",
  10758. Info: "2208",
  10759. }
  10760. customData = append(customData, custom)
  10761. custom1 := &CustomData{
  10762. MsgId: "H4402290015820210330172057803",
  10763. PsnNo: "44020000001101161813",
  10764. Info: "2208",
  10765. }
  10766. customData = append(customData, custom1)
  10767. custom2 := &CustomData{
  10768. MsgId: "H44022900158202103301705198813",
  10769. PsnNo: "44190000133097375417",
  10770. Info: "2208",
  10771. }
  10772. customData = append(customData, custom2)
  10773. custom3 := &CustomData{
  10774. MsgId: "H44022900158202103301715524756",
  10775. PsnNo: "44020000001100187221",
  10776. Info: "2208",
  10777. }
  10778. customData = append(customData, custom3)
  10779. custom4 := &CustomData{
  10780. MsgId: "H44022900158202103301730376224",
  10781. PsnNo: "44020000001101959155",
  10782. Info: "2208",
  10783. }
  10784. customData = append(customData, custom4)
  10785. custom5 := &CustomData{
  10786. MsgId: "H44022900158202103301748008725",
  10787. PsnNo: "44020000001104246641",
  10788. Info: "2208",
  10789. }
  10790. customData = append(customData, custom5)
  10791. custom6 := &CustomData{
  10792. MsgId: "H44022900158202103301718096755",
  10793. PsnNo: "44020000001102211860",
  10794. Info: "2208",
  10795. }
  10796. customData = append(customData, custom6)
  10797. custom7 := &CustomData{
  10798. MsgId: "H44022900158202103301736551640",
  10799. PsnNo: "44020000001102687718",
  10800. Info: "2208",
  10801. }
  10802. customData = append(customData, custom7)
  10803. custom8 := &CustomData{
  10804. MsgId: "H44022900158202103301743097676",
  10805. PsnNo: "44020000001102127785",
  10806. Info: "2208",
  10807. }
  10808. customData = append(customData, custom8)
  10809. custom9 := &CustomData{
  10810. MsgId: "H44022900158202103301712304203",
  10811. PsnNo: "44020000001101518097",
  10812. Info: "2208",
  10813. }
  10814. customData = append(customData, custom9)
  10815. custom10 := &CustomData{
  10816. MsgId: "H44022900158202103301738448785",
  10817. PsnNo: "44020000001100500813",
  10818. Info: "2208",
  10819. }
  10820. customData = append(customData, custom10)
  10821. custom11 := &CustomData{
  10822. MsgId: "H44022900158202103301732455843",
  10823. PsnNo: "44020000001102690557",
  10824. Info: "2208",
  10825. }
  10826. customData = append(customData, custom11)
  10827. custom12 := &CustomData{
  10828. MsgId: "H44022900158202103301745421708",
  10829. PsnNo: "44020000001102211928",
  10830. Info: "2208",
  10831. }
  10832. customData = append(customData, custom12)
  10833. custom1212 := &CustomData{
  10834. MsgId: "H440229001582021033017351627",
  10835. PsnNo: "44020000001102481733",
  10836. Info: "2208",
  10837. }
  10838. customData = append(customData, custom1212)
  10839. custom13 := &CustomData{
  10840. MsgId: "H44022900158202103301740327951",
  10841. PsnNo: "44020000001103174866",
  10842. Info: "2208",
  10843. }
  10844. customData = append(customData, custom13)
  10845. custom14 := &CustomData{
  10846. MsgId: "H4402290015820210330174922668",
  10847. PsnNo: "44020000001102927272",
  10848. Info: "2208",
  10849. }
  10850. customData = append(customData, custom14)
  10851. custom15 := &CustomData{
  10852. MsgId: "H44022900158202103301752362273",
  10853. PsnNo: "44020000001102942890",
  10854. Info: "2208",
  10855. }
  10856. customData = append(customData, custom15)
  10857. custom16 := &CustomData{
  10858. MsgId: "H44022900158202103301751082917",
  10859. PsnNo: "44020000001101662162",
  10860. Info: "2208",
  10861. }
  10862. customData = append(customData, custom16)
  10863. custom17 := &CustomData{
  10864. MsgId: "H44022900158202103301754147728",
  10865. PsnNo: "44020000000229014511",
  10866. Info: "2208",
  10867. }
  10868. customData = append(customData, custom17)
  10869. adminUser := c.GetAdminUserInfo()
  10870. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10871. for _, item := range customData {
  10872. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10873. fmt.Println(result)
  10874. }
  10875. }
  10876. func PathExists(path string) (bool, error) {
  10877. _, err := os.Stat(path)
  10878. if err == nil {
  10879. return true, nil
  10880. }
  10881. if os.IsNotExist(err) {
  10882. return false, nil
  10883. }
  10884. return false, err
  10885. }
  10886. //创建文件夹
  10887. func Mkdir(dir string) {
  10888. // 创建文件夹
  10889. exist, err := PathExists(dir)
  10890. if err != nil {
  10891. fmt.Println(err.Error())
  10892. } else {
  10893. if exist {
  10894. fmt.Println(dir + "文件夹已存在!")
  10895. } else {
  10896. // 文件夹名称,权限
  10897. err := os.Mkdir(dir, os.ModePerm)
  10898. if err != nil {
  10899. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10900. } else {
  10901. fmt.Println(dir + "文件夹创建成功!")
  10902. }
  10903. }
  10904. }
  10905. }
  10906. //压缩文件
  10907. func Zip(srcFile string, destZip string) error {
  10908. zipfile, err := os.Create(destZip)
  10909. if err != nil {
  10910. return err
  10911. }
  10912. defer zipfile.Close()
  10913. archive := zip.NewWriter(zipfile)
  10914. defer archive.Close()
  10915. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10916. if err != nil {
  10917. return err
  10918. }
  10919. header, err := zip.FileInfoHeader(info)
  10920. if err != nil {
  10921. return err
  10922. }
  10923. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10924. // header.Name = path
  10925. if info.IsDir() {
  10926. header.Name += "/"
  10927. } else {
  10928. header.Method = zip.Deflate
  10929. }
  10930. writer, err := archive.CreateHeader(header)
  10931. if err != nil {
  10932. return err
  10933. }
  10934. if !info.IsDir() {
  10935. file, err := os.Open(path)
  10936. if err != nil {
  10937. return err
  10938. }
  10939. defer file.Close()
  10940. _, err = io.Copy(writer, file)
  10941. }
  10942. return err
  10943. })
  10944. return err
  10945. }
  10946. func ReadFile(filePath string) []byte {
  10947. f, err := os.Open(filePath)
  10948. if err != nil {
  10949. fmt.Println("read file fail", err)
  10950. return nil
  10951. }
  10952. defer f.Close()
  10953. fd, err := ioutil.ReadAll(f)
  10954. if err != nil {
  10955. fmt.Println("read to fd fail", err)
  10956. return nil
  10957. }
  10958. return fd
  10959. }
  10960. func saveLog(result string, request string, infno string, desc string) {
  10961. org_id, _ := beego.AppConfig.Int64("org_id")
  10962. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10963. dir := miConfig.OrgName + "日志"
  10964. utils.Mkdir(dir)
  10965. month := time.Unix(1557042972, 0).Format("1")
  10966. year := time.Now().Format("2006")
  10967. month = time.Now().Format("01")
  10968. day := time.Now().Format("02")
  10969. hour := time.Now().Format("15")
  10970. min := time.Now().Format("04")
  10971. sec := time.Now().Format("05")
  10972. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10973. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10974. file_name := file + ".txt"
  10975. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10976. exist, _ := utils.PathExists(file_path)
  10977. if exist { //存在
  10978. fmt.Println("存在")
  10979. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10980. if err != nil {
  10981. fmt.Println("read fail")
  10982. }
  10983. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10984. n, _ := f.Seek(0, 2)
  10985. _, err = f.WriteAt([]byte(content), n)
  10986. } else { //不存在
  10987. fmt.Println("文件不存在,创建文件")
  10988. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10989. defer f.Close()
  10990. if err != nil {
  10991. } else {
  10992. _, err = f.Write([]byte("记录日志"))
  10993. }
  10994. }
  10995. }
  10996. type Charset string
  10997. const (
  10998. UTF8 = Charset("UTF-8")
  10999. GB18030 = Charset("GB18030")
  11000. )
  11001. func ConvertToString(src string, srcCode string, tagCode string) string {
  11002. srcCoder := mahonia.NewDecoder(srcCode)
  11003. srcResult := srcCoder.ConvertString(src)
  11004. tagCoder := mahonia.NewDecoder(tagCode)
  11005. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  11006. result := string(cdata)
  11007. return result
  11008. }
  11009. func (c *HisApiController) ReadEleCard() {
  11010. id_card_type, _ := c.GetInt64("id_card_type")
  11011. admin_user_id, _ := c.GetInt64("admin_user_id")
  11012. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  11013. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  11014. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  11015. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  11016. var api string
  11017. if miConfig.MdtrtareaAdmvs == "320921" {
  11018. api = "http://192.168.2.110:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  11019. "&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
  11020. fmt.Println(api)
  11021. } else {
  11022. 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 +
  11023. "&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)
  11024. }
  11025. resp, requestErr := http.Get(api)
  11026. if requestErr != nil {
  11027. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11028. return
  11029. }
  11030. body, ioErr := ioutil.ReadAll(resp.Body)
  11031. if ioErr != nil {
  11032. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  11033. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11034. return
  11035. }
  11036. var respJSON map[string]interface{}
  11037. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  11038. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  11039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11040. return
  11041. }
  11042. var status string
  11043. status = respJSON["data"].(map[string]interface{})["status"].(string)
  11044. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  11045. var token string
  11046. var res ResultTwo //1101结果
  11047. var res10265 ResultTwo10265 //1101结果
  11048. if status == "0" { //读卡成功
  11049. var card_info string //卡信息
  11050. var busi_card_info string
  11051. token = respJSON["data"].(map[string]interface{})["token"].(string)
  11052. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  11053. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  11054. fmt.Println(card_info)
  11055. fmt.Println(busi_card_info)
  11056. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  11057. result, _ := json.Marshal(respJSON)
  11058. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  11059. utils.ErrorLog("解析失败:%v", err)
  11060. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  11061. return
  11062. }
  11063. res.ErrMsg = res10265.ErrMsg
  11064. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  11065. res.Infcode = infocode
  11066. res.Output = res10265.Output
  11067. res.InfRefmsgid = res10265.InfRefmsgid
  11068. if res.Infcode == 0 {
  11069. c.ServeSuccessJSON(map[string]interface{}{
  11070. "number": token,
  11071. })
  11072. }
  11073. } else {
  11074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11075. return
  11076. }
  11077. } else { //读卡失败
  11078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  11079. return
  11080. }
  11081. }
  11082. func DeleteExtraSpaceTwo(s string) string {
  11083. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11084. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11085. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11086. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11087. s2 := make([]byte, len(s1)) //定义字符数组切片
  11088. copy(s2, s1) //将字符串复制到切片
  11089. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11090. for len(spc_index) > 0 { //找到适配项
  11091. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11092. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11093. }
  11094. return string(s2)
  11095. }
  11096. func Remove0000(s string) string {
  11097. str := make([]rune, 0, len(s))
  11098. for _, v := range []rune(s) {
  11099. if v == 0 {
  11100. continue
  11101. }
  11102. str = append(str, v)
  11103. }
  11104. return string(str)
  11105. }
  11106. func (c *HisApiController) GetELeCertInfo(code string, operator_id string, operator_name string) (string, string) {
  11107. DllDef := syscall.MustLoadDLL("HeaSecReadInfo.dll")
  11108. readCard := DllDef.MustFindProc("EcQuery")
  11109. pCardInfo := make([]byte, 8192)
  11110. pBusiCardInfo := make([]byte, 8192)
  11111. data := make(map[string]interface{})
  11112. //pData := make(map[string]interface{})
  11113. inputData := make(map[string]interface{})
  11114. inputData["orgId"] = code
  11115. inputData["businessType"] = "01101"
  11116. inputData["operatorId"] = operator_id
  11117. inputData["operatorName"] = operator_name
  11118. inputData["officeId"] = "001"
  11119. inputData["officeName"] = "血透室"
  11120. //
  11121. data["data"] = inputData
  11122. data["transType"] = "ec.query"
  11123. data["orgId"] = code
  11124. bytesData, _ := json.Marshal(data)
  11125. pCardInfo = bytesData
  11126. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&pCardInfo[0])), (uintptr)(unsafe.Pointer(&pBusiCardInfo[0])))
  11127. fmt.Println(ret2)
  11128. //fmt.Println(DeleteExtraSpace(string(bytesData)))
  11129. //fmt.Println(DeleteExtraSpace(string(pBusiCardInfo)))
  11130. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(bytesData)), "gbk", "utf-8"))
  11131. fmt.Println(":", ConvertToString(DeleteExtraSpace(string(pBusiCardInfo)), "gbk", "utf-8"))
  11132. if ret2 != 0 {
  11133. return "", ""
  11134. }
  11135. return DeleteExtraSpace(string(bytesData)), DeleteExtraSpace(string(pBusiCardInfo))
  11136. }
  11137. func DeleteExtraSpace(s string) string {
  11138. //删除字符串中的多余空格,有多个空格时,仅保留一个空格
  11139. s1 := strings.Replace(s, " ", " ", -1) //替换tab为空格
  11140. regstr := "\\s{2,}" //两个及两个以上空格的正则表达式
  11141. reg, _ := regexp.Compile(regstr) //编译正则表达式
  11142. s2 := make([]byte, len(s1)) //定义字符数组切片
  11143. copy(s2, s1) //将字符串复制到切片
  11144. spc_index := reg.FindStringIndex(string(s2)) //在字符串中搜索
  11145. for len(spc_index) > 0 { //找到适配项
  11146. s2 = append(s2[:spc_index[0]+1], s2[spc_index[1]:]...) //删除多余空格
  11147. spc_index = reg.FindStringIndex(string(s2)) //继续在字符串中搜索
  11148. }
  11149. return string(s2)
  11150. }