his_api_controller.go 437KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010
  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. "strconv"
  23. "strings"
  24. "syscall"
  25. "time"
  26. "unsafe"
  27. )
  28. type HisApiController struct {
  29. controllers.BaseAuthAPIController
  30. }
  31. func HisManagerApiRegistRouters() {
  32. //挂号
  33. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  34. //上传就诊信息-上传明细-结算
  35. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  36. //查询
  37. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  38. //对总账
  39. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  40. //对明细
  41. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  42. //退费,退明细
  43. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  44. //退号
  45. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  46. //退明细
  47. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  48. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  49. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  50. beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  51. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  52. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  53. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  54. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  55. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  56. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  57. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  58. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  59. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  60. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  61. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  62. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/settlelisthosptial/get", &HisApiController{}, "get:GetSettleListHospital")
  65. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  66. beego.Router("/api/insutype/check", &HisApiController{}, "get:CheckInsutype")
  67. beego.Router("/api/batchsettlelist/get", &HisApiController{}, "get:GetBatchSettleList")
  68. beego.Router("/api/psn/info", &HisApiController{}, "get:GetPsnNcdsInfo")
  69. beego.Router("/api/allopatry/get", &HisApiController{}, "get:GetAllopatry")
  70. beego.Router("/api/comfirmallopatry/post", &HisApiController{}, "post:ComfirmAllopatry")
  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. }
  78. func (c *HisApiController) Get9001() {
  79. adminUser := c.GetAdminUserInfo()
  80. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  81. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, 185)
  82. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  83. var dat map[string]interface{}
  84. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  85. fmt.Println(dat)
  86. } else {
  87. fmt.Println(err)
  88. }
  89. userJSONBytes, _ := json.Marshal(dat)
  90. var res models.Result9001
  91. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  92. utils.ErrorLog("解析失败:%v", err)
  93. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  94. return
  95. }
  96. }
  97. func (c *HisApiController) Check3101() {
  98. patient_id, _ := c.GetInt64("patient_id")
  99. his_patient_id, _ := c.GetInt64("his_patient_id")
  100. admin_user_id, _ := c.GetInt64("admin_user_id")
  101. adminUser := c.GetAdminUserInfo()
  102. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  103. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  104. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  105. record_time := c.GetString("record_time")
  106. trig_scen := c.GetString("trig_scen")
  107. timeLayout := "2006-01-02"
  108. loc, _ := time.LoadLocation("Local")
  109. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  110. if err != nil {
  111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  112. return
  113. }
  114. recordDateTime := theTime.Unix()
  115. var patientPrescription models.HisPrescriptionInfo
  116. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  117. if patientPrescription.ID == 0 {
  118. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  119. }
  120. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  121. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  122. //
  123. diagnosis_ids := strings.Split(patientPrescription.Diagnosis, ",")
  124. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  125. var pp models.PublicParams
  126. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  127. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  128. pp.FixmedinsName = miConfig.OrgName
  129. pp.FixmedinsCode = miConfig.Code
  130. pp.RequestUrl = miConfig.Url
  131. pp.Cainfo = miConfig.Cainfo
  132. pp.SecretKey = miConfig.SecretKey
  133. pp.AccessKey = miConfig.AccessKey
  134. pp.OpterName = roles.UserName
  135. var config []*models.HisXtDiagnoseConfig
  136. for _, item := range diagnosis_ids {
  137. id, _ := strconv.ParseInt(item, 10, 64)
  138. diagnosisConfig, _ := service.FindDiagnoseById(id)
  139. config = append(config, &diagnosisConfig)
  140. }
  141. var pd models.PatientDtos
  142. pd.PatnID = his.PsnNo
  143. pd.PatnName = his.Name
  144. pd.Gend = his.Gend
  145. pd.Brdy = his.Brdy
  146. pd.Poolarea = his.InsuplcAdmdvs
  147. pd.CurrMdtrtID = his.Number
  148. var fed models.FsiEncounterDtos
  149. fed.MdtrtID = his.Number
  150. fed.MedinsID = miConfig.Code
  151. fed.MedinsName = miConfig.OrgName
  152. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  153. fed.MedMdtrtType = "1"
  154. fed.MedinsType = "1"
  155. fed.MedinsLv = "11"
  156. tm := time.Unix(his.RecordDate, 0)
  157. s_tm := tm.Format("2006-01-02 15:04:05")
  158. fed.AdmDate = s_tm
  159. fed.DscgDate = s_tm
  160. fed.DscgMainDiseCodg = config[0].CountryCode
  161. fed.DscgMainDiseName = config[0].CountryContentName
  162. //诊断信息
  163. var fdds []*models.FsiDiagnoseDtos
  164. for index, item := range config {
  165. if index == 0 {
  166. var fdd models.FsiDiagnoseDtos
  167. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  168. fdd.InoutDiseType = "1"
  169. fdd.MaindiseFlag = "1"
  170. fdd.DiseDate = s_tm
  171. fdd.DiasSrtNo = "1"
  172. fdd.DiseName = item.CountryContentName
  173. fdd.DiseCodg = item.CountryCode
  174. fdds = append(fdds, &fdd)
  175. } else {
  176. var fdd models.FsiDiagnoseDtos
  177. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  178. fdd.InoutDiseType = "1"
  179. fdd.MaindiseFlag = "1"
  180. fdd.DiseDate = s_tm
  181. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  182. fdd.DiseName = item.CountryContentName
  183. fdd.DiseCodg = item.CountryCode
  184. fdds = append(fdds, &fdd)
  185. }
  186. }
  187. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  188. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  189. fed.AdmDeptName = department.Name
  190. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  191. fed.DscgDeptName = department.Name
  192. fed.MedMdtrtType = "1"
  193. fed.MedType = "11"
  194. //if his.Insutype == "390" {
  195. // fed.MedType = "1402"
  196. //} else {
  197. // fed.MedType = "9933"
  198. //}
  199. var orders []*models.FsiOrderDtos
  200. if trig_scen == "2" {
  201. //处方医嘱信息
  202. for _, item := range prescriptions {
  203. for _, subItem := range item.HisDoctorAdviceInfo {
  204. var order models.FsiOrderDtos
  205. order.RxID = strconv.FormatInt(item.ID, 10)
  206. order.Rxno = strconv.FormatInt(item.ID, 10)
  207. order.LongDrordFlag = "0"
  208. order.HilistType = "1"
  209. order.ChrgType = "1"
  210. order.DrordBhvr = "-"
  211. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  212. order.HosplistName = subItem.BaseDrugLib.DrugName
  213. order.HilistLv = "1"
  214. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  215. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  216. order.HosplistName = subItem.BaseDrugLib.DrugName
  217. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  218. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  219. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  220. order.OwnpayAmt = ""
  221. order.SelfpayAmt = ""
  222. order.Spec = ""
  223. order.SpecUnt = ""
  224. order.DrordBegnDate = s_tm
  225. order.DrordStopDate = ""
  226. order.DrordDrCodg = "1"
  227. order.DrordDeptName = department.Name
  228. order.DrordDrCodg = "1"
  229. order.DrordDrName = doctor_info.UserName
  230. order.DrordDrProfttl = ""
  231. order.CurrDrordFlag = "1"
  232. orders = append(orders, &order)
  233. }
  234. for _, subItem := range item.HisPrescriptionProject {
  235. if subItem.Type == 2 {
  236. var order models.FsiOrderDtos
  237. order.RxID = strconv.FormatInt(item.ID, 10)
  238. order.Rxno = strconv.FormatInt(item.ID, 10)
  239. order.LongDrordFlag = "0"
  240. order.HilistType = "1"
  241. order.ChrgType = "1"
  242. order.DrordBhvr = "-"
  243. order.HilistCode = subItem.HisProject.MedicalCode
  244. order.HosplistName = subItem.HisProject.ProjectName
  245. order.HilistLv = "1"
  246. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  247. order.HosplistCode = subItem.HisProject.MedicalCode
  248. order.HosplistName = subItem.HisProject.ProjectName
  249. order.Cnt = subItem.Count
  250. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  251. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  252. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  253. order.OwnpayAmt = ""
  254. order.SelfpayAmt = ""
  255. order.Spec = ""
  256. order.SpecUnt = ""
  257. order.DrordBegnDate = s_tm
  258. order.DrordStopDate = ""
  259. order.DrordDrCodg = "1"
  260. order.DrordDeptName = department.Name
  261. order.DrordDrCodg = "1"
  262. order.DrordDrName = doctor_info.UserName
  263. order.DrordDrProfttl = ""
  264. order.CurrDrordFlag = "1"
  265. orders = append(orders, &order)
  266. }
  267. if subItem.Type == 3 {
  268. var order models.FsiOrderDtos
  269. order.RxID = strconv.FormatInt(item.ID, 10)
  270. order.Rxno = strconv.FormatInt(item.ID, 10)
  271. order.LongDrordFlag = "0"
  272. order.HilistType = "1"
  273. order.ChrgType = "1"
  274. order.DrordBhvr = "-"
  275. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  276. order.HosplistName = subItem.GoodInfo.GoodName
  277. order.HilistLv = "1"
  278. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  279. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  280. order.HosplistName = subItem.GoodInfo.GoodName
  281. order.Cnt = subItem.Count
  282. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  283. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  284. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  285. order.OwnpayAmt = ""
  286. order.SelfpayAmt = ""
  287. order.Spec = ""
  288. order.SpecUnt = ""
  289. order.DrordBegnDate = s_tm
  290. order.DrordStopDate = ""
  291. order.DrordDrCodg = "1"
  292. order.DrordDeptName = department.Name
  293. order.DrordDrCodg = "1"
  294. order.DrordDrName = doctor_info.UserName
  295. order.DrordDrProfttl = ""
  296. order.CurrDrordFlag = "1"
  297. orders = append(orders, &order)
  298. }
  299. }
  300. }
  301. //处方医嘱信息
  302. }
  303. fed.MatnStas = "0"
  304. fed.MedfeeSumamt = "0"
  305. fed.OwnpayAmt = "0"
  306. fed.SelfpayAmt = "0"
  307. fed.AcctPayamt = "0"
  308. fed.MaAmt = "0"
  309. fed.HifpPayamt = "0"
  310. fed.SetlTotlnum = "1"
  311. fed.Insutype = his.Insutype
  312. fed.ReimFlag = "0"
  313. fed.OutSetlFlag = "0"
  314. var fopd []*models.FsiOperationDtosData
  315. data := make(map[string]interface{})
  316. data["fed"] = fed
  317. data["fdd"] = fdds
  318. data["fod"] = orders
  319. data["pd"] = pd
  320. data["pp"] = pp
  321. data["fopd"] = fopd
  322. data["trig_scen"] = trig_scen
  323. fmt.Println(data)
  324. fmt.Println(fed)
  325. fmt.Println(fdds)
  326. fmt.Println(orders)
  327. fmt.Println(pd)
  328. fmt.Println(pp)
  329. fmt.Println(fopd)
  330. client := &http.Client{}
  331. bytesData, _ := json.Marshal(data)
  332. var req *http.Request
  333. if miConfig.MdtrtareaAdmvs == "320921" {
  334. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  335. } else {
  336. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3101", bytes.NewReader(bytesData))
  337. }
  338. resp, _ := client.Do(req)
  339. defer resp.Body.Close()
  340. body, ioErr := ioutil.ReadAll(resp.Body)
  341. if ioErr != nil {
  342. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  343. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  344. return
  345. }
  346. var respJSON map[string]interface{}
  347. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  348. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  349. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  350. return
  351. }
  352. //手术操作集合
  353. //手术操作集合
  354. }
  355. func (c *HisApiController) Check3102() {
  356. patient_id, _ := c.GetInt64("patient_id")
  357. order_id, _ := c.GetInt64("order_id")
  358. his_patient_id, _ := c.GetInt64("his_patient_id")
  359. admin_user_id, _ := c.GetInt64("admin_user_id")
  360. trig_scen := c.GetString("trig_scen")
  361. adminUser := c.GetAdminUserInfo()
  362. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  363. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  364. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  365. record_time := c.GetString("record_time")
  366. order, _ := service.GetHisOrderByID(order_id)
  367. timeLayout := "2006-01-02"
  368. loc, _ := time.LoadLocation("Local")
  369. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  370. if err != nil {
  371. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  372. return
  373. }
  374. recordDateTime := theTime.Unix()
  375. var patientPrescription models.HisPrescriptionInfo
  376. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  377. if patientPrescription.ID == 0 {
  378. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  379. }
  380. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  381. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  382. //
  383. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  384. prescriptions, _ := service.GetNewHisPrescriptionTen(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  385. var pp models.PublicParams
  386. pp.InsuplcAdmdvs = miConfig.InsuplcAdmdvs
  387. pp.MdtrtareaAdmvs = miConfig.MdtrtareaAdmvs
  388. pp.FixmedinsName = miConfig.OrgName
  389. pp.FixmedinsCode = miConfig.Code
  390. pp.RequestUrl = miConfig.Url
  391. pp.Cainfo = miConfig.Cainfo
  392. pp.SecretKey = miConfig.SecretKey
  393. pp.AccessKey = miConfig.AccessKey
  394. pp.OpterName = roles.UserName
  395. var config []*models.HisXtDiagnoseConfig
  396. for _, item := range diagnosis_ids {
  397. id, _ := strconv.ParseInt(item, 10, 64)
  398. diagnosisConfig, _ := service.FindDiagnoseById(id)
  399. config = append(config, &diagnosisConfig)
  400. }
  401. var pd models.PatientDtos
  402. pd.PatnID = his.PsnNo
  403. pd.PatnName = his.Name
  404. pd.Gend = his.Gend
  405. pd.Brdy = his.Brdy
  406. pd.Poolarea = his.InsuplcAdmdvs
  407. pd.CurrMdtrtID = his.Number
  408. var fed models.FsiEncounterDtos
  409. fed.MdtrtID = his.Number
  410. fed.MedinsID = miConfig.Code
  411. fed.MedinsName = miConfig.OrgName
  412. fed.MedinsAdmdvs = miConfig.MdtrtareaAdmvs
  413. fed.MedMdtrtType = "1"
  414. fed.MedinsType = "1"
  415. fed.MedinsLv = "11"
  416. tm := time.Unix(his.RecordDate, 0)
  417. s_tm := tm.Format("2006-01-02 15:04:05")
  418. fed.AdmDate = s_tm
  419. fed.DscgDate = s_tm
  420. fed.DscgMainDiseCodg = config[0].CountryCode
  421. fed.DscgMainDiseName = config[0].CountryContentName
  422. //诊断信息
  423. var fdds []*models.FsiDiagnoseDtos
  424. for index, item := range config {
  425. if index == 0 {
  426. var fdd models.FsiDiagnoseDtos
  427. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  428. fdd.InoutDiseType = "1"
  429. fdd.MaindiseFlag = "1"
  430. fdd.DiseDate = s_tm
  431. fdd.DiasSrtNo = "1"
  432. fdd.DiseName = item.CountryContentName
  433. fdd.DiseCodg = item.CountryCode
  434. fdds = append(fdds, &fdd)
  435. } else {
  436. var fdd models.FsiDiagnoseDtos
  437. fdd.DiseID = strconv.FormatInt(item.ID, 10)
  438. fdd.InoutDiseType = "1"
  439. fdd.MaindiseFlag = "1"
  440. fdd.DiseDate = s_tm
  441. fdd.DiasSrtNo = strconv.FormatInt(int64(index), 10)
  442. fdd.DiseName = item.CountryContentName
  443. fdd.DiseCodg = item.CountryCode
  444. fdds = append(fdds, &fdd)
  445. }
  446. }
  447. fed.DrCodg = strconv.FormatInt(doctor_info.ID, 10)
  448. fed.AdmDeptCodg = strconv.FormatInt(department.ID, 10)
  449. fed.AdmDeptName = department.Name
  450. fed.DscgDeptCodg = strconv.FormatInt(department.ID, 10)
  451. fed.DscgDeptName = department.Name
  452. fed.MedType = order.MedType
  453. //处方医嘱信息
  454. var orders []*models.FsiOrderDtos
  455. //for _, item := range prescriptions {
  456. // for _, subItem := range item.HisDoctorAdviceInfo {
  457. // var order models.FsiOrderDtos
  458. // order.RxID = strconv.FormatInt(item.ID, 10)
  459. // order.Rxno = strconv.FormatInt(item.ID, 10)
  460. // order.LongDrordFlag = "0"
  461. // order.HilistType = "1"
  462. // order.ChrgType = "1"
  463. // order.DrordBhvr = "-"
  464. // order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  465. // order.HosplistName = subItem.BaseDrugLib.DrugName
  466. // order.HilistLv = "1"
  467. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  468. // order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  469. // order.HosplistName = subItem.BaseDrugLib.DrugName
  470. // order.Cnt = strconv.FormatFloat(subItem.PrescribingNumber, 'E', -1, 64)
  471. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  472. // order.Sumamt = strconv.FormatFloat((subItem.Price * subItem.PrescribingNumber), 'E', -1, 64)
  473. // order.OwnpayAmt = ""
  474. // order.SelfpayAmt = ""
  475. // order.Spec = ""
  476. // order.SpecUnt = ""
  477. // order.DrordBegnDate = s_tm
  478. // order.DrordStopDate = ""
  479. // order.DrordDrCodg = "1"
  480. // order.DrordDeptName = department.Name
  481. // order.DrordDrCodg = "1"
  482. // order.DrordDrName = doctor_info.UserName
  483. // order.DrordDrProfttl = ""
  484. // order.CurrDrordFlag = "1"
  485. // orders = append(orders, &order)
  486. // }
  487. // for _, subItem := range item.HisPrescriptionProject {
  488. // if subItem.Type == 2 {
  489. // var order models.FsiOrderDtos
  490. // order.RxID = strconv.FormatInt(item.ID, 10)
  491. // order.Rxno = strconv.FormatInt(item.ID, 10)
  492. // order.LongDrordFlag = "0"
  493. // order.HilistType = "1"
  494. // order.ChrgType = "1"
  495. // order.DrordBhvr = "-"
  496. // order.HilistCode = subItem.HisProject.MedicalCode
  497. // order.HosplistName = subItem.HisProject.ProjectName
  498. // order.HilistLv = "1"
  499. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  500. // order.HosplistCode = subItem.HisProject.MedicalCode
  501. // order.HosplistName = subItem.HisProject.ProjectName
  502. // order.Cnt = subItem.Count
  503. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  504. //
  505. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  506. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  507. // order.OwnpayAmt = ""
  508. // order.SelfpayAmt = ""
  509. // order.Spec = ""
  510. // order.SpecUnt = ""
  511. // order.DrordBegnDate = s_tm
  512. // order.DrordStopDate = ""
  513. // order.DrordDrCodg = "1"
  514. // order.DrordDeptName = department.Name
  515. // order.DrordDrCodg = "1"
  516. // order.DrordDrName = doctor_info.UserName
  517. // order.DrordDrProfttl = ""
  518. // order.CurrDrordFlag = "1"
  519. // orders = append(orders, &order)
  520. //
  521. // }
  522. // if subItem.Type == 3 {
  523. //
  524. // var order models.FsiOrderDtos
  525. // order.RxID = strconv.FormatInt(item.ID, 10)
  526. // order.Rxno = strconv.FormatInt(item.ID, 10)
  527. // order.LongDrordFlag = "0"
  528. // order.HilistType = "1"
  529. // order.ChrgType = "1"
  530. // order.DrordBhvr = "-"
  531. // order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  532. // order.HosplistName = subItem.GoodInfo.GoodName
  533. // order.HilistLv = "1"
  534. // order.HilistPric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  535. // order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  536. // order.HosplistName = subItem.GoodInfo.GoodName
  537. // order.Cnt = subItem.Count
  538. // cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  539. // order.Pric = strconv.FormatFloat(subItem.Price, 'E', -1, 64)
  540. // order.Sumamt = strconv.FormatFloat((subItem.Price * cnt), 'E', -1, 64)
  541. // order.OwnpayAmt = ""
  542. // order.SelfpayAmt = ""
  543. // order.Spec = ""
  544. // order.SpecUnt = ""
  545. // order.DrordBegnDate = s_tm
  546. // order.DrordStopDate = ""
  547. // order.DrordDrCodg = "1"
  548. // order.DrordDeptName = department.Name
  549. // order.DrordDrCodg = "1"
  550. // order.DrordDrName = doctor_info.UserName
  551. // order.DrordDrProfttl = ""
  552. // order.CurrDrordFlag = "1"
  553. // orders = append(orders, &order)
  554. //
  555. // }
  556. // }
  557. //}
  558. for _, item := range prescriptions {
  559. for _, subItem := range item.HisDoctorAdviceInfo {
  560. var order models.FsiOrderDtos
  561. order.RxID = strconv.FormatInt(item.ID, 10)
  562. order.Rxno = strconv.FormatInt(item.ID, 10)
  563. order.LongDrordFlag = "0"
  564. order.HilistType = "1"
  565. order.ChrgType = "1"
  566. order.DrordBhvr = "-"
  567. order.HilistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  568. order.HosplistName = subItem.BaseDrugLib.DrugName
  569. order.HilistLv = "1"
  570. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  571. order.HosplistCode = subItem.BaseDrugLib.MedicalInsuranceNumber
  572. order.HosplistName = subItem.BaseDrugLib.DrugName
  573. order.Cnt = fmt.Sprintf("%.2f", subItem.PrescribingNumber)
  574. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  575. order.Sumamt = fmt.Sprintf("%.2f", (subItem.PrescribingNumber * subItem.Price))
  576. order.OwnpayAmt = ""
  577. order.SelfpayAmt = ""
  578. order.Spec = ""
  579. order.SpecUnt = ""
  580. order.DrordBegnDate = s_tm
  581. order.DrordStopDate = ""
  582. order.DrordDrCodg = "1"
  583. order.DrordDeptName = department.Name
  584. order.DrordDrCodg = "1"
  585. order.DrordDrName = doctor_info.UserName
  586. order.DrordDrProfttl = ""
  587. order.CurrDrordFlag = "1"
  588. orders = append(orders, &order)
  589. }
  590. for _, subItem := range item.HisPrescriptionProject {
  591. if subItem.Type == 2 {
  592. var order models.FsiOrderDtos
  593. order.RxID = strconv.FormatInt(item.ID, 10)
  594. order.Rxno = strconv.FormatInt(item.ID, 10)
  595. order.LongDrordFlag = "0"
  596. order.HilistType = "1"
  597. order.ChrgType = "1"
  598. order.DrordBhvr = "-"
  599. order.HilistCode = subItem.HisProject.MedicalCode
  600. order.HosplistName = subItem.HisProject.ProjectName
  601. order.HilistLv = "1"
  602. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  603. order.HosplistCode = subItem.HisProject.MedicalCode
  604. order.HosplistName = subItem.HisProject.ProjectName
  605. order.Cnt = subItem.Count
  606. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  607. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  608. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  609. order.OwnpayAmt = ""
  610. order.SelfpayAmt = ""
  611. order.Spec = ""
  612. order.SpecUnt = ""
  613. order.DrordBegnDate = s_tm
  614. order.DrordStopDate = ""
  615. order.DrordDrCodg = "1"
  616. order.DrordDeptName = department.Name
  617. order.DrordDrCodg = "1"
  618. order.DrordDrName = doctor_info.UserName
  619. order.DrordDrProfttl = ""
  620. order.CurrDrordFlag = "1"
  621. orders = append(orders, &order)
  622. }
  623. if subItem.Type == 3 {
  624. var order models.FsiOrderDtos
  625. order.RxID = strconv.FormatInt(item.ID, 10)
  626. order.Rxno = strconv.FormatInt(item.ID, 10)
  627. order.LongDrordFlag = "0"
  628. order.HilistType = "1"
  629. order.ChrgType = "1"
  630. order.DrordBhvr = "-"
  631. order.HilistCode = subItem.GoodInfo.MedicalInsuranceNumber
  632. order.HosplistName = subItem.GoodInfo.GoodName
  633. order.HilistLv = "1"
  634. order.HilistPric = fmt.Sprintf("%.2f", subItem.Price)
  635. order.HosplistCode = subItem.GoodInfo.MedicalInsuranceNumber
  636. order.HosplistName = subItem.GoodInfo.GoodName
  637. order.Cnt = subItem.Count
  638. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  639. order.Pric = fmt.Sprintf("%.2f", subItem.Price)
  640. order.Sumamt = fmt.Sprintf("%.2f", subItem.Price*cnt)
  641. order.OwnpayAmt = ""
  642. order.SelfpayAmt = ""
  643. order.Spec = ""
  644. order.SpecUnt = ""
  645. order.DrordBegnDate = s_tm
  646. order.DrordStopDate = ""
  647. order.DrordDrCodg = "1"
  648. order.DrordDeptName = department.Name
  649. order.DrordDrCodg = "1"
  650. order.DrordDrName = doctor_info.UserName
  651. order.DrordDrProfttl = ""
  652. order.CurrDrordFlag = "1"
  653. orders = append(orders, &order)
  654. }
  655. }
  656. }
  657. //处方医嘱信息
  658. fed.MatnStas = "0"
  659. fed.MedfeeSumamt = fmt.Sprintf("%.2f", order.MedfeeSumamt)
  660. fed.OwnpayAmt = fmt.Sprintf("%.2f", order.FulamtOwnpayAmt)
  661. fed.SelfpayAmt = fmt.Sprintf("%.2f", order.PreselfpayAmt)
  662. fed.AcctPayamt = fmt.Sprintf("%.2f", order.AcctPay)
  663. fed.MaAmt = fmt.Sprintf("%.2f", order.MafPay)
  664. fed.HifpPayamt = fmt.Sprintf("%.2f", order.HifpPay)
  665. fed.SetlTotlnum = "1"
  666. fed.Insutype = his.Insutype
  667. fed.ReimFlag = "0"
  668. fed.OutSetlFlag = "0"
  669. var fopd []*models.FsiOperationDtosData
  670. data := make(map[string]interface{})
  671. data["fed"] = fed
  672. data["fdd"] = fdds
  673. data["fod"] = orders
  674. data["pd"] = pd
  675. data["pp"] = pp
  676. data["fopd"] = fopd
  677. data["trig_scen"] = trig_scen
  678. client := &http.Client{}
  679. bytesData, _ := json.Marshal(data)
  680. var req *http.Request
  681. if miConfig.MdtrtareaAdmvs == "320921" {
  682. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  683. } else {
  684. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/3102", bytes.NewReader(bytesData))
  685. }
  686. resp, _ := client.Do(req)
  687. defer resp.Body.Close()
  688. body, ioErr := ioutil.ReadAll(resp.Body)
  689. if ioErr != nil {
  690. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  692. return
  693. }
  694. var respJSON map[string]interface{}
  695. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  696. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  697. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  698. return
  699. }
  700. //手术操作集合
  701. //手术操作集合
  702. }
  703. func (c *HisApiController) Check() {
  704. psn_no := c.GetString("psn_no")
  705. in := c.GetString("in")
  706. mt := c.GetString("mt")
  707. baseParams := models.BaseParams{
  708. SecretKey: "MSDBYGxXm1Mtyi3PtOUB7n1ktcxwyW57",
  709. FixmedinsCode: "H15049901371",
  710. InsuplcAdmdvs: "150499",
  711. MdtrtareaAdmvs: "150499",
  712. OrgName: "赤峰费森血液透析中心",
  713. Doctor: "1111",
  714. }
  715. service.Gdyb2001(baseParams, psn_no, in, mt)
  716. }
  717. func (c *HisApiController) GetPsnNcdsInfo() {
  718. admin_user_id, _ := c.GetInt64("admin_user_id")
  719. patient_id, _ := c.GetInt64("patient_id")
  720. id, _ := c.GetInt64("id")
  721. adminUser := c.GetAdminUserInfo()
  722. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  723. //config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  724. //patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  725. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  726. psn_record, _ := service.GetPsnNCDSRecordById(id)
  727. //
  728. //if psn_record.ID == 0 {
  729. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  730. // return
  731. //}
  732. var res Result5301
  733. var res10265 Result5301For10265
  734. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  735. psn_info, _ := service.GetPsnByPatientId(patient_id)
  736. var api string
  737. if miConfig.MdtrtareaAdmvs == "320921" {
  738. api = "http://192.168.3.111:9532/" + "jsyb/5301?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName +
  739. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  740. } else {
  741. 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 +
  742. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&psn_no=" + psn_info.PsnNo + "&cainfo=" + miConfig.Cainfo
  743. }
  744. resp, requestErr := http.Get(api)
  745. if requestErr != nil {
  746. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  747. return
  748. }
  749. body, ioErr := ioutil.ReadAll(resp.Body)
  750. if ioErr != nil {
  751. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  752. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  753. return
  754. }
  755. var respJSON map[string]interface{}
  756. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  757. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  758. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  759. return
  760. }
  761. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  762. result, _ := json.Marshal(respJSON)
  763. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  764. utils.ErrorLog("解析失败:%v", err)
  765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  766. return
  767. }
  768. res.ErrMsg = res10265.ErrMsg
  769. res.Output = res10265.Output
  770. res.InfRefmsgid = res10265.InfRefmsgid
  771. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  772. res.Infcode = infocode
  773. } else {
  774. result := service.Gdyb5301(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  775. var dat map[string]interface{}
  776. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  777. fmt.Println(dat)
  778. } else {
  779. fmt.Println(err)
  780. }
  781. userJSONBytes, _ := json.Marshal(dat)
  782. if miConfig.Code == "H15049901371" {
  783. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  784. utils.ErrorLog("解析失败:%v", err)
  785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  786. return
  787. }
  788. res.InfRefmsgid = res10265.InfRefmsgid
  789. res.Output = res10265.Output
  790. res.ErrMsg = res10265.ErrMsg
  791. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  792. res.Infcode = infocode
  793. } else {
  794. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  795. utils.ErrorLog("解析失败:%v", err)
  796. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  797. return
  798. }
  799. }
  800. }
  801. if res.Infcode == 0 {
  802. c.ServeSuccessJSON(map[string]interface{}{
  803. "result": res.Output.Result,
  804. })
  805. }
  806. }
  807. func (c *HisApiController) CheckInsutype() {
  808. his_patient_id, _ := c.GetInt64("his_patient_id")
  809. admin_user_id, _ := c.GetInt64("admin_user_id")
  810. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  811. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  812. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  813. result := service.Gdyb90100(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  814. var dat map[string]interface{}
  815. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  816. fmt.Println(dat)
  817. } else {
  818. fmt.Println(err)
  819. }
  820. userJSONBytes, _ := json.Marshal(dat)
  821. var res Result90100
  822. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  823. utils.ErrorLog("解析失败:%v", err)
  824. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  825. return
  826. }
  827. if res.Infcode != 0 {
  828. c.ServeSuccessJSON(map[string]interface{}{
  829. "failed_code": -10,
  830. "msg": res.ErrMsg,
  831. })
  832. return
  833. } else {
  834. fmt.Println(res)
  835. }
  836. }
  837. func (c *HisApiController) CheckCardPWD() {
  838. card_pwd := c.GetString("card_pwd")
  839. his_patient_id, _ := c.GetInt64("his_patient_id")
  840. admin_user_id, _ := c.GetInt64("admin_user_id")
  841. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  842. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  843. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  844. psn, _ := service.GetPsnByPatientId(his.PatientId)
  845. bas := strings.Split(psn.CardInfo, "|")
  846. basNumber := bas[2]
  847. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd, basNumber)
  848. var dat map[string]interface{}
  849. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  850. fmt.Println(dat)
  851. } else {
  852. fmt.Println(err)
  853. }
  854. userJSONBytes, _ := json.Marshal(dat)
  855. var res Result90991
  856. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  857. utils.ErrorLog("解析失败:%v", err)
  858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  859. return
  860. }
  861. if res.Infcode != 0 {
  862. c.ServeSuccessJSON(map[string]interface{}{
  863. "failed_code": -10,
  864. "msg": res.ErrMsg,
  865. })
  866. return
  867. } else {
  868. if res.Output.Result.SscnoCheckStat == "0" {
  869. var msg string
  870. switch res.Output.Result.CardStat {
  871. case "00":
  872. msg = "未激活"
  873. break
  874. case "10":
  875. msg = "激活"
  876. break
  877. case "20":
  878. msg = "窗口挂失"
  879. break
  880. case "21":
  881. msg = "电话挂失"
  882. break
  883. case "22":
  884. msg = "单位网上申报挂失"
  885. break
  886. case "23":
  887. msg = "保健办挂失"
  888. break
  889. case "24":
  890. msg = "个人网上挂失"
  891. break
  892. case "25":
  893. msg = "网上服务大厅挂失"
  894. break
  895. case "30":
  896. msg = "注销"
  897. break
  898. case "40":
  899. msg = "回收"
  900. break
  901. case "99":
  902. msg = "制卡中(无效卡)"
  903. break
  904. }
  905. c.ServeSuccessJSON(map[string]interface{}{
  906. "failed_code": -10,
  907. "msg": msg,
  908. })
  909. return
  910. } else {
  911. c.ServeSuccessJSON(map[string]interface{}{
  912. "msg": "校验成功",
  913. })
  914. return
  915. }
  916. }
  917. }
  918. func (c *HisApiController) CheckCardPWDTwo() {
  919. //card_pwd := c.GetString("card_pwd")
  920. //his_patient_id, _ := c.GetInt64("his_patient_id")
  921. admin_user_id, _ := c.GetInt64("admin_user_id")
  922. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  923. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  924. result := service.Gdyb90991("44030000000629690364", miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, "000000", "BDM421363")
  925. var dat map[string]interface{}
  926. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  927. fmt.Println(dat)
  928. } else {
  929. fmt.Println(err)
  930. }
  931. userJSONBytes, _ := json.Marshal(dat)
  932. var res Result90991
  933. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  934. utils.ErrorLog("解析失败:%v", err)
  935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  936. return
  937. }
  938. if res.Infcode != 0 {
  939. c.ServeSuccessJSON(map[string]interface{}{
  940. "failed_code": -10,
  941. "msg": res.ErrMsg,
  942. })
  943. return
  944. } else {
  945. if res.Output.Result.SscnoCheckStat == "0" {
  946. var msg string
  947. switch res.Output.Result.CardStat {
  948. case "00":
  949. msg = "未激活"
  950. break
  951. case "10":
  952. msg = "激活"
  953. break
  954. case "20":
  955. msg = "窗口挂失"
  956. break
  957. case "21":
  958. msg = "电话挂失"
  959. break
  960. case "22":
  961. msg = "单位网上申报挂失"
  962. break
  963. case "23":
  964. msg = "保健办挂失"
  965. break
  966. case "24":
  967. msg = "个人网上挂失"
  968. break
  969. case "25":
  970. msg = "网上服务大厅挂失"
  971. break
  972. case "30":
  973. msg = "注销"
  974. break
  975. case "40":
  976. msg = "回收"
  977. break
  978. case "99":
  979. msg = "制卡中(无效卡)"
  980. break
  981. }
  982. c.ServeSuccessJSON(map[string]interface{}{
  983. "failed_code": -10,
  984. "msg": msg,
  985. })
  986. return
  987. } else {
  988. c.ServeSuccessJSON(map[string]interface{}{
  989. "msg": "校验成功",
  990. })
  991. return
  992. }
  993. }
  994. }
  995. func (c *HisApiController) ReadCard() {
  996. id_card_type, _ := c.GetInt64("id_card_type")
  997. admin_user_id, _ := c.GetInt64("admin_user_id")
  998. certificates, _ := c.GetInt64("certificates")
  999. fmt.Println(c.GetAdminUserInfo().CurrentOrgId)
  1000. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1001. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1002. switch id_card_type {
  1003. case 1:
  1004. if miConfig.MdtrtareaAdmvs == "421300" {
  1005. var res ResultTwo
  1006. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  1007. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  1008. "&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)
  1009. resp, requestErr := http.Get(api)
  1010. if requestErr != nil {
  1011. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1012. return
  1013. }
  1014. body, ioErr := ioutil.ReadAll(resp.Body)
  1015. if ioErr != nil {
  1016. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1018. return
  1019. }
  1020. var respJSON map[string]interface{}
  1021. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1022. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1023. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1024. return
  1025. }
  1026. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1027. result, _ := json.Marshal(respJSON)
  1028. fmt.Println("log")
  1029. fmt.Println(string(result))
  1030. if err := json.Unmarshal([]byte(result), &res); err != nil {
  1031. utils.ErrorLog("解析失败:%v", err)
  1032. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1033. return
  1034. }
  1035. if res.Infcode == 0 {
  1036. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1037. if err == gorm.ErrRecordNotFound {
  1038. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1039. return
  1040. } else if err != nil {
  1041. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1042. return
  1043. } else {
  1044. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1045. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1046. infoStr := string(Iinfos)
  1047. idetinfoStr := string(Idetinfos)
  1048. psn := &models.HisPsn{
  1049. PsnNo: res.Output.Baseinfo.PsnNo,
  1050. Age: res.Output.Baseinfo.Age,
  1051. PatientId: patient.ID,
  1052. Certno: res.Output.Baseinfo.Certno,
  1053. Brdy: res.Output.Baseinfo.Brdy,
  1054. Gend: res.Output.Baseinfo.Gend,
  1055. Naty: res.Output.Baseinfo.Naty,
  1056. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1057. PsnName: res.Output.Baseinfo.PsnName,
  1058. Idetinfo: idetinfoStr,
  1059. Insuinfo: infoStr,
  1060. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1061. }
  1062. service.CreateHisPsn(psn)
  1063. c.ServeSuccessJSON(map[string]interface{}{
  1064. "patient": patient,
  1065. "number": res.Output.Baseinfo.Certno,
  1066. })
  1067. }
  1068. } else {
  1069. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1070. return
  1071. }
  1072. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1073. var api string
  1074. if miConfig.MdtrtareaAdmvs == "320921" {
  1075. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1076. "&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
  1077. fmt.Println(api)
  1078. } else {
  1079. 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 +
  1080. "&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)
  1081. }
  1082. resp, requestErr := http.Get(api)
  1083. if requestErr != nil {
  1084. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1085. return
  1086. }
  1087. body, ioErr := ioutil.ReadAll(resp.Body)
  1088. if ioErr != nil {
  1089. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1090. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1091. return
  1092. }
  1093. var respJSON map[string]interface{}
  1094. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1095. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1097. return
  1098. }
  1099. var status string
  1100. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1101. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1102. //console.log()
  1103. fmt.Println("type===")
  1104. fmt.Println(card_type)
  1105. var token string
  1106. var res ResultTwo //1101结果
  1107. var res10265 ResultTwo10265 //1101结果
  1108. var card_info string //卡信息
  1109. var busi_card_info string
  1110. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1111. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1112. if status == "0" { //读卡成功
  1113. if card_type == "1" {
  1114. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1115. result, _ := json.Marshal(respJSON)
  1116. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1117. utils.ErrorLog("解析失败:%v", err)
  1118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1119. return
  1120. }
  1121. res.ErrMsg = res10265.ErrMsg
  1122. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1123. res.Infcode = infocode
  1124. res.Output = res10265.Output
  1125. res.InfRefmsgid = res10265.InfRefmsgid
  1126. } else {
  1127. //var card_info string //卡信息
  1128. //var busi_card_info string
  1129. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1130. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1131. //fmt.Println(card_info)
  1132. //fmt.Println(busi_card_info)
  1133. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1134. result, _ := json.Marshal(respJSON)
  1135. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1136. utils.ErrorLog("解析失败:%v", err)
  1137. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1138. return
  1139. }
  1140. res.ErrMsg = res10265.ErrMsg
  1141. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1142. res.Infcode = infocode
  1143. res.Output = res10265.Output
  1144. res.InfRefmsgid = res10265.InfRefmsgid
  1145. }
  1146. if res.Infcode == 0 {
  1147. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1148. if err == gorm.ErrRecordNotFound {
  1149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1150. return
  1151. } else if err != nil {
  1152. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1153. return
  1154. } else {
  1155. if card_type == "1" {
  1156. bas := strings.Split(card_info, "|")
  1157. basNumber := bas[2]
  1158. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1159. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1160. infoStr := string(Iinfos)
  1161. idetinfoStr := string(Idetinfos)
  1162. psn := &models.HisPsn{
  1163. PsnNo: res.Output.Baseinfo.PsnNo,
  1164. Age: res.Output.Baseinfo.Age,
  1165. PatientId: patient.ID,
  1166. Certno: res.Output.Baseinfo.Certno,
  1167. Brdy: res.Output.Baseinfo.Brdy,
  1168. Gend: res.Output.Baseinfo.Gend,
  1169. Naty: res.Output.Baseinfo.Naty,
  1170. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1171. PsnName: res.Output.Baseinfo.PsnName,
  1172. Idetinfo: idetinfoStr,
  1173. Insuinfo: infoStr,
  1174. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1175. CardInfo: card_info,
  1176. VerifyNumber: busi_card_info,
  1177. }
  1178. service.CreateHisPsn(psn)
  1179. var rf []*ResultFive
  1180. json.Unmarshal([]byte(infoStr), &rf)
  1181. var insutypes []*ResultFive
  1182. var insutype string
  1183. var is390 int = 0
  1184. var is310 int = 0
  1185. for _, item := range rf {
  1186. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1187. insutypes = append(insutypes, item)
  1188. }
  1189. }
  1190. if len(insutypes) == 1 {
  1191. insutype = insutypes[0].Insutype
  1192. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1193. } else {
  1194. for _, i := range insutypes {
  1195. if i.Insutype == "390" {
  1196. is390 = 1
  1197. }
  1198. if i.Insutype == "310" {
  1199. is310 = 1
  1200. }
  1201. }
  1202. }
  1203. if is390 == 1 {
  1204. insutype = "390"
  1205. }
  1206. if is310 == 1 {
  1207. insutype = "310"
  1208. }
  1209. if len(insutypes) == 0 {
  1210. insutype = "310"
  1211. }
  1212. c.ServeSuccessJSON(map[string]interface{}{
  1213. "patient": patient,
  1214. "number": basNumber,
  1215. "insutype": insutype,
  1216. })
  1217. } else {
  1218. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1219. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1220. infoStr := string(Iinfos)
  1221. idetinfoStr := string(Idetinfos)
  1222. psn := &models.HisPsn{
  1223. PsnNo: res.Output.Baseinfo.PsnNo,
  1224. Age: res.Output.Baseinfo.Age,
  1225. PatientId: patient.ID,
  1226. Certno: res.Output.Baseinfo.Certno,
  1227. Brdy: res.Output.Baseinfo.Brdy,
  1228. Gend: res.Output.Baseinfo.Gend,
  1229. Naty: res.Output.Baseinfo.Naty,
  1230. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1231. PsnName: res.Output.Baseinfo.PsnName,
  1232. Idetinfo: idetinfoStr,
  1233. Insuinfo: infoStr,
  1234. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1235. CardInfo: card_info,
  1236. VerifyNumber: token,
  1237. }
  1238. service.CreateHisPsn(psn)
  1239. c.ServeSuccessJSON(map[string]interface{}{
  1240. "patient": patient,
  1241. "number": token,
  1242. })
  1243. }
  1244. }
  1245. } else {
  1246. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1247. return
  1248. }
  1249. } else { //读卡失败
  1250. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1251. return
  1252. }
  1253. } else {
  1254. if initFlag == 0 {
  1255. c.TestGetBasBaseInit()
  1256. }
  1257. basStr := c.GetBasBaseInfo()
  1258. if len(basStr) == 0 {
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1260. return
  1261. }
  1262. fmt.Println(basStr)
  1263. bas := strings.Split(basStr, "|")
  1264. basNumber := bas[1]
  1265. fmt.Println(basNumber)
  1266. card_sn := bas[3]
  1267. fmt.Println(card_sn)
  1268. result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1269. var dat map[string]interface{}
  1270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1271. fmt.Println(dat)
  1272. } else {
  1273. fmt.Println(err)
  1274. }
  1275. userJSONBytes, _ := json.Marshal(dat)
  1276. var res ResultTwo
  1277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1278. utils.ErrorLog("解析失败:%v", err)
  1279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1280. return
  1281. }
  1282. if res.Infcode == 0 {
  1283. patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  1284. if err == gorm.ErrRecordNotFound {
  1285. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1286. return
  1287. } else if err != nil {
  1288. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1289. return
  1290. } else {
  1291. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1292. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1293. infoStr := string(Iinfos)
  1294. idetinfoStr := string(Idetinfos)
  1295. psn := &models.HisPsn{
  1296. PsnNo: res.Output.Baseinfo.PsnNo,
  1297. Age: res.Output.Baseinfo.Age,
  1298. PatientId: patient.ID,
  1299. Certno: res.Output.Baseinfo.Certno,
  1300. Brdy: res.Output.Baseinfo.Brdy,
  1301. Gend: res.Output.Baseinfo.Gend,
  1302. Naty: res.Output.Baseinfo.Naty,
  1303. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1304. PsnName: res.Output.Baseinfo.PsnName,
  1305. Idetinfo: idetinfoStr,
  1306. Insuinfo: infoStr,
  1307. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1308. CardInfo: basStr,
  1309. VerifyNumber: "",
  1310. }
  1311. service.CreateHisPsn(psn)
  1312. c.ServeSuccessJSON(map[string]interface{}{
  1313. "patient": patient,
  1314. "number": basNumber,
  1315. })
  1316. }
  1317. } else {
  1318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1319. return
  1320. }
  1321. break
  1322. }
  1323. case 2:
  1324. SFZStr := c.GetSFZBaseInfo()
  1325. id_card_str := strings.Split(SFZStr, "^")
  1326. id_card_number := id_card_str[0]
  1327. card_sn := ""
  1328. result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  1329. var dat map[string]interface{}
  1330. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1331. fmt.Println(dat)
  1332. } else {
  1333. fmt.Println(err)
  1334. }
  1335. userJSONBytes, _ := json.Marshal(dat)
  1336. var res ResultTwo
  1337. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1338. utils.ErrorLog("解析失败:%v", err)
  1339. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1340. return
  1341. }
  1342. if res.Infcode == 0 {
  1343. patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  1344. if err == gorm.ErrRecordNotFound {
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1346. return
  1347. } else if err != nil {
  1348. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1349. return
  1350. } else {
  1351. c.ServeSuccessJSON(map[string]interface{}{
  1352. "patient": patient,
  1353. "number": id_card_number,
  1354. })
  1355. }
  1356. } else {
  1357. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1358. return
  1359. }
  1360. break
  1361. case 3:
  1362. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1363. var api string
  1364. if miConfig.MdtrtareaAdmvs == "320921" {
  1365. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1366. "&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
  1367. fmt.Println(api)
  1368. } else {
  1369. 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 +
  1370. "&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)
  1371. }
  1372. resp, requestErr := http.Get(api)
  1373. if requestErr != nil {
  1374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1375. return
  1376. }
  1377. body, ioErr := ioutil.ReadAll(resp.Body)
  1378. if ioErr != nil {
  1379. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1380. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1381. return
  1382. }
  1383. var respJSON map[string]interface{}
  1384. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1385. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1386. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1387. return
  1388. }
  1389. var status string
  1390. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1391. card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1392. var token string
  1393. var res ResultTwo //1101结果
  1394. var res10265 ResultTwo10265 //1101结果
  1395. var card_info string //卡信息
  1396. var busi_card_info string
  1397. //card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1398. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1399. if status == "0" { //读卡成功
  1400. if card_type == "1" {
  1401. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1402. result, _ := json.Marshal(respJSON)
  1403. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1404. utils.ErrorLog("解析失败:%v", err)
  1405. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1406. return
  1407. }
  1408. res.ErrMsg = res10265.ErrMsg
  1409. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1410. res.Infcode = infocode
  1411. res.Output = res10265.Output
  1412. res.InfRefmsgid = res10265.InfRefmsgid
  1413. } else {
  1414. //var card_info string //卡信息
  1415. //var busi_card_info string
  1416. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1417. //busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1418. //fmt.Println(card_info)
  1419. //fmt.Println(busi_card_info)
  1420. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1421. result, _ := json.Marshal(respJSON)
  1422. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1423. utils.ErrorLog("解析失败:%v", err)
  1424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1425. return
  1426. }
  1427. res.ErrMsg = res10265.ErrMsg
  1428. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1429. res.Infcode = infocode
  1430. res.Output = res10265.Output
  1431. res.InfRefmsgid = res10265.InfRefmsgid
  1432. }
  1433. if res.Infcode == 0 {
  1434. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1435. if err == gorm.ErrRecordNotFound {
  1436. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1437. return
  1438. } else if err != nil {
  1439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1440. return
  1441. } else {
  1442. if card_type == "1" {
  1443. bas := strings.Split(card_info, "|")
  1444. basNumber := bas[2]
  1445. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1446. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1447. infoStr := string(Iinfos)
  1448. idetinfoStr := string(Idetinfos)
  1449. psn := &models.HisPsn{
  1450. PsnNo: res.Output.Baseinfo.PsnNo,
  1451. Age: res.Output.Baseinfo.Age,
  1452. PatientId: patient.ID,
  1453. Certno: res.Output.Baseinfo.Certno,
  1454. Brdy: res.Output.Baseinfo.Brdy,
  1455. Gend: res.Output.Baseinfo.Gend,
  1456. Naty: res.Output.Baseinfo.Naty,
  1457. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1458. PsnName: res.Output.Baseinfo.PsnName,
  1459. Idetinfo: idetinfoStr,
  1460. Insuinfo: infoStr,
  1461. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1462. CardInfo: card_info,
  1463. VerifyNumber: busi_card_info,
  1464. }
  1465. service.CreateHisPsn(psn)
  1466. c.ServeSuccessJSON(map[string]interface{}{
  1467. "patient": patient,
  1468. "number": basNumber,
  1469. })
  1470. } else {
  1471. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1472. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1473. infoStr := string(Iinfos)
  1474. idetinfoStr := string(Idetinfos)
  1475. psn := &models.HisPsn{
  1476. PsnNo: res.Output.Baseinfo.PsnNo,
  1477. Age: res.Output.Baseinfo.Age,
  1478. PatientId: patient.ID,
  1479. Certno: res.Output.Baseinfo.Certno,
  1480. Brdy: res.Output.Baseinfo.Brdy,
  1481. Gend: res.Output.Baseinfo.Gend,
  1482. Naty: res.Output.Baseinfo.Naty,
  1483. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1484. PsnName: res.Output.Baseinfo.PsnName,
  1485. Idetinfo: idetinfoStr,
  1486. Insuinfo: infoStr,
  1487. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1488. CardInfo: card_info,
  1489. VerifyNumber: token,
  1490. }
  1491. service.CreateHisPsn(psn)
  1492. var rf []*ResultFive
  1493. json.Unmarshal([]byte(infoStr), &rf)
  1494. var insutypes []*ResultFive
  1495. var insutype string
  1496. var is390 int = 0
  1497. var is310 int = 0
  1498. for _, item := range rf {
  1499. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1500. insutypes = append(insutypes, item)
  1501. }
  1502. }
  1503. if len(insutypes) == 1 {
  1504. insutype = insutypes[0].Insutype
  1505. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  1506. } else {
  1507. for _, i := range insutypes {
  1508. if i.Insutype == "390" {
  1509. is390 = 1
  1510. }
  1511. if i.Insutype == "310" {
  1512. is310 = 1
  1513. }
  1514. }
  1515. }
  1516. if is390 == 1 {
  1517. insutype = "390"
  1518. }
  1519. if is310 == 1 {
  1520. insutype = "310"
  1521. }
  1522. if len(insutypes) == 0 {
  1523. insutype = "310"
  1524. }
  1525. c.ServeSuccessJSON(map[string]interface{}{
  1526. "patient": patient,
  1527. "number": token,
  1528. "insutype": insutype,
  1529. })
  1530. }
  1531. }
  1532. } else {
  1533. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1534. return
  1535. }
  1536. } else { //读卡失败
  1537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1538. return
  1539. }
  1540. }
  1541. break
  1542. case 4:
  1543. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  1544. var api string
  1545. if miConfig.MdtrtareaAdmvs == "320921" {
  1546. api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  1547. "&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
  1548. fmt.Println(api)
  1549. } else {
  1550. 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 +
  1551. "&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)
  1552. }
  1553. resp, requestErr := http.Get(api)
  1554. if requestErr != nil {
  1555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1556. return
  1557. }
  1558. body, ioErr := ioutil.ReadAll(resp.Body)
  1559. if ioErr != nil {
  1560. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1561. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1562. return
  1563. }
  1564. var respJSON map[string]interface{}
  1565. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1566. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1567. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1568. return
  1569. }
  1570. var status string
  1571. status = respJSON["data"].(map[string]interface{})["status"].(string)
  1572. //card_type := respJSON["data"].(map[string]interface{})["type"].(string)
  1573. var token string
  1574. var res ResultTwo //1101结果
  1575. var res10265 ResultTwo10265 //1101结果
  1576. if status == "0" { //读卡成功
  1577. var card_info string //卡信息
  1578. var busi_card_info string
  1579. token = respJSON["data"].(map[string]interface{})["token"].(string)
  1580. busi_card_info = respJSON["data"].(map[string]interface{})["busi_card_info"].(string)
  1581. card_info = respJSON["data"].(map[string]interface{})["card_info"].(string)
  1582. fmt.Println(card_info)
  1583. fmt.Println(busi_card_info)
  1584. respJSON = respJSON["data"].(map[string]interface{})["result"].(map[string]interface{})
  1585. result, _ := json.Marshal(respJSON)
  1586. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  1587. utils.ErrorLog("解析失败:%v", err)
  1588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1589. return
  1590. }
  1591. res.ErrMsg = res10265.ErrMsg
  1592. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  1593. res.Infcode = infocode
  1594. res.Output = res10265.Output
  1595. res.InfRefmsgid = res10265.InfRefmsgid
  1596. if res.Infcode == 0 {
  1597. patient, err := service.GetPatientByIDCard(res.Output.Baseinfo.Certno, c.GetAdminUserInfo().CurrentOrgId)
  1598. if err == gorm.ErrRecordNotFound {
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1600. return
  1601. } else if err != nil {
  1602. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1603. return
  1604. } else {
  1605. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1606. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1607. infoStr := string(Iinfos)
  1608. idetinfoStr := string(Idetinfos)
  1609. psn := &models.HisPsn{
  1610. PsnNo: res.Output.Baseinfo.PsnNo,
  1611. Age: res.Output.Baseinfo.Age,
  1612. PatientId: patient.ID,
  1613. Certno: res.Output.Baseinfo.Certno,
  1614. Brdy: res.Output.Baseinfo.Brdy,
  1615. Gend: res.Output.Baseinfo.Gend,
  1616. Naty: res.Output.Baseinfo.Naty,
  1617. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1618. PsnName: res.Output.Baseinfo.PsnName,
  1619. Idetinfo: idetinfoStr,
  1620. Insuinfo: infoStr,
  1621. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  1622. CardInfo: card_info,
  1623. VerifyNumber: token,
  1624. }
  1625. service.CreateHisPsn(psn)
  1626. c.ServeSuccessJSON(map[string]interface{}{
  1627. "patient": patient,
  1628. "number": token,
  1629. })
  1630. }
  1631. } else {
  1632. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1633. return
  1634. }
  1635. } else { //读卡失败
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  1637. return
  1638. }
  1639. }
  1640. break
  1641. }
  1642. }
  1643. var initFlag int64 = 0
  1644. func (c *HisApiController) TestGetBasBaseInit() {
  1645. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1646. Iinit := DllDef.MustFindProc("Init")
  1647. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1648. ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_api/prd/api/card/initDll"), StrPtr(miConfig.InsuplcAdmdvs))
  1649. if ret != 0 {
  1650. fmt.Println("SSCard的报错原因:", err)
  1651. fmt.Println("SSCard的运算结果为:", ret)
  1652. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1653. return
  1654. }
  1655. result := int(ret)
  1656. fmt.Println("SSCard的运算结果为1:", result)
  1657. initFlag = 1
  1658. return
  1659. }
  1660. func (c *HisApiController) GetSFZBaseInfo() string {
  1661. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1662. readCard := DllDef.MustFindProc("ReadSFZ")
  1663. if readCard == nil {
  1664. fmt.Println("readcard is nil")
  1665. readCard = DllDef.MustFindProc("ReadSFZ")
  1666. }
  1667. str := make([]byte, 256)
  1668. str1 := make([]byte, 256)
  1669. r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  1670. fmt.Println(r)
  1671. return string(str)
  1672. }
  1673. func (c *HisApiController) GetBasBaseInfo() string {
  1674. DllDef := syscall.MustLoadDLL("SSCard.dll")
  1675. readCard := DllDef.MustFindProc("ReadCardBas")
  1676. if readCard == nil {
  1677. fmt.Println("readcard is nil")
  1678. readCard = DllDef.MustFindProc("ReadCardBas")
  1679. }
  1680. str := make([]byte, 1024)
  1681. str1 := make([]byte, 1024)
  1682. ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  1683. fmt.Println(string(str1))
  1684. fmt.Println(string(str))
  1685. fmt.Println(":", ConvertToString(string(str1), "gbk", "utf-8"))
  1686. fmt.Println(":", ConvertToString(string(str), "gbk", "utf-8"))
  1687. if ret2 != 0 {
  1688. return ""
  1689. }
  1690. return string(str)
  1691. }
  1692. type CustomFundPay struct {
  1693. FundPayType string `json:"fund_pay_type"`
  1694. FundPayamt float64 `json:"fund_payamt"`
  1695. }
  1696. func (c *HisApiController) GetSettleList() {
  1697. order_id, _ := c.GetInt64("order_id")
  1698. admin_user_id, _ := c.GetInt64("admin_user_id")
  1699. order, _ := service.GetHisOrderByIDTwo(order_id)
  1700. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  1701. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  1702. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  1703. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  1704. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  1705. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  1706. if order.ID == 0 {
  1707. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1708. return
  1709. }
  1710. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  1711. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  1712. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  1713. fmt.Println(count)
  1714. var zero string
  1715. number := count + 1
  1716. if number >= 1000 {
  1717. zero = "0000" + strconv.FormatInt(number, 10)
  1718. } else if number >= 10000 {
  1719. zero = "000" + strconv.FormatInt(number, 10)
  1720. } else if number >= 100000 {
  1721. zero = "00" + strconv.FormatInt(number, 10)
  1722. } else if number >= 1000000 {
  1723. zero = "0" + strconv.FormatInt(number, 10)
  1724. } else {
  1725. zero = strconv.FormatInt(number, 10)
  1726. }
  1727. fmt.Println(zero)
  1728. struct4101 := service.Struct4101{
  1729. PsnNo: order.PsnNo,
  1730. MdtrtId: order.MdtrtId,
  1731. SetlId: order.SetlId,
  1732. PsnName: order.PsnName,
  1733. Gend: order.Gend,
  1734. Brdy: his.Brdy,
  1735. Age: his.Age,
  1736. Naty: order.Naty,
  1737. PatnCertType: "01",
  1738. Certno: order.Certno,
  1739. Prfs: "90",
  1740. ConerName: roles[0].UserName,
  1741. PatnRlts: "99",
  1742. ConerAddr: miConfig.OrgName,
  1743. ConerTel: admin.Mobile,
  1744. HiType: order.Insutype,
  1745. Insuplc: miConfig.InsuplcAdmdvs,
  1746. MaindiagFlag: "1",
  1747. BillCode: last_order.FaPiaoCode,
  1748. BillNo: zero,
  1749. BizSn: order.Number,
  1750. PsnSelfPay: order.PsnPartAmt,
  1751. PsnOwnPay: order.PsnPartAmt,
  1752. AcctPay: order.AcctPay,
  1753. PsnCashpay: order.PsnCashPay,
  1754. HiPaymtd: "1",
  1755. Hsorg: miConfig.InsuplcAdmdvs,
  1756. HsorgOpter: miConfig.InsuplcAdmdvs,
  1757. MedinsFillPsn: curRoles.UserName,
  1758. MedinsFillDept: depart.Name,
  1759. IptMedType: "2",
  1760. }
  1761. struct4101.SetlBegnDate = order.SetlTime
  1762. struct4101.SetlEndDate = order.SetlTime
  1763. time_arr := strings.Split(order.SetlTime, " ")
  1764. struct4101.AdmTime = time_arr[0]
  1765. struct4101.AdmEndTime = time_arr[0]
  1766. var rf []CustomFundPay
  1767. json.Unmarshal([]byte(order.SetlDetail), &rf)
  1768. var tempFunPays []service.CustomStruct
  1769. for _, item := range rf {
  1770. var tempFunPay service.CustomStruct
  1771. tempFunPay.FundPayamt = item.FundPayamt
  1772. tempFunPay.FundPayType = item.FundPayType
  1773. tempFunPays = append(tempFunPays, tempFunPay)
  1774. }
  1775. struct4101.CustomStruct = tempFunPays
  1776. var tempDiaginfos []service.DiaginfoStructTwo
  1777. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  1778. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  1779. diagnosis_ids := strings.Split(order.Diagnosis, ",")
  1780. var config []*models.HisXtDiagnoseConfig
  1781. for _, item := range diagnosis_ids {
  1782. id, _ := strconv.ParseInt(item, 10, 64)
  1783. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1784. config = append(config, &diagnosisConfig)
  1785. }
  1786. for index, item := range config {
  1787. if index == 0 {
  1788. var tempDiaginfo service.DiaginfoStructTwo
  1789. tempDiaginfo.DiagCode = item.CountryCode
  1790. tempDiaginfo.DiagName = item.CountryContentName
  1791. tempDiaginfo.DiagType = "1"
  1792. tempDiaginfo.MaindiagFlag = "1"
  1793. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1794. } else {
  1795. var tempDiaginfo service.DiaginfoStructTwo
  1796. tempDiaginfo.DiagCode = item.CountryCode
  1797. tempDiaginfo.DiagName = item.CountryContentName
  1798. tempDiaginfo.DiagType = "2"
  1799. tempDiaginfo.MaindiagFlag = "0"
  1800. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  1801. }
  1802. }
  1803. struct4101.Diseinfo = tempDiaginfos
  1804. sickConfigTwo, _ := service.FindSickById(his.SickType)
  1805. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  1806. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  1807. tempOpspdiseinfo2.OprnOprtCode = sickConfigTwo.ContentCode
  1808. tempOpspdiseinfo2.OprnOprtName = sickConfigTwo.CountryContentName
  1809. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  1810. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  1811. var iteminfo service.IteminfoStruct
  1812. var bedCostTotal float64 = 0 //床位总费
  1813. var bedCostSelfTotal float64 = 0 //床位自费
  1814. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  1815. var operationCostTotal float64 = 0 //手术费
  1816. var operationCostSelfTotal float64 = 0 //手术费
  1817. var operationCostPartSelfTotal float64 = 0 //手术费
  1818. var otherCostTotal float64 = 0 //其他费用
  1819. var otherCostSelfTotal float64 = 0 //其他费用
  1820. var otherCostPartSelfTotal float64 = 0 //其他费用
  1821. var materialCostTotal float64 = 0 //材料费
  1822. var materialCostSelfTotal float64 = 0 //材料费
  1823. var materialCostPartSelfTotal float64 = 0 //材料费
  1824. var westernMedicineCostTotal float64 = 0 //西药费
  1825. var westernMedicineCostSelfTotal float64 = 0 //西药费
  1826. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  1827. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  1828. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  1829. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  1830. var checkCostTotal float64 = 0 //检查费
  1831. var checkCostSelfTotal float64 = 0 //检查费
  1832. var checkCostPartSelfTotal float64 = 0 //检查费
  1833. var laboratoryCostTotal float64 = 0 //化验费
  1834. var laboratoryCostSelfTotal float64 = 0 //化验费
  1835. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  1836. var treatCostTotal float64 = 0 //治疗费用
  1837. var treatCostSelfTotal float64 = 0 //治疗费用
  1838. var treatCostPartSelfTotal float64 = 0 //治疗费用
  1839. decimal.DivisionPrecision = 2
  1840. var bed_fulamt_ownpay_amt float64 = 0
  1841. var operation_fulamt_ownpay_amt float64 = 0
  1842. var other_fulamt_ownpay_amt float64 = 0
  1843. var westernMedicine_fulamt_ownpay_amt float64 = 0
  1844. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  1845. var check_fulamt_ownpay_amt float64 = 0
  1846. var material_fulamt_ownpay_amt float64 = 0
  1847. var laboratory_fulamt_ownpay_amt float64 = 0
  1848. var treat_fulamt_ownpay_amt float64 = 0
  1849. var bed_claa_sunmfee float64 = 0
  1850. var bed_clab_amt float64 = 0
  1851. var bed_other_amt float64 = 0
  1852. var operation_claa_sunmfee float64 = 0
  1853. var operation_clab_amt float64 = 0
  1854. var operation_other_amt float64 = 0
  1855. var other_claa_sunmfee float64 = 0
  1856. var other_clab_amt float64 = 0
  1857. var other_other_amt float64 = 0
  1858. var westernMedicine_claa_sunmfee float64 = 0
  1859. var westernMedicine_clab_amt float64 = 0
  1860. var westernMedicine_other_amt float64 = 0
  1861. var chineseTraditional_claa_sunmfee float64 = 0
  1862. var chineseTraditional_clab_amt float64 = 0
  1863. var chineseTraditional_other_amt float64 = 0
  1864. var check_claa_sunmfee float64 = 0
  1865. var check_clab_amt float64 = 0
  1866. var check_other_amt float64 = 0
  1867. var material_claa_sunmfee float64 = 0
  1868. var material_clab_amt float64 = 0
  1869. var material_other_amt float64 = 0
  1870. var laboratory_claa_sunmfee float64 = 0
  1871. var laboratory_clab_amt float64 = 0
  1872. var laboratory_other_amt float64 = 0
  1873. var treat_claa_sunmfee float64 = 0
  1874. var treat_clab_amt float64 = 0
  1875. var treat_other_amt float64 = 0
  1876. for _, item := range order.HisOrderInfo {
  1877. if item.MedChrgitmType == "01" { //床位费
  1878. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1879. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1880. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1881. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1882. if item.ChrgitmLv == "1" {
  1883. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1884. }
  1885. if item.ChrgitmLv == "2" {
  1886. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1887. }
  1888. if item.ChrgitmLv == "3" {
  1889. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1890. }
  1891. }
  1892. if item.MedChrgitmType == "03" { //检查费
  1893. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1894. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1895. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1896. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1897. if item.ChrgitmLv == "1" {
  1898. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1899. }
  1900. if item.ChrgitmLv == "2" {
  1901. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1902. }
  1903. if item.ChrgitmLv == "3" {
  1904. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1905. }
  1906. }
  1907. if item.MedChrgitmType == "04" { //化验费
  1908. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1909. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1910. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1911. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1912. if item.ChrgitmLv == "1" {
  1913. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1914. }
  1915. if item.ChrgitmLv == "2" {
  1916. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1917. }
  1918. if item.ChrgitmLv == "3" {
  1919. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1920. }
  1921. }
  1922. if item.MedChrgitmType == "05" { //治疗费
  1923. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1924. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1925. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1926. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1927. if item.ChrgitmLv == "1" {
  1928. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1929. }
  1930. if item.ChrgitmLv == "2" {
  1931. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1932. }
  1933. if item.ChrgitmLv == "3" {
  1934. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1935. }
  1936. }
  1937. if item.MedChrgitmType == "06" { //手术费
  1938. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1939. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1940. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1941. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1942. if item.ChrgitmLv == "1" {
  1943. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1944. }
  1945. if item.ChrgitmLv == "2" {
  1946. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1947. }
  1948. if item.ChrgitmLv == "3" {
  1949. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1950. }
  1951. }
  1952. if item.MedChrgitmType == "08" { //材料费
  1953. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1954. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1955. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1956. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1957. if item.ChrgitmLv == "1" {
  1958. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1959. }
  1960. if item.ChrgitmLv == "2" {
  1961. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1962. }
  1963. if item.ChrgitmLv == "3" {
  1964. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1965. }
  1966. }
  1967. if item.MedChrgitmType == "09" { //西药费
  1968. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1969. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1970. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1971. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1972. if item.ChrgitmLv == "1" {
  1973. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1974. }
  1975. if item.ChrgitmLv == "2" {
  1976. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1977. }
  1978. if item.ChrgitmLv == "3" {
  1979. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1980. }
  1981. }
  1982. if item.MedChrgitmType == "11" { //中成费
  1983. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1984. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1985. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1986. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  1987. if item.ChrgitmLv == "1" {
  1988. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1989. }
  1990. if item.ChrgitmLv == "2" {
  1991. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  1992. }
  1993. if item.ChrgitmLv == "3" {
  1994. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  1995. }
  1996. }
  1997. if item.MedChrgitmType == "14" { //其他费
  1998. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  1999. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2000. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2001. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2002. if item.ChrgitmLv == "1" {
  2003. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2004. }
  2005. if item.ChrgitmLv == "2" {
  2006. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2007. }
  2008. if item.ChrgitmLv == "3" {
  2009. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2010. }
  2011. }
  2012. }
  2013. var iteminfoStructs []service.IteminfoStruct
  2014. if bedCostTotal != 0 {
  2015. iteminfo.MedChrgitm = "01"
  2016. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2017. iteminfo.Amt = bedCostTotal
  2018. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2019. iteminfo.ClabAmt = bed_clab_amt
  2020. iteminfo.OthAmt = bed_other_amt
  2021. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2022. }
  2023. if checkCostTotal != 0 {
  2024. iteminfo.MedChrgitm = "03"
  2025. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2026. iteminfo.Amt = checkCostTotal
  2027. iteminfo.ClaaSumfee = check_claa_sunmfee
  2028. iteminfo.ClabAmt = check_clab_amt
  2029. iteminfo.OthAmt = check_other_amt
  2030. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2031. }
  2032. if laboratoryCostTotal != 0 {
  2033. iteminfo.MedChrgitm = "04"
  2034. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2035. iteminfo.Amt = laboratoryCostTotal
  2036. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2037. iteminfo.ClabAmt = laboratory_clab_amt
  2038. iteminfo.OthAmt = laboratory_other_amt
  2039. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2040. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2041. }
  2042. if treatCostTotal != 0 {
  2043. iteminfo.MedChrgitm = "05"
  2044. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2045. iteminfo.Amt = treatCostTotal
  2046. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2047. iteminfo.ClabAmt = treat_clab_amt
  2048. iteminfo.OthAmt = treat_other_amt
  2049. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2050. //(struct4101.IteminfoStruct, iteminfo)
  2051. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2052. }
  2053. if operationCostTotal != 0 {
  2054. iteminfo.MedChrgitm = "06"
  2055. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2056. iteminfo.Amt = operationCostTotal
  2057. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2058. iteminfo.ClabAmt = operation_clab_amt
  2059. iteminfo.OthAmt = operation_other_amt
  2060. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2061. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2062. }
  2063. if materialCostTotal != 0 {
  2064. iteminfo.MedChrgitm = "08"
  2065. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2066. iteminfo.Amt = materialCostTotal
  2067. iteminfo.ClaaSumfee = material_claa_sunmfee
  2068. iteminfo.ClabAmt = material_clab_amt
  2069. iteminfo.OthAmt = material_other_amt
  2070. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2071. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2072. }
  2073. if westernMedicineCostTotal != 0 {
  2074. iteminfo.MedChrgitm = "09"
  2075. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2076. iteminfo.Amt = westernMedicineCostTotal
  2077. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2078. iteminfo.ClabAmt = westernMedicine_clab_amt
  2079. iteminfo.OthAmt = westernMedicine_other_amt
  2080. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2081. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2082. }
  2083. if chineseTraditionalMedicineCostTotal != 0 {
  2084. iteminfo.MedChrgitm = "11"
  2085. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2086. iteminfo.Amt = westernMedicineCostTotal
  2087. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2088. iteminfo.ClabAmt = westernMedicine_clab_amt
  2089. iteminfo.OthAmt = westernMedicine_other_amt
  2090. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2091. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2092. }
  2093. if otherCostTotal != 0 {
  2094. iteminfo.MedChrgitm = "14"
  2095. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2096. iteminfo.Amt = otherCostTotal
  2097. iteminfo.ClaaSumfee = other_claa_sunmfee
  2098. iteminfo.ClabAmt = other_clab_amt
  2099. iteminfo.OthAmt = other_other_amt
  2100. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2101. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2102. }
  2103. struct4101.IteminfoStruct = iteminfoStructs
  2104. struct4101.Ntly = "中国"
  2105. struct4101.AdmCaty = "A03.06"
  2106. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2107. fmt.Println(result)
  2108. var dat map[string]interface{}
  2109. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2110. fmt.Println(dat)
  2111. } else {
  2112. fmt.Println(err)
  2113. }
  2114. userJSONBytes, _ := json.Marshal(dat)
  2115. var res ResultSeventeen
  2116. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2117. utils.ErrorLog("解析失败:%v", err)
  2118. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2119. return
  2120. }
  2121. if res.Infcode != 0 {
  2122. c.ServeSuccessJSON(map[string]interface{}{
  2123. "failed_code": -10,
  2124. "msg": res.ErrMsg,
  2125. })
  2126. return
  2127. } else {
  2128. order.FaPiaoNumber = zero
  2129. order.FaPiaoCode = last_order.FaPiaoCode
  2130. service.UpdateOrder(order)
  2131. hisFundSettleListResult := &models.HisFundSettleListResult{
  2132. Number: res.Output.SetlListId,
  2133. Status: 1,
  2134. Ctime: time.Now().Unix(),
  2135. Mtime: time.Now().Unix(),
  2136. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2137. IsUpload: 1,
  2138. OrderId: order_id,
  2139. }
  2140. service.CreateUploadRecord(hisFundSettleListResult)
  2141. c.ServeSuccessJSON(map[string]interface{}{
  2142. "msg": "上传成功",
  2143. "result": hisFundSettleListResult,
  2144. })
  2145. return
  2146. }
  2147. }
  2148. func (c *HisApiController) GetSettleListHospital() {
  2149. order_id, _ := c.GetInt64("order_id")
  2150. admin_user_id, _ := c.GetInt64("admin_user_id")
  2151. order, _ := service.GetHisOrderByIDTwo(order_id)
  2152. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2153. his, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  2154. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2155. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  2156. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2157. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2158. if order.ID == 0 {
  2159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2160. return
  2161. }
  2162. last_order, _ := service.GetLastHisOrder(c.GetAdminUserInfo().CurrentOrgId)
  2163. max_order, _ := service.GetLastHisOrderTwo(c.GetAdminUserInfo().CurrentOrgId)
  2164. count, _ := strconv.ParseInt(max_order.FaPiaoNumber, 10, 64)
  2165. fmt.Println(count)
  2166. var zero string
  2167. number := count + 1
  2168. if number >= 1000 {
  2169. zero = "0000" + strconv.FormatInt(number, 10)
  2170. } else if number >= 10000 {
  2171. zero = "000" + strconv.FormatInt(number, 10)
  2172. } else if number >= 100000 {
  2173. zero = "00" + strconv.FormatInt(number, 10)
  2174. } else if number >= 1000000 {
  2175. zero = "0" + strconv.FormatInt(number, 10)
  2176. } else {
  2177. zero = strconv.FormatInt(number, 10)
  2178. }
  2179. fmt.Println(zero)
  2180. struct4101 := service.Struct4101{
  2181. PsnNo: order.PsnNo,
  2182. MdtrtId: order.MdtrtId,
  2183. SetlId: order.SetlId,
  2184. PsnName: order.PsnName,
  2185. Gend: order.Gend,
  2186. Brdy: his.Brdy,
  2187. Age: int64(order.Age),
  2188. Naty: order.Naty,
  2189. PatnCertType: "01",
  2190. Certno: order.Certno,
  2191. Prfs: "90",
  2192. ConerName: roles[0].UserName,
  2193. PatnRlts: "99",
  2194. ConerAddr: miConfig.OrgName,
  2195. ConerTel: admin.Mobile,
  2196. HiType: order.Insutype,
  2197. Insuplc: miConfig.InsuplcAdmdvs,
  2198. MaindiagFlag: "1",
  2199. BillCode: last_order.FaPiaoCode,
  2200. BillNo: zero,
  2201. BizSn: order.Number,
  2202. PsnSelfPay: order.PsnPartAmt,
  2203. PsnOwnPay: order.PsnPartAmt,
  2204. AcctPay: order.AcctPay,
  2205. PsnCashpay: order.PsnCashPay,
  2206. HiPaymtd: "1",
  2207. Hsorg: miConfig.InsuplcAdmdvs,
  2208. HsorgOpter: miConfig.InsuplcAdmdvs,
  2209. MedinsFillPsn: curRoles.UserName,
  2210. MedinsFillDept: depart.Name,
  2211. IptMedType: "2",
  2212. AdmTime: his.InHosptialTime,
  2213. AdmEndTime: his.OutHosptialTime,
  2214. }
  2215. struct4101.SetlBegnDate = order.SetlTime
  2216. struct4101.SetlEndDate = order.SetlTime
  2217. var rf []CustomFundPay
  2218. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2219. var tempFunPays []service.CustomStruct
  2220. for _, item := range rf {
  2221. var tempFunPay service.CustomStruct
  2222. tempFunPay.FundPayamt = item.FundPayamt
  2223. tempFunPay.FundPayType = item.FundPayType
  2224. tempFunPays = append(tempFunPays, tempFunPay)
  2225. }
  2226. struct4101.CustomStruct = tempFunPays
  2227. var tempDiaginfos []service.DiaginfoStructTwo
  2228. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2229. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2230. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2231. var config []*models.HisXtDiagnoseConfig
  2232. for _, item := range diagnosis_ids {
  2233. id, _ := strconv.ParseInt(item, 10, 64)
  2234. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2235. config = append(config, &diagnosisConfig)
  2236. }
  2237. for index, item := range config {
  2238. if index == 0 {
  2239. var tempDiaginfo service.DiaginfoStructTwo
  2240. tempDiaginfo.DiagCode = item.CountryCode
  2241. tempDiaginfo.DiagName = item.CountryContentName
  2242. tempDiaginfo.DiagType = "1"
  2243. tempDiaginfo.MaindiagFlag = "1"
  2244. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2245. } else {
  2246. var tempDiaginfo service.DiaginfoStructTwo
  2247. tempDiaginfo.DiagCode = item.CountryCode
  2248. tempDiaginfo.DiagName = item.CountryContentName
  2249. tempDiaginfo.DiagType = "2"
  2250. tempDiaginfo.MaindiagFlag = "0"
  2251. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2252. }
  2253. }
  2254. struct4101.Diseinfo = tempDiaginfos
  2255. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2256. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2257. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2258. tempOpspdiseinfo2.OprnOprtCode = ""
  2259. tempOpspdiseinfo2.OprnOprtName = ""
  2260. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2261. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2262. var iteminfo service.IteminfoStruct
  2263. var bedCostTotal float64 = 0 //床位总费
  2264. var bedCostSelfTotal float64 = 0 //床位自费
  2265. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2266. var operationCostTotal float64 = 0 //手术费
  2267. var operationCostSelfTotal float64 = 0 //手术费
  2268. var operationCostPartSelfTotal float64 = 0 //手术费
  2269. var otherCostTotal float64 = 0 //其他费用
  2270. var otherCostSelfTotal float64 = 0 //其他费用
  2271. var otherCostPartSelfTotal float64 = 0 //其他费用
  2272. var materialCostTotal float64 = 0 //材料费
  2273. var materialCostSelfTotal float64 = 0 //材料费
  2274. var materialCostPartSelfTotal float64 = 0 //材料费
  2275. var westernMedicineCostTotal float64 = 0 //西药费
  2276. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2277. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2278. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2279. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2280. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2281. var checkCostTotal float64 = 0 //检查费
  2282. var checkCostSelfTotal float64 = 0 //检查费
  2283. var checkCostPartSelfTotal float64 = 0 //检查费
  2284. var laboratoryCostTotal float64 = 0 //化验费
  2285. var laboratoryCostSelfTotal float64 = 0 //化验费
  2286. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2287. var treatCostTotal float64 = 0 //治疗费用
  2288. var treatCostSelfTotal float64 = 0 //治疗费用
  2289. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2290. decimal.DivisionPrecision = 2
  2291. var bed_fulamt_ownpay_amt float64 = 0
  2292. var operation_fulamt_ownpay_amt float64 = 0
  2293. var other_fulamt_ownpay_amt float64 = 0
  2294. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2295. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2296. var check_fulamt_ownpay_amt float64 = 0
  2297. var material_fulamt_ownpay_amt float64 = 0
  2298. var laboratory_fulamt_ownpay_amt float64 = 0
  2299. var treat_fulamt_ownpay_amt float64 = 0
  2300. var bed_claa_sunmfee float64 = 0
  2301. var bed_clab_amt float64 = 0
  2302. var bed_other_amt float64 = 0
  2303. var operation_claa_sunmfee float64 = 0
  2304. var operation_clab_amt float64 = 0
  2305. var operation_other_amt float64 = 0
  2306. var other_claa_sunmfee float64 = 0
  2307. var other_clab_amt float64 = 0
  2308. var other_other_amt float64 = 0
  2309. var westernMedicine_claa_sunmfee float64 = 0
  2310. var westernMedicine_clab_amt float64 = 0
  2311. var westernMedicine_other_amt float64 = 0
  2312. var chineseTraditional_claa_sunmfee float64 = 0
  2313. var chineseTraditional_clab_amt float64 = 0
  2314. var chineseTraditional_other_amt float64 = 0
  2315. var check_claa_sunmfee float64 = 0
  2316. var check_clab_amt float64 = 0
  2317. var check_other_amt float64 = 0
  2318. var material_claa_sunmfee float64 = 0
  2319. var material_clab_amt float64 = 0
  2320. var material_other_amt float64 = 0
  2321. var laboratory_claa_sunmfee float64 = 0
  2322. var laboratory_clab_amt float64 = 0
  2323. var laboratory_other_amt float64 = 0
  2324. var treat_claa_sunmfee float64 = 0
  2325. var treat_clab_amt float64 = 0
  2326. var treat_other_amt float64 = 0
  2327. for _, item := range order.HisOrderInfo {
  2328. if item.MedChrgitmType == "01" { //床位费
  2329. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2330. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2331. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2332. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2333. if item.ChrgitmLv == "1" {
  2334. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2335. }
  2336. if item.ChrgitmLv == "2" {
  2337. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2338. }
  2339. if item.ChrgitmLv == "3" {
  2340. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2341. }
  2342. }
  2343. if item.MedChrgitmType == "03" { //检查费
  2344. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2345. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2346. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2347. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2348. if item.ChrgitmLv == "1" {
  2349. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2350. }
  2351. if item.ChrgitmLv == "2" {
  2352. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2353. }
  2354. if item.ChrgitmLv == "3" {
  2355. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2356. }
  2357. }
  2358. if item.MedChrgitmType == "04" { //化验费
  2359. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2360. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2361. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2362. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2363. if item.ChrgitmLv == "1" {
  2364. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2365. }
  2366. if item.ChrgitmLv == "2" {
  2367. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2368. }
  2369. if item.ChrgitmLv == "3" {
  2370. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2371. }
  2372. }
  2373. if item.MedChrgitmType == "05" { //治疗费
  2374. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2375. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2376. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2377. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2378. if item.ChrgitmLv == "1" {
  2379. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2380. }
  2381. if item.ChrgitmLv == "2" {
  2382. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2383. }
  2384. if item.ChrgitmLv == "3" {
  2385. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2386. }
  2387. }
  2388. if item.MedChrgitmType == "06" { //手术费
  2389. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2390. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2391. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2392. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2393. if item.ChrgitmLv == "1" {
  2394. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2395. }
  2396. if item.ChrgitmLv == "2" {
  2397. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2398. }
  2399. if item.ChrgitmLv == "3" {
  2400. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2401. }
  2402. }
  2403. if item.MedChrgitmType == "08" { //材料费
  2404. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2405. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2406. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2407. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2408. if item.ChrgitmLv == "1" {
  2409. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2410. }
  2411. if item.ChrgitmLv == "2" {
  2412. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2413. }
  2414. if item.ChrgitmLv == "3" {
  2415. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2416. }
  2417. }
  2418. if item.MedChrgitmType == "09" { //西药费
  2419. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2420. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2421. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2422. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2423. if item.ChrgitmLv == "1" {
  2424. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2425. }
  2426. if item.ChrgitmLv == "2" {
  2427. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2428. }
  2429. if item.ChrgitmLv == "3" {
  2430. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2431. }
  2432. }
  2433. if item.MedChrgitmType == "11" { //中成费
  2434. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2435. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2436. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2437. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2438. if item.ChrgitmLv == "1" {
  2439. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2440. }
  2441. if item.ChrgitmLv == "2" {
  2442. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2443. }
  2444. if item.ChrgitmLv == "3" {
  2445. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2446. }
  2447. }
  2448. if item.MedChrgitmType == "14" { //其他费
  2449. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2450. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2451. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2452. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2453. if item.ChrgitmLv == "1" {
  2454. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2455. }
  2456. if item.ChrgitmLv == "2" {
  2457. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2458. }
  2459. if item.ChrgitmLv == "3" {
  2460. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2461. }
  2462. }
  2463. }
  2464. var iteminfoStructs []service.IteminfoStruct
  2465. if bedCostTotal != 0 {
  2466. iteminfo.MedChrgitm = "01"
  2467. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2468. iteminfo.Amt = bedCostTotal
  2469. iteminfo.ClaaSumfee = bed_claa_sunmfee
  2470. iteminfo.ClabAmt = bed_clab_amt
  2471. iteminfo.OthAmt = bed_other_amt
  2472. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2473. }
  2474. if checkCostTotal != 0 {
  2475. iteminfo.MedChrgitm = "03"
  2476. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  2477. iteminfo.Amt = checkCostTotal
  2478. iteminfo.ClaaSumfee = check_claa_sunmfee
  2479. iteminfo.ClabAmt = check_clab_amt
  2480. iteminfo.OthAmt = check_other_amt
  2481. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2482. }
  2483. if laboratoryCostTotal != 0 {
  2484. iteminfo.MedChrgitm = "04"
  2485. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  2486. iteminfo.Amt = laboratoryCostTotal
  2487. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  2488. iteminfo.ClabAmt = laboratory_clab_amt
  2489. iteminfo.OthAmt = laboratory_other_amt
  2490. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2491. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2492. }
  2493. if treatCostTotal != 0 {
  2494. iteminfo.MedChrgitm = "05"
  2495. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  2496. iteminfo.Amt = treatCostTotal
  2497. iteminfo.ClaaSumfee = treat_claa_sunmfee
  2498. iteminfo.ClabAmt = treat_clab_amt
  2499. iteminfo.OthAmt = treat_other_amt
  2500. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2501. //(struct4101.IteminfoStruct, iteminfo)
  2502. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2503. }
  2504. if operationCostTotal != 0 {
  2505. iteminfo.MedChrgitm = "06"
  2506. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  2507. iteminfo.Amt = operationCostTotal
  2508. iteminfo.ClaaSumfee = operation_claa_sunmfee
  2509. iteminfo.ClabAmt = operation_clab_amt
  2510. iteminfo.OthAmt = operation_other_amt
  2511. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2512. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2513. }
  2514. if materialCostTotal != 0 {
  2515. iteminfo.MedChrgitm = "08"
  2516. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  2517. iteminfo.Amt = materialCostTotal
  2518. iteminfo.ClaaSumfee = material_claa_sunmfee
  2519. iteminfo.ClabAmt = material_clab_amt
  2520. iteminfo.OthAmt = material_other_amt
  2521. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2522. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2523. }
  2524. if westernMedicineCostTotal != 0 {
  2525. iteminfo.MedChrgitm = "09"
  2526. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2527. iteminfo.Amt = westernMedicineCostTotal
  2528. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2529. iteminfo.ClabAmt = westernMedicine_clab_amt
  2530. iteminfo.OthAmt = westernMedicine_other_amt
  2531. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2532. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2533. }
  2534. if chineseTraditionalMedicineCostTotal != 0 {
  2535. iteminfo.MedChrgitm = "11"
  2536. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  2537. iteminfo.Amt = westernMedicineCostTotal
  2538. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  2539. iteminfo.ClabAmt = westernMedicine_clab_amt
  2540. iteminfo.OthAmt = westernMedicine_other_amt
  2541. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2542. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2543. }
  2544. if otherCostTotal != 0 {
  2545. iteminfo.MedChrgitm = "14"
  2546. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  2547. iteminfo.Amt = otherCostTotal
  2548. iteminfo.ClaaSumfee = other_claa_sunmfee
  2549. iteminfo.ClabAmt = other_clab_amt
  2550. iteminfo.OthAmt = other_other_amt
  2551. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  2552. iteminfoStructs = append(iteminfoStructs, iteminfo)
  2553. }
  2554. struct4101.IteminfoStruct = iteminfoStructs
  2555. struct4101.Ntly = "中国"
  2556. struct4101.AdmCaty = "A03.06"
  2557. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.UserOrgId)
  2558. fmt.Println(result)
  2559. var dat map[string]interface{}
  2560. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2561. fmt.Println(dat)
  2562. } else {
  2563. fmt.Println(err)
  2564. }
  2565. userJSONBytes, _ := json.Marshal(dat)
  2566. var res ResultSeventeen
  2567. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2568. utils.ErrorLog("解析失败:%v", err)
  2569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2570. return
  2571. }
  2572. if res.Infcode != 0 {
  2573. c.ServeSuccessJSON(map[string]interface{}{
  2574. "failed_code": -10,
  2575. "msg": res.ErrMsg,
  2576. })
  2577. return
  2578. } else {
  2579. order.FaPiaoNumber = zero
  2580. order.FaPiaoCode = last_order.FaPiaoCode
  2581. service.UpdateOrder(order)
  2582. hisFundSettleListResult := &models.HisFundSettleListResult{
  2583. Number: res.Output.SetlListId,
  2584. Status: 1,
  2585. Ctime: time.Now().Unix(),
  2586. Mtime: time.Now().Unix(),
  2587. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  2588. IsUpload: 1,
  2589. OrderId: order_id,
  2590. }
  2591. service.CreateUploadRecord(hisFundSettleListResult)
  2592. c.ServeSuccessJSON(map[string]interface{}{
  2593. "msg": "上传成功",
  2594. "result": hisFundSettleListResult,
  2595. })
  2596. return
  2597. }
  2598. }
  2599. func (c *HisApiController) GetBatchSettleList() {
  2600. orders, _ := service.GetAllHisOrder(10106)
  2601. for _, item := range orders {
  2602. order_id := item.ID
  2603. order, _ := service.GetHisOrderByIDTwo(order_id)
  2604. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  2605. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  2606. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  2607. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, 2495)
  2608. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  2609. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  2610. if order.ID == 0 {
  2611. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2612. return
  2613. }
  2614. if his.BalanceAccountsType == 2 {
  2615. continue
  2616. }
  2617. struct4101 := service.Struct4101{
  2618. PsnNo: order.PsnNo,
  2619. MdtrtId: order.MdtrtId,
  2620. SetlId: order.SetlId,
  2621. PsnName: order.PsnName,
  2622. Gend: order.Gend,
  2623. Brdy: his.Brdy,
  2624. Age: his.Age,
  2625. Naty: order.Naty,
  2626. PatnCertType: "01",
  2627. Certno: order.Certno,
  2628. Prfs: "90",
  2629. ConerName: roles[0].UserName,
  2630. PatnRlts: "99",
  2631. ConerAddr: miConfig.OrgName,
  2632. ConerTel: admin.Mobile,
  2633. HiType: order.Insutype,
  2634. Insuplc: his.InsuplcAdmdvs,
  2635. MaindiagFlag: "1",
  2636. BillCode: order.FaPiaoCode,
  2637. BillNo: order.FaPiaoNumber,
  2638. BizSn: order.Number,
  2639. PsnSelfPay: order.PsnPartAmt,
  2640. PsnOwnPay: order.PsnPartAmt,
  2641. AcctPay: order.AcctPay,
  2642. PsnCashpay: order.PsnCashPay,
  2643. HiPaymtd: "1",
  2644. Hsorg: his.InsuplcAdmdvs,
  2645. HsorgOpter: his.InsuplcAdmdvs,
  2646. MedinsFillPsn: curRoles.UserName,
  2647. MedinsFillDept: depart.Name,
  2648. IptMedType: "2",
  2649. }
  2650. struct4101.SetlBegnDate = order.SetlTime
  2651. struct4101.SetlEndDate = order.SetlTime
  2652. //if order.SettleType == 1 {
  2653. // t := time.Unix(int64(order.SettleAccountsDate), 0)
  2654. // dateStr := t.Format("2006-01-02")
  2655. // struct4101.SetlBegnDate = dateStr
  2656. // struct4101.SetlEndDate = dateStr
  2657. //} else {
  2658. // t := time.Unix(int64(order.SettleStartTime), 0)
  2659. // t2 := time.Unix(int64(order.SettleEndTime), 0)
  2660. // dateStartStr := t.Format("2006-01-02")
  2661. // dateEndStr := t2.Format("2006-01-02")
  2662. // struct4101.SetlBegnDate = dateStartStr
  2663. // struct4101.SetlEndDate = dateEndStr
  2664. //}
  2665. var rf []CustomFundPay
  2666. json.Unmarshal([]byte(order.SetlDetail), &rf)
  2667. var tempFunPays []service.CustomStruct
  2668. var tempFunPay610100 service.CustomStruct
  2669. for _, item := range rf {
  2670. if item.FundPayType == "610100" {
  2671. tempFunPay610100.FundPayamt, _ = decimal.NewFromFloat(tempFunPay610100.FundPayamt).Add(decimal.NewFromFloat(item.FundPayamt)).Float64()
  2672. tempFunPay610100.FundPayType = item.FundPayType
  2673. } else {
  2674. var tempFunPay service.CustomStruct
  2675. tempFunPay.FundPayamt = item.FundPayamt
  2676. tempFunPay.FundPayType = item.FundPayType
  2677. tempFunPays = append(tempFunPays, tempFunPay)
  2678. }
  2679. }
  2680. tempFunPays = append(tempFunPays, tempFunPay610100)
  2681. struct4101.CustomStruct = tempFunPays
  2682. var tempDiaginfos []service.DiaginfoStructTwo
  2683. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  2684. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  2685. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  2686. var config []*models.HisXtDiagnoseConfig
  2687. for _, item := range diagnosis_ids {
  2688. id, _ := strconv.ParseInt(item, 10, 64)
  2689. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2690. config = append(config, &diagnosisConfig)
  2691. }
  2692. for index, item := range config {
  2693. if index == 0 {
  2694. var tempDiaginfo service.DiaginfoStructTwo
  2695. tempDiaginfo.DiagCode = item.CountryCode
  2696. tempDiaginfo.DiagName = item.CountryContentName
  2697. tempDiaginfo.DiagType = "1"
  2698. tempDiaginfo.MaindiagFlag = "1"
  2699. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2700. } else {
  2701. var tempDiaginfo service.DiaginfoStructTwo
  2702. tempDiaginfo.DiagCode = item.CountryCode
  2703. tempDiaginfo.DiagName = item.CountryContentName
  2704. tempDiaginfo.DiagType = "2"
  2705. tempDiaginfo.MaindiagFlag = "0"
  2706. tempDiaginfos = append(tempDiaginfos, tempDiaginfo)
  2707. }
  2708. }
  2709. struct4101.Diseinfo = tempDiaginfos
  2710. sickConfigTwo, _ := service.FindSickById(his.SickType)
  2711. tempOpspdiseinfo2.DiagCode = sickConfigTwo.ContentCode
  2712. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  2713. tempOpspdiseinfo2.OprnOprtCode = ""
  2714. tempOpspdiseinfo2.OprnOprtName = ""
  2715. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  2716. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  2717. var iteminfo service.IteminfoStruct
  2718. var bedCostTotal float64 = 0 //床位总费
  2719. var bedCostSelfTotal float64 = 0 //床位自费
  2720. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  2721. var examineCostTotal float64 = 0 //诊查总费
  2722. var examineCostSelfTotal float64 = 0 //诊查自费
  2723. var examineCostPartSelfTotal float64 = 0 //诊查部分项目自费
  2724. var nursingCostTotal float64 = 0 //护理总费
  2725. var nursingCostSelfTotal float64 = 0 //护理自费
  2726. var nursingCostPartSelfTotal float64 = 0 //护理部分项目自费
  2727. var chineseMedicineCostTotal float64 = 0 //中成药
  2728. var chineseMedicineCostSelfTotal float64 = 0 //中成药
  2729. var chineseMedicineCostPartSelfTotal float64 = 0 //中成药
  2730. var commonlyTreatmentCostTotal float64 = 0 //一般诊疗费
  2731. var commonlyTreatmentCostSelfTotal float64 = 0 //一般诊疗费
  2732. var commonlyTreatmentCostPartSelfTotal float64 = 0 //一般诊疗费
  2733. var registerCostTotal float64 = 0 //一般诊疗费
  2734. var registerCostSelfTotal float64 = 0 //一般诊疗费
  2735. var registerPartSelfTotal float64 = 0 //一般诊疗费
  2736. var operationCostTotal float64 = 0 //手术费
  2737. var operationCostSelfTotal float64 = 0 //手术费
  2738. var operationCostPartSelfTotal float64 = 0 //手术费
  2739. var otherCostTotal float64 = 0 //其他费用
  2740. var otherCostSelfTotal float64 = 0 //其他费用
  2741. var otherCostPartSelfTotal float64 = 0 //其他费用
  2742. var materialCostTotal float64 = 0 //材料费
  2743. var materialCostSelfTotal float64 = 0 //材料费
  2744. var materialCostPartSelfTotal float64 = 0 //材料费
  2745. var westernMedicineCostTotal float64 = 0 //西药费
  2746. var westernMedicineCostSelfTotal float64 = 0 //西药费
  2747. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  2748. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  2749. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  2750. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  2751. var checkCostTotal float64 = 0 //检查费
  2752. var checkCostSelfTotal float64 = 0 //检查费
  2753. var checkCostPartSelfTotal float64 = 0 //检查费
  2754. var laboratoryCostTotal float64 = 0 //化验费
  2755. var laboratoryCostSelfTotal float64 = 0 //化验费
  2756. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  2757. var treatCostTotal float64 = 0 //治疗费用
  2758. var treatCostSelfTotal float64 = 0 //治疗费用
  2759. var treatCostPartSelfTotal float64 = 0 //治疗费用
  2760. decimal.DivisionPrecision = 2
  2761. var bed_fulamt_ownpay_amt float64 = 0
  2762. var examine_fulamt_ownpay_amt float64 = 0
  2763. var nursing_fulamt_ownpay_amt float64 = 0
  2764. var chinese_medicine_fulamt_ownpay_amt float64 = 0
  2765. var commonly_treatment_fulamt_ownpay_amt float64 = 0
  2766. var register_fulamt_ownpay_amt float64 = 0
  2767. var operation_fulamt_ownpay_amt float64 = 0
  2768. var other_fulamt_ownpay_amt float64 = 0
  2769. var westernMedicine_fulamt_ownpay_amt float64 = 0
  2770. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  2771. var check_fulamt_ownpay_amt float64 = 0
  2772. var material_fulamt_ownpay_amt float64 = 0
  2773. var laboratory_fulamt_ownpay_amt float64 = 0
  2774. var treat_fulamt_ownpay_amt float64 = 0
  2775. var bed_claa_sunmfee float64 = 0
  2776. var bed_clab_amt float64 = 0
  2777. var bed_other_amt float64 = 0
  2778. var examine_claa_sunmfee float64 = 0
  2779. var examine_clab_amt float64 = 0
  2780. var examine_other_amt float64 = 0
  2781. var nursing_claa_sunmfee float64 = 0
  2782. var nursing_clab_amt float64 = 0
  2783. var nursing_other_amt float64 = 0
  2784. var chinese_medicine_claa_sunmfee float64 = 0
  2785. var chinese_medicine_clab_amt float64 = 0
  2786. var chinese_medicine_other_amt float64 = 0
  2787. var commonly_treatment_claa_sunmfee float64 = 0
  2788. var commonly_treatment_clab_amt float64 = 0
  2789. var commonly_treatment_other_amt float64 = 0
  2790. var operation_claa_sunmfee float64 = 0
  2791. var operation_clab_amt float64 = 0
  2792. var operation_other_amt float64 = 0
  2793. var other_claa_sunmfee float64 = 0
  2794. var other_clab_amt float64 = 0
  2795. var other_other_amt float64 = 0
  2796. var westernMedicine_claa_sunmfee float64 = 0
  2797. var westernMedicine_clab_amt float64 = 0
  2798. var westernMedicine_other_amt float64 = 0
  2799. var chineseTraditional_claa_sunmfee float64 = 0
  2800. var chineseTraditional_clab_amt float64 = 0
  2801. var chineseTraditional_other_amt float64 = 0
  2802. var check_claa_sunmfee float64 = 0
  2803. var check_clab_amt float64 = 0
  2804. var check_other_amt float64 = 0
  2805. var material_claa_sunmfee float64 = 0
  2806. var material_clab_amt float64 = 0
  2807. var material_other_amt float64 = 0
  2808. var laboratory_claa_sunmfee float64 = 0
  2809. var laboratory_clab_amt float64 = 0
  2810. var laboratory_other_amt float64 = 0
  2811. var treat_claa_sunmfee float64 = 0
  2812. var treat_clab_amt float64 = 0
  2813. var treat_other_amt float64 = 0
  2814. var register_claa_sunmfee float64 = 0
  2815. var register_clab_amt float64 = 0
  2816. var register_other_amt float64 = 0
  2817. for _, item := range order.HisOrderInfo {
  2818. if item.MedChrgitmType == "01" { //床位费
  2819. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2820. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2821. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2822. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2823. if item.ChrgitmLv == "1" {
  2824. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2825. }
  2826. if item.ChrgitmLv == "2" {
  2827. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2828. }
  2829. if item.ChrgitmLv == "3" {
  2830. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2831. }
  2832. }
  2833. if item.MedChrgitmType == "02" { //诊查
  2834. examineCostTotal, _ = decimal.NewFromFloat(examineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2835. examineCostSelfTotal, _ = decimal.NewFromFloat(examineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2836. examineCostPartSelfTotal, _ = decimal.NewFromFloat(examineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2837. examine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(examine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2838. if item.ChrgitmLv == "1" {
  2839. examine_claa_sunmfee, _ = decimal.NewFromFloat(examine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2840. }
  2841. if item.ChrgitmLv == "2" {
  2842. examine_clab_amt, _ = decimal.NewFromFloat(examine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2843. }
  2844. if item.ChrgitmLv == "3" {
  2845. examine_other_amt, _ = decimal.NewFromFloat(examine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2846. }
  2847. }
  2848. if item.MedChrgitmType == "03" { //检查费
  2849. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2850. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2851. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2852. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2853. if item.ChrgitmLv == "1" {
  2854. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2855. }
  2856. if item.ChrgitmLv == "2" {
  2857. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2858. }
  2859. if item.ChrgitmLv == "3" {
  2860. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2861. }
  2862. }
  2863. if item.MedChrgitmType == "04" { //化验费
  2864. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2865. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2866. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2867. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2868. if item.ChrgitmLv == "1" {
  2869. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2870. }
  2871. if item.ChrgitmLv == "2" {
  2872. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2873. }
  2874. if item.ChrgitmLv == "3" {
  2875. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2876. }
  2877. }
  2878. if item.MedChrgitmType == "05" { //治疗费
  2879. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2880. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2881. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2882. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2883. if item.ChrgitmLv == "1" {
  2884. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2885. }
  2886. if item.ChrgitmLv == "2" {
  2887. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2888. }
  2889. if item.ChrgitmLv == "3" {
  2890. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2891. }
  2892. }
  2893. if item.MedChrgitmType == "06" { //手术费
  2894. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2895. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2896. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2897. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2898. if item.ChrgitmLv == "1" {
  2899. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2900. }
  2901. if item.ChrgitmLv == "2" {
  2902. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2903. }
  2904. if item.ChrgitmLv == "3" {
  2905. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2906. }
  2907. }
  2908. if item.MedChrgitmType == "07" { //手术费
  2909. nursingCostTotal, _ = decimal.NewFromFloat(nursingCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2910. nursingCostSelfTotal, _ = decimal.NewFromFloat(nursingCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2911. nursingCostPartSelfTotal, _ = decimal.NewFromFloat(nursingCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2912. nursing_fulamt_ownpay_amt, _ = decimal.NewFromFloat(nursing_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2913. if item.ChrgitmLv == "1" {
  2914. nursing_claa_sunmfee, _ = decimal.NewFromFloat(nursing_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2915. }
  2916. if item.ChrgitmLv == "2" {
  2917. nursing_clab_amt, _ = decimal.NewFromFloat(nursing_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2918. }
  2919. if item.ChrgitmLv == "3" {
  2920. nursing_other_amt, _ = decimal.NewFromFloat(nursing_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2921. }
  2922. }
  2923. if item.MedChrgitmType == "08" { //材料费
  2924. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2925. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2926. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2927. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2928. if item.ChrgitmLv == "1" {
  2929. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2930. }
  2931. if item.ChrgitmLv == "2" {
  2932. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2933. }
  2934. if item.ChrgitmLv == "3" {
  2935. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2936. }
  2937. }
  2938. if item.MedChrgitmType == "09" { //西药费
  2939. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2940. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2941. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2942. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2943. if item.ChrgitmLv == "1" {
  2944. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2945. }
  2946. if item.ChrgitmLv == "2" {
  2947. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2948. }
  2949. if item.ChrgitmLv == "3" {
  2950. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2951. }
  2952. }
  2953. if item.MedChrgitmType == "10" { //中药饮片
  2954. chineseMedicineCostTotal, _ = decimal.NewFromFloat(chineseMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2955. chineseMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2956. chineseMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2957. chinese_medicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chinese_medicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2958. if item.ChrgitmLv == "1" {
  2959. chinese_medicine_claa_sunmfee, _ = decimal.NewFromFloat(chinese_medicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2960. }
  2961. if item.ChrgitmLv == "2" {
  2962. chinese_medicine_clab_amt, _ = decimal.NewFromFloat(chinese_medicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2963. }
  2964. if item.ChrgitmLv == "3" {
  2965. chinese_medicine_other_amt, _ = decimal.NewFromFloat(chinese_medicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2966. }
  2967. }
  2968. if item.MedChrgitmType == "11" { //中成费
  2969. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2970. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2971. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2972. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2973. if item.ChrgitmLv == "1" {
  2974. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2975. }
  2976. if item.ChrgitmLv == "2" {
  2977. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2978. }
  2979. if item.ChrgitmLv == "3" {
  2980. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2981. }
  2982. }
  2983. if item.MedChrgitmType == "12" { //中成费
  2984. commonlyTreatmentCostTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2985. commonlyTreatmentCostSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2986. commonlyTreatmentCostPartSelfTotal, _ = decimal.NewFromFloat(commonlyTreatmentCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2987. commonly_treatment_fulamt_ownpay_amt, _ = decimal.NewFromFloat(commonly_treatment_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  2988. if item.ChrgitmLv == "1" {
  2989. commonly_treatment_claa_sunmfee, _ = decimal.NewFromFloat(commonly_treatment_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  2990. }
  2991. if item.ChrgitmLv == "2" {
  2992. commonly_treatment_clab_amt, _ = decimal.NewFromFloat(commonly_treatment_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  2993. }
  2994. if item.ChrgitmLv == "3" {
  2995. commonly_treatment_other_amt, _ = decimal.NewFromFloat(commonly_treatment_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  2996. }
  2997. }
  2998. if item.MedChrgitmType == "13" { //中成费
  2999. registerCostTotal, _ = decimal.NewFromFloat(registerCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3000. registerCostSelfTotal, _ = decimal.NewFromFloat(registerCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3001. registerPartSelfTotal, _ = decimal.NewFromFloat(registerPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3002. register_fulamt_ownpay_amt, _ = decimal.NewFromFloat(register_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3003. if item.ChrgitmLv == "1" {
  3004. register_claa_sunmfee, _ = decimal.NewFromFloat(register_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3005. }
  3006. if item.ChrgitmLv == "2" {
  3007. register_clab_amt, _ = decimal.NewFromFloat(register_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3008. }
  3009. if item.ChrgitmLv == "3" {
  3010. register_other_amt, _ = decimal.NewFromFloat(register_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3011. }
  3012. }
  3013. if item.MedChrgitmType == "14" { //其他费
  3014. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3015. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3016. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3017. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  3018. if item.ChrgitmLv == "1" {
  3019. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  3020. }
  3021. if item.ChrgitmLv == "2" {
  3022. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  3023. }
  3024. if item.ChrgitmLv == "3" {
  3025. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  3026. }
  3027. }
  3028. }
  3029. var iteminfoStructs []service.IteminfoStruct
  3030. if bedCostTotal != 0 {
  3031. iteminfo.MedChrgitm = "01"
  3032. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3033. iteminfo.Amt = bedCostTotal
  3034. iteminfo.ClaaSumfee = bed_claa_sunmfee
  3035. iteminfo.ClabAmt = bed_clab_amt
  3036. iteminfo.OthAmt = bed_other_amt
  3037. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3038. }
  3039. if examineCostTotal != 0 {
  3040. iteminfo.MedChrgitm = "02"
  3041. iteminfo.FulamtOwnpayAmt = examine_fulamt_ownpay_amt
  3042. iteminfo.Amt = examineCostTotal
  3043. iteminfo.ClaaSumfee = examine_claa_sunmfee
  3044. iteminfo.ClabAmt = examine_clab_amt
  3045. iteminfo.OthAmt = examine_other_amt
  3046. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3047. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3048. }
  3049. if checkCostTotal != 0 {
  3050. iteminfo.MedChrgitm = "03"
  3051. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  3052. iteminfo.Amt = checkCostTotal
  3053. iteminfo.ClaaSumfee = check_claa_sunmfee
  3054. iteminfo.ClabAmt = check_clab_amt
  3055. iteminfo.OthAmt = check_other_amt
  3056. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3057. }
  3058. if laboratoryCostTotal != 0 {
  3059. iteminfo.MedChrgitm = "04"
  3060. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  3061. iteminfo.Amt = laboratoryCostTotal
  3062. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  3063. iteminfo.ClabAmt = laboratory_clab_amt
  3064. iteminfo.OthAmt = laboratory_other_amt
  3065. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3066. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3067. }
  3068. if treatCostTotal != 0 {
  3069. iteminfo.MedChrgitm = "05"
  3070. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  3071. iteminfo.Amt = treatCostTotal
  3072. iteminfo.ClaaSumfee = treat_claa_sunmfee
  3073. iteminfo.ClabAmt = treat_clab_amt
  3074. iteminfo.OthAmt = treat_other_amt
  3075. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3076. //(struct4101.IteminfoStruct, iteminfo)
  3077. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3078. }
  3079. if operationCostTotal != 0 {
  3080. iteminfo.MedChrgitm = "06"
  3081. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  3082. iteminfo.Amt = operationCostTotal
  3083. iteminfo.ClaaSumfee = operation_claa_sunmfee
  3084. iteminfo.ClabAmt = operation_clab_amt
  3085. iteminfo.OthAmt = operation_other_amt
  3086. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3087. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3088. }
  3089. if nursingCostTotal != 0 {
  3090. iteminfo.MedChrgitm = "07"
  3091. iteminfo.FulamtOwnpayAmt = nursing_fulamt_ownpay_amt
  3092. iteminfo.Amt = nursingCostTotal
  3093. iteminfo.ClaaSumfee = nursing_claa_sunmfee
  3094. iteminfo.ClabAmt = nursing_clab_amt
  3095. iteminfo.OthAmt = nursing_other_amt
  3096. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3097. }
  3098. if materialCostTotal != 0 {
  3099. iteminfo.MedChrgitm = "08"
  3100. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  3101. iteminfo.Amt = materialCostTotal
  3102. iteminfo.ClaaSumfee = material_claa_sunmfee
  3103. iteminfo.ClabAmt = material_clab_amt
  3104. iteminfo.OthAmt = material_other_amt
  3105. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3106. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3107. }
  3108. if westernMedicineCostTotal != 0 {
  3109. iteminfo.MedChrgitm = "09"
  3110. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3111. iteminfo.Amt = westernMedicineCostTotal
  3112. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3113. iteminfo.ClabAmt = westernMedicine_clab_amt
  3114. iteminfo.OthAmt = westernMedicine_other_amt
  3115. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3116. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3117. }
  3118. if chineseMedicineCostTotal != 0 {
  3119. iteminfo.MedChrgitm = "10"
  3120. iteminfo.FulamtOwnpayAmt = chinese_medicine_fulamt_ownpay_amt
  3121. iteminfo.Amt = chineseMedicineCostTotal
  3122. iteminfo.ClaaSumfee = chinese_medicine_claa_sunmfee
  3123. iteminfo.ClabAmt = chinese_medicine_clab_amt
  3124. iteminfo.OthAmt = chinese_medicine_other_amt
  3125. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3126. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3127. }
  3128. if chineseTraditionalMedicineCostTotal != 0 {
  3129. iteminfo.MedChrgitm = "11"
  3130. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  3131. iteminfo.Amt = westernMedicineCostTotal
  3132. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  3133. iteminfo.ClabAmt = westernMedicine_clab_amt
  3134. iteminfo.OthAmt = westernMedicine_other_amt
  3135. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3136. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3137. }
  3138. if commonlyTreatmentCostTotal != 0 {
  3139. iteminfo.MedChrgitm = "12"
  3140. iteminfo.FulamtOwnpayAmt = commonly_treatment_fulamt_ownpay_amt
  3141. iteminfo.Amt = commonlyTreatmentCostTotal
  3142. iteminfo.ClaaSumfee = commonly_treatment_claa_sunmfee
  3143. iteminfo.ClabAmt = commonly_treatment_clab_amt
  3144. iteminfo.OthAmt = commonly_treatment_other_amt
  3145. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3146. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3147. }
  3148. if registerCostTotal != 0 {
  3149. iteminfo.MedChrgitm = "13"
  3150. iteminfo.FulamtOwnpayAmt = register_fulamt_ownpay_amt
  3151. iteminfo.Amt = registerCostTotal
  3152. iteminfo.ClaaSumfee = register_claa_sunmfee
  3153. iteminfo.ClabAmt = register_clab_amt
  3154. iteminfo.OthAmt = register_other_amt
  3155. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3156. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3157. }
  3158. if otherCostTotal != 0 {
  3159. iteminfo.MedChrgitm = "14"
  3160. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  3161. iteminfo.Amt = otherCostTotal
  3162. iteminfo.ClaaSumfee = other_claa_sunmfee
  3163. iteminfo.ClabAmt = other_clab_amt
  3164. iteminfo.OthAmt = other_other_amt
  3165. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  3166. iteminfoStructs = append(iteminfoStructs, iteminfo)
  3167. }
  3168. struct4101.IteminfoStruct = iteminfoStructs
  3169. struct4101.Ntly = "中国"
  3170. struct4101.AdmCaty = "A03.06"
  3171. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, c.GetAdminUserInfo().CurrentOrgId)
  3172. fmt.Println(result)
  3173. var dat map[string]interface{}
  3174. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3175. fmt.Println(dat)
  3176. } else {
  3177. fmt.Println(err)
  3178. }
  3179. userJSONBytes, _ := json.Marshal(dat)
  3180. var res ResultSeventeen
  3181. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3182. utils.ErrorLog("解析失败:%v", err)
  3183. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3184. adminUser := c.GetAdminUserInfo()
  3185. errlog := &models.HisOrderError{
  3186. UserOrgId: adminUser.CurrentOrgId,
  3187. Ctime: time.Now().Unix(),
  3188. Mtime: time.Now().Unix(),
  3189. ErrMsg: res.ErrMsg + "解析失败",
  3190. Status: 1,
  3191. PatientId: order_id,
  3192. Stage: 10106,
  3193. }
  3194. service.CreateErrMsgLog(errlog)
  3195. continue
  3196. }
  3197. if res.Infcode != 0 {
  3198. adminUser := c.GetAdminUserInfo()
  3199. errlog := &models.HisOrderError{
  3200. UserOrgId: adminUser.CurrentOrgId,
  3201. Ctime: time.Now().Unix(),
  3202. Mtime: time.Now().Unix(),
  3203. ErrMsg: res.ErrMsg,
  3204. Status: 1,
  3205. PatientId: order_id,
  3206. Stage: 10106,
  3207. }
  3208. service.CreateErrMsgLog(errlog)
  3209. continue
  3210. } else {
  3211. hisFundSettleListResult := &models.HisFundSettleListResult{
  3212. Number: res.Output.SetlListId,
  3213. Status: 1,
  3214. Ctime: time.Now().Unix(),
  3215. Mtime: time.Now().Unix(),
  3216. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  3217. IsUpload: 1,
  3218. OrderId: order_id,
  3219. }
  3220. service.CreateUploadRecord(hisFundSettleListResult)
  3221. continue
  3222. }
  3223. }
  3224. }
  3225. func (c *HisApiController) GetOrgInfo() {
  3226. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  3227. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  3228. }
  3229. func (c *HisApiController) GetHisPatientInfo() {
  3230. medical_insurance_card := c.GetString("medical_insurance_card")
  3231. id_card_type, _ := c.GetInt64("id_card_type")
  3232. id_card := c.GetString("id_card")
  3233. adminInfo := c.GetAdminUserInfo()
  3234. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  3235. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  3236. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  3237. IdCardNo := ""
  3238. if id_card_type == 1 {
  3239. IdCardNo = medical_insurance_card
  3240. } else if id_card_type == 2 {
  3241. IdCardNo = id_card
  3242. }
  3243. if config.IsOpen == 1 {
  3244. 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
  3245. resp, requestErr := http.Get(api)
  3246. if requestErr != nil {
  3247. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3248. return
  3249. }
  3250. defer resp.Body.Close()
  3251. body, ioErr := ioutil.ReadAll(resp.Body)
  3252. if ioErr != nil {
  3253. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3254. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3255. return
  3256. }
  3257. var respJSON map[string]interface{}
  3258. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3259. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3260. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3261. return
  3262. }
  3263. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3264. userJSONBytes, _ := json.Marshal(userJSON)
  3265. var res ResultTwo
  3266. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3267. utils.ErrorLog("解析失败:%v", err)
  3268. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3269. return
  3270. }
  3271. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  3272. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  3273. infoStr := string(Iinfos)
  3274. idetinfoStr := string(Idetinfos)
  3275. if res.Infcode == 0 {
  3276. his := models.VMHisPatient{
  3277. Status: 1,
  3278. Ctime: time.Now().Unix(),
  3279. Mtime: time.Now().Unix(),
  3280. PsnNo: res.Output.Baseinfo.PsnNo,
  3281. PsnCertType: res.Output.Baseinfo.PsnCertType,
  3282. Certno: res.Output.Baseinfo.Certno,
  3283. PsnName: res.Output.Baseinfo.PsnName,
  3284. Gend: res.Output.Baseinfo.Gend,
  3285. Naty: res.Output.Baseinfo.Naty,
  3286. Brdy: res.Output.Baseinfo.Brdy,
  3287. Age: res.Output.Baseinfo.Age,
  3288. Iinfo: infoStr,
  3289. Idetinfo: idetinfoStr,
  3290. UserOrgId: adminInfo.CurrentOrgId,
  3291. IsReturn: 1,
  3292. IdCardType: id_card_type,
  3293. }
  3294. c.ServeSuccessJSON(map[string]interface{}{
  3295. "info": his,
  3296. })
  3297. } else {
  3298. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  3299. return
  3300. }
  3301. }
  3302. }
  3303. //func GetBasBaseInfo() (jsonStr string, err error) {
  3304. //
  3305. // handle := syscall.NewLazyDLL("SSCard.dll")
  3306. // add := handle.NewProc("ReadCardBas")
  3307. // str := make([]byte, 1024)
  3308. // str1 := make([]byte, 1024)
  3309. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3310. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  3311. //
  3312. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  3313. //
  3314. // fmt.Println("> Add(4,5)的结果为:", ret)
  3315. // handle.Release()
  3316. //
  3317. // return "", nil
  3318. //
  3319. //}
  3320. //func GetQRBaseInfo() (jsonStr string, err error) {
  3321. // handle := syscall.LoadDLL("SSCard.dll")
  3322. // ReadCardBas := handle.FindProc("GetQRBase")
  3323. //
  3324. // str := make([]byte, 256)
  3325. // str1 := make([]byte, 256)
  3326. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  3327. //
  3328. // fmt.Println(string(str))
  3329. // fmt.Println(r)
  3330. // return string(str), nil
  3331. //}
  3332. //func CardInit() int {
  3333. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  3334. // add := DllTestDef.MustFindProc("Init")
  3335. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3336. // if err != nil {
  3337. // fmt.Println("SSCard的运算结果为:", ret)
  3338. // }
  3339. // result := int(ret)
  3340. // return result
  3341. //}
  3342. //func CardInit() int {
  3343. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  3344. // if err != nil {
  3345. // fmt.Println("SSCard的运算结果为:", ret)
  3346. // }
  3347. // fmt.Println(err)
  3348. // result := int(ret)
  3349. // return result
  3350. //}
  3351. func IntPtr(n int) uintptr {
  3352. return uintptr(n)
  3353. }
  3354. func StrPtr(s string) uintptr {
  3355. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  3356. }
  3357. type Result2001 struct {
  3358. Cainfo interface{} `json:"cainfo"`
  3359. ErrMsg string `json:"err_msg"`
  3360. InfRefmsgid string `json:"inf_refmsgid"`
  3361. Infcode int64 `json:"infcode"`
  3362. Output struct {
  3363. Trtinfo struct {
  3364. PsnNo string `json:"psn_no"`
  3365. TrtChkType string `json:"trt_chk_type"`
  3366. FundPayType string `json:"fund_pay_type"`
  3367. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3368. Begndate string `json:"begndate"`
  3369. Enddate string `json:"enddate"`
  3370. TrtChkRslt string `json:"trt_chk_rslt"`
  3371. } `json:"trtinfo"`
  3372. } `json:"output"`
  3373. RefmsgTime string `json:"refmsg_time"`
  3374. RespondTime string `json:"respond_time"`
  3375. Signtype interface{} `json:"signtype"`
  3376. WarnMsg interface{} `json:"warn_msg"`
  3377. }
  3378. type Result2001Org10265 struct {
  3379. Cainfo interface{} `json:"cainfo"`
  3380. ErrMsg string `json:"err_msg"`
  3381. InfRefmsgid string `json:"inf_refmsgid"`
  3382. Infcode string `json:"infcode"`
  3383. Output struct {
  3384. Trtinfo struct {
  3385. PsnNo string `json:"psn_no"`
  3386. TrtChkType string `json:"trt_chk_type"`
  3387. FundPayType string `json:"fund_pay_type"`
  3388. TrtEnjymntFlag string `json:"trt_enjymnt_flag"`
  3389. Begndate string `json:"begndate"`
  3390. Enddate string `json:"enddate"`
  3391. TrtChkRslt string `json:"trt_chk_rslt"`
  3392. } `json:"trtinfo"`
  3393. } `json:"output"`
  3394. RefmsgTime string `json:"refmsg_time"`
  3395. RespondTime string `json:"respond_time"`
  3396. Signtype interface{} `json:"signtype"`
  3397. WarnMsg interface{} `json:"warn_msg"`
  3398. }
  3399. type ResultTwo struct {
  3400. ErrMsg string `json:"err_msg"`
  3401. InfRefmsgid string `json:"inf_refmsgid"`
  3402. Infcode int64 `json:"infcode"`
  3403. Output struct {
  3404. Baseinfo struct {
  3405. Age float64 `json:"age"`
  3406. Brdy string `json:"brdy"`
  3407. Certno string `json:"certno"`
  3408. Gend string `json:"gend"`
  3409. Naty string `json:"naty"`
  3410. PsnCertType string `json:"psn_cert_type"`
  3411. PsnName string `json:"psn_name"`
  3412. PsnNo string `json:"psn_no"`
  3413. } `json:"baseinfo"`
  3414. Idetinfo []interface{} `json:"idetinfo"`
  3415. Iinfo []struct {
  3416. Balc float64 `json:"balc"`
  3417. CvlservFlag string `json:"cvlserv_flag"`
  3418. EmpName string `json:"emp_name"`
  3419. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3420. Insutype string `json:"insutype"`
  3421. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3422. PausInsuDate string `json:"paus_insu_date"`
  3423. PsnInsuDate string `json:"psn_insu_date"`
  3424. PsnInsuStas string `json:"psn_insu_stas"`
  3425. PsnType string `json:"psn_type"`
  3426. } `json:"insuinfo"`
  3427. } `json:"output"`
  3428. RefmsgTime string `json:"refmsg_time"`
  3429. RespondTime string `json:"respond_time"`
  3430. Signtype interface{} `json:"signtype"`
  3431. WarnInfo interface{} `json:"warn_info"`
  3432. }
  3433. type ResultTwo10265 struct {
  3434. ErrMsg string `json:"err_msg"`
  3435. InfRefmsgid string `json:"inf_refmsgid"`
  3436. Infcode string `json:"infcode"`
  3437. Output struct {
  3438. Baseinfo struct {
  3439. Age float64 `json:"age"`
  3440. Brdy string `json:"brdy"`
  3441. Certno string `json:"certno"`
  3442. Gend string `json:"gend"`
  3443. Naty string `json:"naty"`
  3444. PsnCertType string `json:"psn_cert_type"`
  3445. PsnName string `json:"psn_name"`
  3446. PsnNo string `json:"psn_no"`
  3447. } `json:"baseinfo"`
  3448. Idetinfo []interface{} `json:"idetinfo"`
  3449. Iinfo []struct {
  3450. Balc float64 `json:"balc"`
  3451. CvlservFlag string `json:"cvlserv_flag"`
  3452. EmpName string `json:"emp_name"`
  3453. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3454. Insutype string `json:"insutype"`
  3455. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3456. PausInsuDate string `json:"paus_insu_date"`
  3457. PsnInsuDate string `json:"psn_insu_date"`
  3458. PsnInsuStas string `json:"psn_insu_stas"`
  3459. PsnType string `json:"psn_type"`
  3460. } `json:"insuinfo"`
  3461. } `json:"output"`
  3462. RefmsgTime string `json:"refmsg_time"`
  3463. RespondTime string `json:"respond_time"`
  3464. Signtype interface{} `json:"signtype"`
  3465. WarnInfo interface{} `json:"warn_info"`
  3466. }
  3467. type ResultThree struct {
  3468. Cainfo interface{} `json:"cainfo"`
  3469. ErrMsg string `json:"err_msg"`
  3470. InfRefmsgid string `json:"inf_refmsgid"`
  3471. Infcode int64 `json:"infcode"`
  3472. Output struct {
  3473. Data struct {
  3474. IptOtpNo string `json:"ipt_otp_no"`
  3475. MdtrtID string `json:"mdtrt_id"`
  3476. PsnNo string `json:"psn_no"`
  3477. } `json:"data"`
  3478. } `json:"output"`
  3479. RefmsgTime string `json:"refmsg_time"`
  3480. RespondTime string `json:"respond_time"`
  3481. Signtype interface{} `json:"signtype"`
  3482. WarnMsg interface{} `json:"warn_msg"`
  3483. }
  3484. type ResultThree10265 struct {
  3485. Cainfo interface{} `json:"cainfo"`
  3486. ErrMsg string `json:"err_msg"`
  3487. InfRefmsgid string `json:"inf_refmsgid"`
  3488. Infcode string `json:"infcode"`
  3489. Output struct {
  3490. Data struct {
  3491. IptOtpNo string `json:"ipt_otp_no"`
  3492. MdtrtID string `json:"mdtrt_id"`
  3493. PsnNo string `json:"psn_no"`
  3494. } `json:"data"`
  3495. } `json:"output"`
  3496. RefmsgTime string `json:"refmsg_time"`
  3497. RespondTime string `json:"respond_time"`
  3498. Signtype interface{} `json:"signtype"`
  3499. WarnMsg interface{} `json:"warn_msg"`
  3500. }
  3501. type ResultFour struct {
  3502. Cainfo string `json:"cainfo"`
  3503. ErrMsg string `json:"err_msg"`
  3504. InfRefmsgid string `json:"inf_refmsgid"`
  3505. Infcode int64 `json:"infcode"`
  3506. Output struct {
  3507. Result []struct {
  3508. BasMednFlag string `json:"bas_medn_flag"`
  3509. ChldMedcFlag string `json:"chld_medc_flag"`
  3510. ChrgitmLv string `json:"chrgitm_lv"`
  3511. Cnt float64 `json:"cnt"`
  3512. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3513. DrtReimFlag string `json:"drt_reim_flag"`
  3514. FeedetlSn string `json:"feedetl_sn"`
  3515. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3516. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3517. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3518. ListSpItemFlag string `json:"list_sp_item_flag"`
  3519. LmtUsedFlag string `json:"lmt_used_flag"`
  3520. MedChrgitmType string `json:"med_chrgitm_type"`
  3521. Memo string `json:"memo"`
  3522. OverlmtAmt float64 `json:"overlmt_amt"`
  3523. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3524. Pric float64 `json:"pric"`
  3525. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3526. SelfpayProp float64 `json:"selfpay_prop"`
  3527. } `json:"result"`
  3528. } `json:"output"`
  3529. RefmsgTime string `json:"refmsg_time"`
  3530. RespondTime string `json:"respond_time"`
  3531. Signtype string `json:"signtype"`
  3532. WarnMsg string `json:"warn_msg"`
  3533. }
  3534. type ResultFour10265 struct {
  3535. Cainfo string `json:"cainfo"`
  3536. ErrMsg string `json:"err_msg"`
  3537. InfRefmsgid string `json:"inf_refmsgid"`
  3538. Infcode string `json:"infcode"`
  3539. Output struct {
  3540. Result []struct {
  3541. BasMednFlag string `json:"bas_medn_flag"`
  3542. ChldMedcFlag string `json:"chld_medc_flag"`
  3543. ChrgitmLv string `json:"chrgitm_lv"`
  3544. Cnt float64 `json:"cnt"`
  3545. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  3546. DrtReimFlag string `json:"drt_reim_flag"`
  3547. FeedetlSn string `json:"feedetl_sn"`
  3548. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3549. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  3550. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3551. ListSpItemFlag string `json:"list_sp_item_flag"`
  3552. LmtUsedFlag string `json:"lmt_used_flag"`
  3553. MedChrgitmType string `json:"med_chrgitm_type"`
  3554. Memo string `json:"memo"`
  3555. OverlmtAmt float64 `json:"overlmt_amt"`
  3556. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3557. Pric float64 `json:"pric"`
  3558. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  3559. SelfpayProp float64 `json:"selfpay_prop"`
  3560. } `json:"result"`
  3561. } `json:"output"`
  3562. RefmsgTime string `json:"refmsg_time"`
  3563. RespondTime string `json:"respond_time"`
  3564. Signtype string `json:"signtype"`
  3565. WarnMsg string `json:"warn_msg"`
  3566. }
  3567. type ResultFive struct {
  3568. Balc float64 `json:"balc"`
  3569. CvlservFlag string `json:"cvlserv_flag"`
  3570. EmpName string `json:"emp_name"`
  3571. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  3572. Insutype string `json:"insutype"`
  3573. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  3574. PausInsuDate string `json:"paus_insu_date"`
  3575. PsnInsuDate string `json:"psn_insu_date"`
  3576. PsnInsuStas string `json:"psn_insu_stas"`
  3577. PsnType string `json:"psn_type"`
  3578. }
  3579. type ResultSix struct {
  3580. Cainfo interface{} `json:"cainfo"`
  3581. ErrMsg string `json:"err_msg"`
  3582. InfRefmsgid string `json:"inf_refmsgid"`
  3583. Infcode int64 `json:"infcode"`
  3584. Output struct {
  3585. } `json:"output"`
  3586. RefmsgTime string `json:"refmsg_time"`
  3587. RespondTime string `json:"respond_time"`
  3588. Signtype interface{} `json:"signtype"`
  3589. WarnMsg interface{} `json:"warn_msg"`
  3590. }
  3591. type ResultSix10265 struct {
  3592. Cainfo interface{} `json:"cainfo"`
  3593. ErrMsg string `json:"err_msg"`
  3594. InfRefmsgid string `json:"inf_refmsgid"`
  3595. Infcode string `json:"infcode"`
  3596. Output struct {
  3597. } `json:"output"`
  3598. RefmsgTime string `json:"refmsg_time"`
  3599. RespondTime string `json:"respond_time"`
  3600. Signtype interface{} `json:"signtype"`
  3601. WarnMsg interface{} `json:"warn_msg"`
  3602. }
  3603. type ResultSeven struct {
  3604. Cainfo string `json:"cainfo"`
  3605. ErrMsg string `json:"err_msg"`
  3606. InfRefmsgid string `json:"inf_refmsgid"`
  3607. Infcode int64 `json:"infcode"`
  3608. Output struct {
  3609. Setldetail []interface{} `json:"setldetail"`
  3610. Setlinfo struct {
  3611. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3612. AcctPay float64 `json:"acct_pay"`
  3613. ActPayDedc float64 `json:"act_pay_dedc"`
  3614. Age float64 `json:"age"`
  3615. Balc float64 `json:"balc"`
  3616. Brdy string `json:"brdy"`
  3617. Certno string `json:"certno"`
  3618. ClrOptins string `json:"clr_optins"`
  3619. ClrType string `json:"clr_type"`
  3620. ClrWay string `json:"clr_way"`
  3621. CvlservFlag string `json:"cvlserv_flag"`
  3622. CvlservPay float64 `json:"cvlserv_pay"`
  3623. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3624. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3625. Gend string `json:"gend"`
  3626. HifesPay float64 `json:"hifes_pay"`
  3627. HifmiPay float64 `json:"hifmi_pay"`
  3628. HifpPay float64 `json:"hifp_pay"`
  3629. HospPartAmt float64 `json:"hosp_part_amt"`
  3630. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3631. Insutype string `json:"insutype"`
  3632. MafPay float64 `json:"maf_pay"`
  3633. MdtrtCertType string `json:"mdtrt_cert_type"`
  3634. HifobPay float64 `json:"hifob_pay"`
  3635. MdtrtID string `json:"mdtrt_id"`
  3636. MedType string `json:"med_type"`
  3637. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3638. MedinsSetlID string `json:"medins_setl_id"`
  3639. Naty string `json:"naty"`
  3640. OthPay float64 `json:"oth_pay"`
  3641. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3642. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3643. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3644. PsnCashPay float64 `json:"psn_cash_pay"`
  3645. PsnCertType string `json:"psn_cert_type"`
  3646. PsnName string `json:"psn_name"`
  3647. PsnNo string `json:"psn_no"`
  3648. PsnPartAmt float64 `json:"psn_part_amt"`
  3649. PsnType string `json:"psn_type"`
  3650. SetlID string `json:"setl_id"`
  3651. SetlTime string `json:"setl_time"`
  3652. } `json:"setlinfo"`
  3653. } `json:"output"`
  3654. RefmsgTime string `json:"refmsg_time"`
  3655. RespondTime string `json:"respond_time"`
  3656. Signtype interface{} `json:"signtype"`
  3657. WarnMsg interface{} `json:"warn_msg"`
  3658. }
  3659. type ResultSeven10265 struct {
  3660. Cainfo string `json:"cainfo"`
  3661. ErrMsg string `json:"err_msg"`
  3662. InfRefmsgid string `json:"inf_refmsgid"`
  3663. Infcode string `json:"infcode"`
  3664. Output struct {
  3665. Setldetail []interface{} `json:"setldetail"`
  3666. Setlinfo struct {
  3667. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  3668. AcctPay float64 `json:"acct_pay"`
  3669. ActPayDedc float64 `json:"act_pay_dedc"`
  3670. Age float64 `json:"age"`
  3671. Balc float64 `json:"balc"`
  3672. Brdy string `json:"brdy"`
  3673. Certno string `json:"certno"`
  3674. ClrOptins string `json:"clr_optins"`
  3675. ClrType string `json:"clr_type"`
  3676. ClrWay string `json:"clr_way"`
  3677. CvlservFlag string `json:"cvlserv_flag"`
  3678. CvlservPay float64 `json:"cvlserv_pay"`
  3679. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3680. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3681. Gend string `json:"gend"`
  3682. HifesPay float64 `json:"hifes_pay"`
  3683. HifmiPay float64 `json:"hifmi_pay"`
  3684. HifpPay float64 `json:"hifp_pay"`
  3685. HospPartAmt float64 `json:"hosp_part_amt"`
  3686. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3687. Insutype string `json:"insutype"`
  3688. MafPay float64 `json:"maf_pay"`
  3689. MdtrtCertType string `json:"mdtrt_cert_type"`
  3690. HifobPay float64 `json:"hifob_pay"`
  3691. MdtrtID string `json:"mdtrt_id"`
  3692. MedType string `json:"med_type"`
  3693. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3694. MedinsSetlID string `json:"medins_setl_id"`
  3695. Naty string `json:"naty"`
  3696. OthPay float64 `json:"oth_pay"`
  3697. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3698. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3699. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3700. PsnCashPay float64 `json:"psn_cash_pay"`
  3701. PsnCertType string `json:"psn_cert_type"`
  3702. PsnName string `json:"psn_name"`
  3703. PsnNo string `json:"psn_no"`
  3704. PsnPartAmt float64 `json:"psn_part_amt"`
  3705. PsnType string `json:"psn_type"`
  3706. SetlID string `json:"setl_id"`
  3707. SetlTime string `json:"setl_time"`
  3708. } `json:"setlinfo"`
  3709. } `json:"output"`
  3710. RefmsgTime string `json:"refmsg_time"`
  3711. RespondTime string `json:"respond_time"`
  3712. Signtype interface{} `json:"signtype"`
  3713. WarnMsg interface{} `json:"warn_msg"`
  3714. }
  3715. type ResultEight struct {
  3716. Cainfo string `json:"cainfo"`
  3717. ErrMsg string `json:"err_msg"`
  3718. InfRefmsgid string `json:"inf_refmsgid"`
  3719. Infcode int64 `json:"infcode"`
  3720. Output struct {
  3721. Stmtinfo struct {
  3722. SetlOptins string `json:"setl_optins"`
  3723. StmtRslt string `json:"stmt_rslt"`
  3724. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3725. } `json:"stmtinfo"`
  3726. } `json:"output"`
  3727. RefmsgTime string `json:"refmsg_time"`
  3728. RespondTime string `json:"respond_time"`
  3729. Signtype interface{} `json:"signtype"`
  3730. WarnMsg interface{} `json:"warn_msg"`
  3731. }
  3732. type ResultEightFor10188 struct {
  3733. Cainfo string `json:"cainfo"`
  3734. ErrMsg string `json:"err_msg"`
  3735. InfRefmsgid string `json:"inf_refmsgid"`
  3736. Infcode string `json:"infcode"`
  3737. Output struct {
  3738. Stmtinfo struct {
  3739. SetlOptins string `json:"setl_optins"`
  3740. StmtRslt string `json:"stmt_rslt"`
  3741. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  3742. } `json:"stmtinfo"`
  3743. } `json:"output"`
  3744. RefmsgTime string `json:"refmsg_time"`
  3745. RespondTime string `json:"respond_time"`
  3746. Signtype interface{} `json:"signtype"`
  3747. WarnMsg interface{} `json:"warn_msg"`
  3748. }
  3749. type ResultNine struct {
  3750. Cainfo string `json:"cainfo"`
  3751. ErrMsg string `json:"err_msg"`
  3752. InfRefmsgid string `json:"inf_refmsgid"`
  3753. Infcode int64 `json:"infcode"`
  3754. Output struct {
  3755. FileQuryNo string `json:"file_qury_no"`
  3756. } `json:"output"`
  3757. RefmsgTime string `json:"refmsg_time"`
  3758. RespondTime string `json:"respond_time"`
  3759. Signtype interface{} `json:"signtype"`
  3760. WarnMsg interface{} `json:"warn_msg"`
  3761. }
  3762. type ResultTen struct {
  3763. Cainfo string `json:"cainfo"`
  3764. ErrMsg string `json:"err_msg"`
  3765. InfRefmsgid string `json:"inf_refmsgid"`
  3766. Infcode int64 `json:"infcode"`
  3767. Output struct {
  3768. DldEndtime string `json:"dld_endtime"`
  3769. FileQuryNo string `json:"file_qury_no"`
  3770. Filename string `json:"filename"`
  3771. } `json:"output"`
  3772. RefmsgTime string `json:"refmsg_time"`
  3773. RespondTime string `json:"respond_time"`
  3774. Signtype interface{} `json:"signtype"`
  3775. WarnMsg interface{} `json:"warn_msg"`
  3776. }
  3777. //type Autogenerated struct {
  3778. // Output struct {
  3779. // Setlinfo struct {
  3780. // SetlTime string `json:"setl_time"`
  3781. // CvlservPay float64 `json:"cvlserv_pay"`
  3782. // Year string `json:"year"`
  3783. // MedType string `json:"med_type"`
  3784. // PsnPay float64 `json:"psn_pay"`
  3785. // OpterID string `json:"opter_id"`
  3786. // Begndate string `json:"begndate"`
  3787. // FlxempeFlag string `json:"flxempe_flag"`
  3788. // HifmiPay float64 `json:"hifmi_pay"`
  3789. // PsnNo string `json:"psn_no"`
  3790. // ActPayDedc float64 `json:"act_pay_dedc"`
  3791. // MedinsSetlID interface{} `json:"medins_setl_id"`
  3792. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3793. // ClrWay string `json:"clr_way"`
  3794. // OthPay float64 `json:"oth_pay"`
  3795. // Gend string `json:"gend"`
  3796. // MdtrtID string `json:"mdtrt_id"`
  3797. // AcctPay float64 `json:"acct_pay"`
  3798. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  3799. // Insutype string `json:"insutype"`
  3800. // Invono interface{} `json:"invono"`
  3801. // Enddate string `json:"enddate"`
  3802. // CashPayamt float64 `json:"cash_payamt"`
  3803. // PsnType string `json:"psn_type"`
  3804. // FixmedinsName string `json:"fixmedins_name"`
  3805. // HifpPay float64 `json:"hifp_pay"`
  3806. // NewFlag interface{} `json:"new_flag"`
  3807. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3808. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  3809. // PayLoc string `json:"pay_loc"`
  3810. // ClrType string `json:"clr_type"`
  3811. // RefdSetlFlag string `json:"refd_setl_flag"`
  3812. // CvlservFlag string `json:"cvlserv_flag"`
  3813. // EmpName string `json:"emp_name"`
  3814. // Brdy string `json:"brdy"`
  3815. // Naty string `json:"naty"`
  3816. // Certno string `json:"certno"`
  3817. // DiseCode string `json:"dise_code"`
  3818. // FixmedinsCode string `json:"fixmedins_code"`
  3819. // DedcHospLv string `json:"dedc_hosp_lv"`
  3820. // OpterName string `json:"opter_name"`
  3821. // Balc float64 `json:"balc"`
  3822. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3823. // PsnCertType string `json:"psn_cert_type"`
  3824. // HifobPay float64 `json:"hifob_pay"`
  3825. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  3826. // HifesPay float64 `json:"hifes_pay"`
  3827. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3828. // OptTime string `json:"opt_time"`
  3829. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3830. // SetlID string `json:"setl_id"`
  3831. // MafPay float64 `json:"maf_pay"`
  3832. // PsnName string `json:"psn_name"`
  3833. // InsuOptins interface{} `json:"insu_optins"`
  3834. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3835. // ClrOptins string `json:"clr_optins"`
  3836. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3837. // DiseName string `json:"dise_name"`
  3838. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3839. // Age float64 `json:"age"`
  3840. // DtrtCertType string `json:"dtrt_cert_type"`
  3841. // HospLv string `json:"hosp_lv"`
  3842. // } `json:"setlinfo"`
  3843. // Setldetail []struct {
  3844. // FundPayType string `json:"fund_pay_type"`
  3845. // FundPayamt float64 `json:"fund_payamt"`
  3846. // SetlProcInfo interface{} `json:"setl_proc_info"`
  3847. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  3848. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  3849. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  3850. // PrefFundPay interface{} `json:"pref_fund_pay"`
  3851. // } `json:"setldetail"`
  3852. // } `json:"output"`
  3853. // Infcode int `json:"infcode"`
  3854. // WarnMsg interface{} `json:"warn_msg"`
  3855. // Cainfo interface{} `json:"cainfo"`
  3856. // ErrMsg interface{} `json:"err_msg"`
  3857. // RefmsgTime string `json:"refmsg_time"`
  3858. // Signtype interface{} `json:"signtype"`
  3859. // RespondTime string `json:"respond_time"`
  3860. // InfRefmsgid string `json:"inf_refmsgid"`
  3861. //}
  3862. type ResultEleven struct {
  3863. Cainfo string `json:"cainfo"`
  3864. ErrMsg string `json:"err_msg"`
  3865. InfRefmsgid string `json:"inf_refmsgid"`
  3866. Infcode int64 `json:"infcode"`
  3867. Output struct {
  3868. Setlinfo struct {
  3869. SetlTime string `json:"setl_time"`
  3870. CvlservPay float64 `json:"cvlserv_pay"`
  3871. Year string `json:"year"`
  3872. MedType string `json:"med_type"`
  3873. PsnPay float64 `json:"psn_pay"`
  3874. OpterID string `json:"opter_id"`
  3875. Begndate string `json:"begndate"`
  3876. FlxempeFlag string `json:"flxempe_flag"`
  3877. HifmiPay float64 `json:"hifmi_pay"`
  3878. PsnNo string `json:"psn_no"`
  3879. ActPayDedc float64 `json:"act_pay_dedc"`
  3880. MedinsSetlID interface{} `json:"medins_setl_id"`
  3881. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3882. ClrWay string `json:"clr_way"`
  3883. OthPay float64 `json:"oth_pay"`
  3884. Gend string `json:"gend"`
  3885. MdtrtID string `json:"mdtrt_id"`
  3886. AcctPay float64 `json:"acct_pay"`
  3887. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3888. Insutype string `json:"insutype"`
  3889. Invono interface{} `json:"invono"`
  3890. Enddate string `json:"enddate"`
  3891. CashPayamt float64 `json:"cash_payamt"`
  3892. PsnType string `json:"psn_type"`
  3893. FixmedinsName string `json:"fixmedins_name"`
  3894. HifpPay float64 `json:"hifp_pay"`
  3895. NewFlag interface{} `json:"new_flag"`
  3896. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3897. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3898. PayLoc string `json:"pay_loc"`
  3899. ClrType string `json:"clr_type"`
  3900. RefdSetlFlag string `json:"refd_setl_flag"`
  3901. CvlservFlag string `json:"cvlserv_flag"`
  3902. EmpName string `json:"emp_name"`
  3903. Brdy string `json:"brdy"`
  3904. Naty string `json:"naty"`
  3905. Certno string `json:"certno"`
  3906. DiseCode string `json:"dise_code"`
  3907. FixmedinsCode string `json:"fixmedins_code"`
  3908. DedcHospLv string `json:"dedc_hosp_lv"`
  3909. OpterName string `json:"opter_name"`
  3910. Balc float64 `json:"balc"`
  3911. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3912. PsnCertType string `json:"psn_cert_type"`
  3913. HifobPay float64 `json:"hifob_pay"`
  3914. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3915. HifesPay float64 `json:"hifes_pay"`
  3916. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3917. OptTime string `json:"opt_time"`
  3918. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3919. SetlID string `json:"setl_id"`
  3920. MafPay float64 `json:"maf_pay"`
  3921. PsnName string `json:"psn_name"`
  3922. InsuOptins interface{} `json:"insu_optins"`
  3923. PrefFundPay interface{} `json:"pref_fund_pay"`
  3924. ClrOptins string `json:"clr_optins"`
  3925. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  3926. DiseName string `json:"dise_name"`
  3927. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  3928. Age float64 `json:"age"`
  3929. DtrtCertType string `json:"dtrt_cert_type"`
  3930. HospLv string `json:"hosp_lv"`
  3931. } `json:"setlinfo"`
  3932. } `json:"output"`
  3933. RefmsgTime string `json:"refmsg_time"`
  3934. RespondTime string `json:"respond_time"`
  3935. Signtype interface{} `json:"signtype"`
  3936. WarnMsg interface{} `json:"warn_msg"`
  3937. }
  3938. type ResultEleven10265 struct {
  3939. Cainfo string `json:"cainfo"`
  3940. ErrMsg string `json:"err_msg"`
  3941. InfRefmsgid string `json:"inf_refmsgid"`
  3942. Infcode string `json:"infcode"`
  3943. Output struct {
  3944. Setlinfo struct {
  3945. SetlTime string `json:"setl_time"`
  3946. CvlservPay float64 `json:"cvlserv_pay"`
  3947. Year string `json:"year"`
  3948. MedType string `json:"med_type"`
  3949. PsnPay float64 `json:"psn_pay"`
  3950. OpterID string `json:"opter_id"`
  3951. Begndate string `json:"begndate"`
  3952. FlxempeFlag string `json:"flxempe_flag"`
  3953. HifmiPay float64 `json:"hifmi_pay"`
  3954. PsnNo string `json:"psn_no"`
  3955. ActPayDedc float64 `json:"act_pay_dedc"`
  3956. MedinsSetlID interface{} `json:"medins_setl_id"`
  3957. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  3958. ClrWay string `json:"clr_way"`
  3959. OthPay float64 `json:"oth_pay"`
  3960. Gend string `json:"gend"`
  3961. MdtrtID string `json:"mdtrt_id"`
  3962. AcctPay float64 `json:"acct_pay"`
  3963. InscpScpAmt float64 `json:"inscp_scp_amt"`
  3964. Insutype string `json:"insutype"`
  3965. Invono interface{} `json:"invono"`
  3966. Enddate string `json:"enddate"`
  3967. CashPayamt float64 `json:"cash_payamt"`
  3968. PsnType string `json:"psn_type"`
  3969. FixmedinsName string `json:"fixmedins_name"`
  3970. HifpPay float64 `json:"hifp_pay"`
  3971. NewFlag interface{} `json:"new_flag"`
  3972. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  3973. PreselfpayAmt float64 `json:"preselfpay_amt"`
  3974. PayLoc string `json:"pay_loc"`
  3975. ClrType string `json:"clr_type"`
  3976. RefdSetlFlag string `json:"refd_setl_flag"`
  3977. CvlservFlag string `json:"cvlserv_flag"`
  3978. EmpName string `json:"emp_name"`
  3979. Brdy string `json:"brdy"`
  3980. Naty string `json:"naty"`
  3981. Certno string `json:"certno"`
  3982. DiseCode string `json:"dise_code"`
  3983. FixmedinsCode string `json:"fixmedins_code"`
  3984. DedcHospLv string `json:"dedc_hosp_lv"`
  3985. OpterName string `json:"opter_name"`
  3986. Balc float64 `json:"balc"`
  3987. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  3988. PsnCertType string `json:"psn_cert_type"`
  3989. HifobPay float64 `json:"hifob_pay"`
  3990. MedfeeSumamt float64 `json:"medfee_sumamt"`
  3991. HifesPay float64 `json:"hifes_pay"`
  3992. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  3993. OptTime string `json:"opt_time"`
  3994. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  3995. SetlID string `json:"setl_id"`
  3996. MafPay float64 `json:"maf_pay"`
  3997. PsnName string `json:"psn_name"`
  3998. InsuOptins interface{} `json:"insu_optins"`
  3999. PrefFundPay interface{} `json:"pref_fund_pay"`
  4000. ClrOptins string `json:"clr_optins"`
  4001. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  4002. DiseName string `json:"dise_name"`
  4003. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  4004. Age float64 `json:"age"`
  4005. DtrtCertType string `json:"dtrt_cert_type"`
  4006. HospLv string `json:"hosp_lv"`
  4007. } `json:"setlinfo"`
  4008. } `json:"output"`
  4009. RefmsgTime string `json:"refmsg_time"`
  4010. RespondTime string `json:"respond_time"`
  4011. Signtype interface{} `json:"signtype"`
  4012. WarnMsg interface{} `json:"warn_msg"`
  4013. }
  4014. type ResultTwelve struct {
  4015. Cainfo string `json:"cainfo"`
  4016. ErrMsg string `json:"err_msg"`
  4017. InfRefmsgid string `json:"inf_refmsgid"`
  4018. Infcode int64 `json:"infcode"`
  4019. Output struct {
  4020. MdtrtId string `json:"mdtrt_id"`
  4021. ChrgBchno string `json:"chrg_bchno"`
  4022. PsnNo string `json:"psn_no"`
  4023. } `json:"output"`
  4024. RefmsgTime string `json:"refmsg_time"`
  4025. RespondTime string `json:"respond_time"`
  4026. Signtype interface{} `json:"signtype"`
  4027. WarnMsg interface{} `json:"warn_msg"`
  4028. }
  4029. type ResultThirteen struct {
  4030. ErrMsg string `json:"err_msg"`
  4031. InfRefmsgid string `json:"inf_refmsgid"`
  4032. Infcode int64 `json:"infcode"`
  4033. Output struct {
  4034. Result struct {
  4035. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4036. } `json:"result"`
  4037. } `json:"output"`
  4038. RefmsgTime string `json:"refmsg_time"`
  4039. RespondTime string `json:"respond_time"`
  4040. Signtype interface{} `json:"signtype"`
  4041. WarnInfo interface{} `json:"warn_info"`
  4042. }
  4043. type ResultThirteen10265 struct {
  4044. ErrMsg string `json:"err_msg"`
  4045. InfRefmsgid string `json:"inf_refmsgid"`
  4046. Infcode string `json:"infcode"`
  4047. Output struct {
  4048. Result struct {
  4049. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  4050. } `json:"result"`
  4051. } `json:"output"`
  4052. RefmsgTime string `json:"refmsg_time"`
  4053. RespondTime string `json:"respond_time"`
  4054. Signtype interface{} `json:"signtype"`
  4055. WarnInfo interface{} `json:"warn_info"`
  4056. }
  4057. type ResultFourteen struct {
  4058. ErrMsg string `json:"err_msg"`
  4059. InfRefmsgid string `json:"inf_refmsgid"`
  4060. Infcode int64 `json:"infcode"`
  4061. Output struct {
  4062. } `json:"output"`
  4063. RefmsgTime string `json:"refmsg_time"`
  4064. RespondTime string `json:"respond_time"`
  4065. Signtype interface{} `json:"signtype"`
  4066. WarnInfo interface{} `json:"warn_info"`
  4067. }
  4068. type ResultFourteen10265 struct {
  4069. ErrMsg string `json:"err_msg"`
  4070. InfRefmsgid string `json:"inf_refmsgid"`
  4071. Infcode string `json:"infcode"`
  4072. Output struct {
  4073. } `json:"output"`
  4074. RefmsgTime string `json:"refmsg_time"`
  4075. RespondTime string `json:"respond_time"`
  4076. Signtype interface{} `json:"signtype"`
  4077. WarnInfo interface{} `json:"warn_info"`
  4078. }
  4079. type ResultSixteen struct {
  4080. Cainfo string `json:"cainfo"`
  4081. ErrMsg string `json:"err_msg"`
  4082. InfRefmsgid string `json:"inf_refmsgid"`
  4083. Infcode int64 `json:"infcode"`
  4084. Output struct {
  4085. Setldetail []interface{} `json:"setldetail"`
  4086. Setlinfo struct {
  4087. MdtrtID string `json:"mdtrt_id"`
  4088. SetlID string `json:"setl_id"`
  4089. ClrOptins string `json:"clr_optins"`
  4090. SetlTime string `json:"setl_time"`
  4091. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4092. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4093. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4094. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4095. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4096. ActPayDedc float64 `json:"act_pay_dedc"`
  4097. HifpPay float64 `json:"hifp_pay"`
  4098. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4099. Lfpay float64 `json:"selfpay"`
  4100. CvlservPay float64 `json:"cvlserv_pay"`
  4101. HifesPay float64 `json:"hifes_pay"`
  4102. HifmiPay float64 `json:"hifmi_pay"`
  4103. HifobPay float64 `json:"hifob_pay"`
  4104. MafPay float64 `json:"maf_pay"`
  4105. OthPay float64 `json:"oth_pay"`
  4106. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4107. PsnPartAmt float64 `json:"psn_part_amt"`
  4108. AcctPay float64 `json:"acct_pay"`
  4109. Balc float64 `json:"balc"`
  4110. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4111. HospPartAmt float64 `json:"hosp_part_amt"`
  4112. MedinsSetlID string `json:"medins_setl_id"`
  4113. PdnCashPay string `json:"pdn_cash_pay"`
  4114. } `json:"setlinfo"`
  4115. } `json:"output"`
  4116. RefmsgTime string `json:"refmsg_time"`
  4117. RespondTime string `json:"respond_time"`
  4118. Signtype interface{} `json:"signtype"`
  4119. WarnMsg interface{} `json:"warn_msg"`
  4120. }
  4121. type ResultSixteen10265 struct {
  4122. Cainfo string `json:"cainfo"`
  4123. ErrMsg string `json:"err_msg"`
  4124. InfRefmsgid string `json:"inf_refmsgid"`
  4125. Infcode string `json:"infcode"`
  4126. Output struct {
  4127. Setldetail []interface{} `json:"setldetail"`
  4128. Setlinfo struct {
  4129. MdtrtID string `json:"mdtrt_id"`
  4130. SetlID string `json:"setl_id"`
  4131. ClrOptins string `json:"clr_optins"`
  4132. SetlTime string `json:"setl_time"`
  4133. MedfeeSumamt float64 `json:"medfee_sumamt"`
  4134. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  4135. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  4136. PreselfpayAmt float64 `json:"preselfpay_amt"`
  4137. InscpScpAmt float64 `json:"inscp_scp_amt"`
  4138. ActPayDedc float64 `json:"act_pay_dedc"`
  4139. HifpPay float64 `json:"hifp_pay"`
  4140. PoolPropSe float64 `json:"pool_prop_selfpay"`
  4141. Lfpay float64 `json:"selfpay"`
  4142. CvlservPay float64 `json:"cvlserv_pay"`
  4143. HifesPay float64 `json:"hifes_pay"`
  4144. HifmiPay float64 `json:"hifmi_pay"`
  4145. HifobPay float64 `json:"hifob_pay"`
  4146. MafPay float64 `json:"maf_pay"`
  4147. OthPay float64 `json:"oth_pay"`
  4148. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  4149. PsnPartAmt float64 `json:"psn_part_amt"`
  4150. AcctPay float64 `json:"acct_pay"`
  4151. Balc float64 `json:"balc"`
  4152. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  4153. HospPartAmt float64 `json:"hosp_part_amt"`
  4154. MedinsSetlID string `json:"medins_setl_id"`
  4155. PdnCashPay string `json:"pdn_cash_pay"`
  4156. } `json:"setlinfo"`
  4157. } `json:"output"`
  4158. RefmsgTime string `json:"refmsg_time"`
  4159. RespondTime string `json:"respond_time"`
  4160. Signtype interface{} `json:"signtype"`
  4161. WarnMsg interface{} `json:"warn_msg"`
  4162. }
  4163. type ResultSeventeen struct {
  4164. ErrMsg string `json:"err_msg"`
  4165. InfRefmsgid string `json:"inf_refmsgid"`
  4166. Infcode int64 `json:"infcode"`
  4167. Output struct {
  4168. SetlListId string `json:"setl_list_id"`
  4169. } `json:"output"`
  4170. RefmsgTime string `json:"refmsg_time"`
  4171. RespondTime string `json:"respond_time"`
  4172. Signtype string `json:"signtype"`
  4173. WarnInfo string `json:"warn_info"`
  4174. }
  4175. type Result90991 struct {
  4176. ErrMsg string `json:"err_msg"`
  4177. InfRefmsgid string `json:"inf_refmsgid"`
  4178. Infcode int64 `json:"infcode"`
  4179. Output struct {
  4180. Result struct {
  4181. PsnNo string `json:"psn_no"`
  4182. CardStat string `json:"card_stat"`
  4183. Certno string `json:"certno"`
  4184. PsnName string `json:"psn_name"`
  4185. CheckStat string `json:"check_stat"`
  4186. SscnoCheckStat string `json:"sscno_check_stat"`
  4187. } `json:"result"`
  4188. } `json:"output"`
  4189. RefmsgTime string `json:"refmsg_time"`
  4190. RespondTime string `json:"respond_time"`
  4191. Signtype interface{} `json:"signtype"`
  4192. WarnInfo interface{} `json:"warn_info"`
  4193. }
  4194. type Result90100 struct {
  4195. ErrMsg string `json:"err_msg"`
  4196. InfRefmsgid string `json:"inf_refmsgid"`
  4197. Infcode int64 `json:"infcode"`
  4198. Output struct {
  4199. PoolareaNo string `json:"poolarea_no"`
  4200. PoolareaNoName string `json:"poolarea_no_name"`
  4201. Insutype string `json:"insutype"`
  4202. InsutypeName string `json:"insutype_name"`
  4203. ClctType string `json:"clct_type"`
  4204. ClctTypeName string `json:"clct_type_name"`
  4205. ClctFlag string `json:"clct_flag"`
  4206. ClctFlagName string `json:"clct_flag_name"`
  4207. AccrymBegn string `json:"accrym_begn"`
  4208. AccrymEnd string `json:"accrym_end"`
  4209. ClctTime string `json:"clct_time"`
  4210. ClctstdCrtfRuleCodg string `json:"clctstd_crtf_rule_codg"`
  4211. } `json:"output"`
  4212. RefmsgTime string `json:"refmsg_time"`
  4213. RespondTime string `json:"respond_time"`
  4214. Signtype interface{} `json:"signtype"`
  4215. WarnInfo interface{} `json:"warn_info"`
  4216. }
  4217. type Custom struct {
  4218. DetItemFeeSumamt string
  4219. Cut string
  4220. FeedetlSn string
  4221. Price string
  4222. MedListCodg string
  4223. Type int64
  4224. AdviceId int64
  4225. ProjectId int64
  4226. ItemId int64
  4227. }
  4228. type Result5301 struct {
  4229. ErrMsg string `json:"err_msg"`
  4230. InfRefmsgid string `json:"inf_refmsgid"`
  4231. Infcode int64 `json:"infcode"`
  4232. Output struct {
  4233. Result []struct {
  4234. OpspDiseCode string `json:"opsp_dise_code"`
  4235. OpspDiseName string `json:"opsp_dise_name"`
  4236. Begndate string `json:"begndate"`
  4237. Enddate string `json:"enddate"`
  4238. } `json:"feedetail"`
  4239. } `json:"output"`
  4240. RefmsgTime string `json:"refmsg_time"`
  4241. RespondTime string `json:"respond_time"`
  4242. Signtype interface{} `json:"signtype"`
  4243. WarnInfo interface{} `json:"warn_info"`
  4244. }
  4245. type Result5301For10265 struct {
  4246. ErrMsg string `json:"err_msg"`
  4247. InfRefmsgid string `json:"inf_refmsgid"`
  4248. Infcode string `json:"infcode"`
  4249. Output struct {
  4250. Result []struct {
  4251. OpspDiseCode string `json:"opsp_dise_code"`
  4252. OpspDiseName string `json:"opsp_dise_name"`
  4253. Begndate string `json:"begndate"`
  4254. Enddate string `json:"enddate"`
  4255. } `json:"feedetail"`
  4256. } `json:"output"`
  4257. RefmsgTime string `json:"refmsg_time"`
  4258. RespondTime string `json:"respond_time"`
  4259. Signtype interface{} `json:"signtype"`
  4260. WarnInfo interface{} `json:"warn_info"`
  4261. }
  4262. //获取个人信息----挂号-----上传就诊信息
  4263. func (c *HisApiController) GetRegisterInfo() {
  4264. id, _ := c.GetInt64("id")
  4265. record_time := c.GetString("record_time")
  4266. settlementValue, _ := c.GetInt64("settlement_value")
  4267. medical_insurance_card := c.GetString("medical_insurance_card")
  4268. name := c.GetString("name")
  4269. id_card_type, _ := c.GetInt64("id_card_type")
  4270. certificates, _ := c.GetInt64("certificates")
  4271. medical_care, _ := c.GetInt64("medical_care")
  4272. birthday := c.GetString("birthday")
  4273. id_card := c.GetString("id_card")
  4274. register_type, _ := c.GetInt64("register")
  4275. doctor, _ := c.GetInt64("doctor")
  4276. department, _ := c.GetInt64("department")
  4277. gender, _ := c.GetInt64("sex")
  4278. registration_fee, _ := c.GetFloat("registration_fee")
  4279. medical_expenses, _ := c.GetFloat("medical_expenses")
  4280. social_type, _ := c.GetInt64("social_type")
  4281. med_type := c.GetString("social_type")
  4282. admin_user_id, _ := c.GetInt64("admin_user_id")
  4283. insuplc_admdvs := c.GetString("insuplc_admdvs")
  4284. timeLayout := "2006-01-02"
  4285. loc, _ := time.LoadLocation("Local")
  4286. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  4287. birthUnix := birthdays.Unix()
  4288. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4289. if err != nil {
  4290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4291. return
  4292. }
  4293. recordDateTime := theTime.Unix()
  4294. adminInfo := c.GetAdminUserInfo()
  4295. var patient service.Patients
  4296. if id == 0 {
  4297. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  4298. } else {
  4299. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  4300. }
  4301. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4302. if patientPrescription.ID == 0 {
  4303. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4304. }
  4305. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4306. if patient.ID == 0 {
  4307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4308. return
  4309. }
  4310. if len(patient.IdCardNo) == 0 {
  4311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4312. return
  4313. }
  4314. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4315. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  4316. doctor_info, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  4317. //就诊结算未完成,不能进行二次挂号
  4318. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  4319. if len(his) >= 1 {
  4320. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  4321. if len(his) >= 1 && order.ID == 0 {
  4322. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  4323. return
  4324. }
  4325. }
  4326. //var register_log string
  4327. if config.IsOpen == 1 {
  4328. var res ResultTwo
  4329. var res10265 ResultTwo10265
  4330. var PsnNo string
  4331. var PsnCertType string
  4332. var Certno string
  4333. var PsnName string
  4334. var Gend string
  4335. var Naty string
  4336. var Brdy string
  4337. var Age float64
  4338. var infoStr string
  4339. var idetinfoStr string
  4340. var infocode int64
  4341. var verify_number string
  4342. fmt.Println(verify_number)
  4343. if miConfig.MdtrtareaAdmvs == "421300" {
  4344. psn_info, _ := service.GetPsnByPatientId(id)
  4345. PsnNo = psn_info.PsnNo
  4346. PsnCertType = psn_info.PsnCertType
  4347. Certno = psn_info.Certno
  4348. PsnName = psn_info.PsnName
  4349. Gend = psn_info.Gend
  4350. Naty = psn_info.Naty
  4351. Brdy = psn_info.Brdy
  4352. Age = psn_info.Age
  4353. infoStr = psn_info.Insuinfo
  4354. idetinfoStr = psn_info.Idetinfo
  4355. infocode = 0
  4356. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4357. psn_info, _ := service.GetPsnByPatientId(id)
  4358. PsnNo = psn_info.PsnNo
  4359. PsnCertType = psn_info.PsnCertType
  4360. Certno = psn_info.Certno
  4361. PsnName = psn_info.PsnName
  4362. Gend = psn_info.Gend
  4363. Naty = psn_info.Naty
  4364. Brdy = psn_info.Brdy
  4365. Age = psn_info.Age
  4366. infoStr = psn_info.Insuinfo
  4367. idetinfoStr = psn_info.Idetinfo
  4368. infocode = 0
  4369. verify_number = psn_info.VerifyNumber
  4370. } else {
  4371. var result string
  4372. var requestLog string
  4373. if miConfig.UserOrgId == 10138 {
  4374. 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)
  4375. } else {
  4376. 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)
  4377. }
  4378. saveLog(result, requestLog, "1101", "人员基本信息获取")
  4379. if miConfig.Code == "H15049901371" {
  4380. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  4381. utils.ErrorLog("解析失败:%v", err)
  4382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4383. return
  4384. }
  4385. res.ErrMsg = res10265.ErrMsg
  4386. res.Output = res10265.Output
  4387. res.InfRefmsgid = res10265.InfRefmsgid
  4388. } else {
  4389. if err := json.Unmarshal([]byte(result), &res); err != nil {
  4390. utils.ErrorLog("解析失败:%v", err)
  4391. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4392. return
  4393. }
  4394. }
  4395. PsnNo = res.Output.Baseinfo.PsnNo
  4396. PsnCertType = res.Output.Baseinfo.PsnCertType
  4397. Certno = res.Output.Baseinfo.Certno
  4398. PsnName = res.Output.Baseinfo.PsnName
  4399. Gend = res.Output.Baseinfo.Gend
  4400. Naty = res.Output.Baseinfo.Naty
  4401. Brdy = res.Output.Baseinfo.Brdy
  4402. Age = res.Output.Baseinfo.Age
  4403. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4404. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4405. infoStr = string(Iinfos)
  4406. idetinfoStr = string(Idetinfos)
  4407. if miConfig.Code == "H15049901371" {
  4408. infocode, _ = strconv.ParseInt(res10265.Infcode, 10, 64)
  4409. } else {
  4410. infocode = res.Infcode
  4411. }
  4412. }
  4413. if infocode == 0 {
  4414. his := models.VMHisPatient{
  4415. Name: name,
  4416. Gender: gender,
  4417. Birthday: birthUnix,
  4418. MedicalTreatmentType: medical_care,
  4419. IdType: certificates,
  4420. IdCardNo: id_card,
  4421. BalanceAccountsType: settlementValue,
  4422. SocialType: social_type,
  4423. MedicalInsuranceNumber: medical_insurance_card,
  4424. RegisterType: register_type,
  4425. RegisterCost: registration_fee,
  4426. TreatmentCost: medical_expenses,
  4427. Status: 1,
  4428. Ctime: time.Now().Unix(),
  4429. Mtime: time.Now().Unix(),
  4430. PsnNo: PsnNo,
  4431. PsnCertType: PsnCertType,
  4432. Certno: Certno,
  4433. PsnName: PsnName,
  4434. Gend: Gend,
  4435. Naty: Naty,
  4436. Brdy: Brdy,
  4437. Age: Age,
  4438. Iinfo: infoStr,
  4439. Idetinfo: idetinfoStr,
  4440. PatientId: patient.ID,
  4441. RecordDate: theTime.Unix(),
  4442. UserOrgId: adminInfo.CurrentOrgId,
  4443. AdminUserId: admin_user_id,
  4444. IsReturn: 1,
  4445. IdCardType: id_card_type,
  4446. Doctor: doctor,
  4447. Departments: department,
  4448. }
  4449. timestamp := time.Now().Unix()
  4450. tempTime := time.Unix(timestamp, 0)
  4451. timeFormat := tempTime.Format("20060102150405")
  4452. chrgBchno := rand.Intn(100000) + 10000
  4453. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  4454. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  4455. department, _ := service.GetDepartMentDetail(department)
  4456. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4457. IdCardNo := ""
  4458. if id_card_type == 1 {
  4459. // IdCardNo = medical_insurance_card
  4460. IdCardNo = patient.IdCardNo
  4461. } else {
  4462. IdCardNo = patient.IdCardNo
  4463. }
  4464. var rf []*ResultFive
  4465. json.Unmarshal([]byte(his.Iinfo), &rf)
  4466. var insutypes []*ResultFive
  4467. var insutype string
  4468. var insuplc_admdvs_temp string
  4469. var is390 int = 0
  4470. var is310 int = 0
  4471. for _, item := range rf {
  4472. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  4473. insutypes = append(insutypes, item)
  4474. }
  4475. }
  4476. if len(insutypes) == 1 {
  4477. insutype = insutypes[0].Insutype
  4478. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  4479. } else {
  4480. for _, i := range insutypes {
  4481. if i.Insutype == "390" {
  4482. is390 = 1
  4483. }
  4484. if i.Insutype == "310" {
  4485. is310 = 1
  4486. }
  4487. }
  4488. }
  4489. if is390 == 1 {
  4490. insutype = "390"
  4491. }
  4492. if is310 == 1 {
  4493. insutype = "310"
  4494. }
  4495. if len(insutypes) == 0 {
  4496. insutype = "310"
  4497. }
  4498. if len(insutypes) == 2 {
  4499. insutype = med_type
  4500. }
  4501. if len(med_type) > 0 {
  4502. insutype = med_type
  4503. }
  4504. //for _, item := range rf {
  4505. // if item.Insutype == insutype {
  4506. // insuplc_admdvs = item.InsuplcAdmdvs
  4507. // }
  4508. //}
  4509. var infocode int64
  4510. var resThree ResultThree
  4511. var resThree10265 ResultThree10265
  4512. if len(insuplc_admdvs) == 0 {
  4513. insuplc_admdvs_temp = miConfig.InsuplcAdmdvs
  4514. } else {
  4515. insuplc_admdvs_temp = insuplc_admdvs
  4516. }
  4517. if miConfig.MdtrtareaAdmvs == "421300" {
  4518. api := "http://192.168.124.4:9532/" + "hbyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + Certno + "&ipt_otp_no=" + ipt_otp_no +
  4519. "&org_name=" + miConfig.OrgName + "&doctor=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4520. "&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 + "&doctor_name=" + doctor_info.UserName
  4521. resp, requestErr := http.Get(api)
  4522. if requestErr != nil {
  4523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4524. return
  4525. }
  4526. body, ioErr := ioutil.ReadAll(resp.Body)
  4527. if ioErr != nil {
  4528. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. var respJSON map[string]interface{}
  4533. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4534. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4535. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4536. return
  4537. }
  4538. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4539. result, _ := json.Marshal(respJSON)
  4540. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4541. utils.ErrorLog("解析失败:%v", err)
  4542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4543. return
  4544. }
  4545. infocode = resThree.Infcode
  4546. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4547. psn_info, _ := service.GetPsnByPatientId(id)
  4548. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  4549. var cert_no string
  4550. if id_card_type == 3 {
  4551. psn_info.VerifyNumber = IdCardNo + "|" + psn_info.VerifyNumber
  4552. cert_no = IdCardNo
  4553. } else {
  4554. bas := strings.Split(psn_info.CardInfo, "|")
  4555. cert_no = bas[2]
  4556. }
  4557. var api string
  4558. if miConfig.MdtrtareaAdmvs == "320921" {
  4559. api = "http://192.168.3.111:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4560. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4561. "&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
  4562. } else {
  4563. api = "http://192.168.5.251:9532/" + "jsyb/2201?psn_no=" + PsnNo + "&insutype=" + insutype + "&cert_no=" + cert_no + "&ipt_otp_no=" + ipt_otp_no +
  4564. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&doctor_name=" + doctor_info.UserName + "&fixmedins_code=" + miConfig.Code +
  4565. "&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
  4566. }
  4567. resp, requestErr := http.Get(api)
  4568. if requestErr != nil {
  4569. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4570. return
  4571. }
  4572. body, ioErr := ioutil.ReadAll(resp.Body)
  4573. if ioErr != nil {
  4574. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4576. return
  4577. }
  4578. var respJSON map[string]interface{}
  4579. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4580. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4582. return
  4583. }
  4584. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4585. result, _ := json.Marshal(respJSON)
  4586. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4587. utils.ErrorLog("解析失败:%v", err)
  4588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4589. return
  4590. }
  4591. resThree.ErrMsg = resThree10265.ErrMsg
  4592. resThree.Output = resThree10265.Output
  4593. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4594. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4595. } else {
  4596. 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)
  4597. saveLog(result, requestLog, "2201A", "挂号")
  4598. if miConfig.Code == "H15049901371" {
  4599. if err := json.Unmarshal([]byte(result), &resThree10265); err != nil {
  4600. utils.ErrorLog("解析失败:%v", err)
  4601. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4602. return
  4603. }
  4604. resThree.ErrMsg = resThree10265.ErrMsg
  4605. resThree.Output = resThree10265.Output
  4606. resThree.InfRefmsgid = resThree10265.InfRefmsgid
  4607. } else {
  4608. if err := json.Unmarshal([]byte(result), &resThree); err != nil {
  4609. utils.ErrorLog("解析失败:%v", err)
  4610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4611. return
  4612. }
  4613. }
  4614. if miConfig.Code == "H15049901371" {
  4615. infocode, _ = strconv.ParseInt(resThree10265.Infcode, 10, 64)
  4616. } else {
  4617. infocode = resThree.Infcode
  4618. }
  4619. }
  4620. if infocode != 0 {
  4621. adminUser := c.GetAdminUserInfo()
  4622. errlog := &models.HisOrderError{
  4623. UserOrgId: adminUser.CurrentOrgId,
  4624. Ctime: time.Now().Unix(),
  4625. Mtime: time.Now().Unix(),
  4626. ErrMsg: resThree.ErrMsg,
  4627. Status: 1,
  4628. PatientId: id,
  4629. RecordTime: recordDateTime,
  4630. Stage: 2,
  4631. }
  4632. service.CreateErrMsgLog(errlog)
  4633. c.ServeSuccessJSON(map[string]interface{}{
  4634. "failed_code": -10,
  4635. "msg": resThree.ErrMsg,
  4636. })
  4637. return
  4638. }
  4639. his.Number = resThree.Output.Data.MdtrtID
  4640. his.PsnNo = resThree.Output.Data.PsnNo
  4641. his.IptOtpNo = resThree.Output.Data.IptOtpNo
  4642. his.IdCardNo = patient.IdCardNo
  4643. his.PhoneNumber = patient.Phone
  4644. his.UserOrgId = adminInfo.CurrentOrgId
  4645. his.Insutype = insutype
  4646. his.Ctime = time.Now().Unix()
  4647. his.Mtime = time.Now().Unix()
  4648. his.InsuplcAdmdvs = insuplc_admdvs_temp
  4649. his.Status = 1
  4650. service.UpdateHisPatientStatus(&his)
  4651. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  4652. c.ServeSuccessJSON(map[string]interface{}{
  4653. "his_info": his,
  4654. })
  4655. } else {
  4656. adminUser := c.GetAdminUserInfo()
  4657. errlog := &models.HisOrderError{
  4658. UserOrgId: adminUser.CurrentOrgId,
  4659. Ctime: time.Now().Unix(),
  4660. Mtime: time.Now().Unix(),
  4661. ErrMsg: res.ErrMsg,
  4662. Status: 1,
  4663. PatientId: id,
  4664. RecordTime: recordDateTime,
  4665. Stage: 1,
  4666. }
  4667. service.CreateErrMsgLog(errlog)
  4668. c.ServeSuccessJSON(map[string]interface{}{
  4669. "failed_code": -10,
  4670. "msg": res.ErrMsg,
  4671. })
  4672. return
  4673. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4674. }
  4675. }
  4676. }
  4677. //上传明细----预结算----确认订单
  4678. func (c *HisApiController) GetUploadInfo() {
  4679. id, _ := c.GetInt64("id")
  4680. record_time := c.GetString("record_time")
  4681. his_patient_id, _ := c.GetInt64("his_patient_id")
  4682. order_id, _ := c.GetInt64("order_id")
  4683. pay_way, _ := c.GetInt64("pay_way")
  4684. pay_price, _ := c.GetFloat("pay_price")
  4685. pay_card_no := c.GetString("pay_card_no")
  4686. discount_price, _ := c.GetFloat("discount_price")
  4687. preferential_price, _ := c.GetFloat("preferential_price")
  4688. reality_price, _ := c.GetFloat("reality_price")
  4689. found_price, _ := c.GetFloat("found_price")
  4690. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  4691. private_price, _ := c.GetFloat("private_price")
  4692. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  4693. admin_user_id, _ := c.GetInt64("admin_user_id")
  4694. fapiao_code := c.GetString("fapiao_code")
  4695. fapiao_number := c.GetString("fapiao_number")
  4696. diagnosis_id := c.GetString("diagnosis")
  4697. sick_type, _ := c.GetInt64("sick_type")
  4698. reg_type, _ := c.GetInt64("p_type")
  4699. begin_time := c.GetString("begin_time")
  4700. id_str := c.GetString("ids")
  4701. ids_arr := strings.Split(id_str, ",")
  4702. timeLayout := "2006-01-02"
  4703. loc, _ := time.LoadLocation("Local")
  4704. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4705. if err != nil {
  4706. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4707. return
  4708. }
  4709. recordDateTime := theTime.Unix()
  4710. adminUser := c.GetAdminUserInfo()
  4711. var tempOrder models.HisOrder
  4712. tempOrder, _ = service.GetHisOrderByID(order_id)
  4713. var prescriptions []*models.HisPrescription
  4714. var start_time int64
  4715. var end_time int64
  4716. //押金模块
  4717. dec_way := c.GetString("dec_way") //是否使用押金支付bool类型
  4718. tmp_decimal := c.GetString("tmp_decimal")
  4719. var decimal float64 //本次使用的押金
  4720. var errmsg error
  4721. if dec_way == "true" && tmp_decimal == "0" || dec_way == "true" && tmp_decimal == "" {
  4722. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为0")
  4723. return
  4724. }
  4725. if len(tmp_decimal) > 0 {
  4726. if tmp_decimal[0] == 45 {
  4727. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, "押金不能为负数")
  4728. return
  4729. }
  4730. }
  4731. tt, errs := strconv.ParseFloat(tmp_decimal, 64)
  4732. fmt.Println(errs)
  4733. decimal = tt
  4734. //if adminUser.CurrentOrgId == 10106{
  4735. // if len(fapiao_code) == 0{
  4736. // fapiao_code = "144072080589"
  4737. // }
  4738. // if len(fapiao_number) == 0{
  4739. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  4740. // if order.ID == 0{
  4741. // fapiao_number = "00001520"
  4742. // }else{
  4743. // //fapiao_code = "00001520"
  4744. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  4745. // var zero string
  4746. // if fpNumber >= 1000{
  4747. // zero = "0000" + strconv.Itoa(fpNumber)
  4748. // }else if fpNumber >= 10000{
  4749. // zero = "000" + strconv.Itoa(fpNumber)
  4750. // } else if fpNumber >= 100000{
  4751. // zero = "00" + strconv.Itoa(fpNumber)
  4752. // } else if fpNumber >= 1000000{
  4753. // zero = "0" + strconv.Itoa(fpNumber)
  4754. // }else {
  4755. // zero = strconv.Itoa(fpNumber)
  4756. // }
  4757. // fapiao_number = zero
  4758. // }
  4759. // }
  4760. //}
  4761. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4762. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4763. var patientPrescription models.HisPrescriptionInfo
  4764. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  4765. if patientPrescription.ID == 0 {
  4766. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  4767. }
  4768. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4769. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4770. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  4771. diagnosis_ids := strings.Split(diagnosis_id, ",")
  4772. var config []*models.HisXtDiagnoseConfig
  4773. for _, item := range diagnosis_ids {
  4774. id, _ := strconv.ParseInt(item, 10, 64)
  4775. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4776. config = append(config, &diagnosisConfig)
  4777. }
  4778. sickConfig, _ := service.FindSickById(sick_type)
  4779. //if tempOrder.ID == 0 {
  4780. // tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime, his.Number)
  4781. //}
  4782. if tempOrder.ID == 0 {
  4783. var result string
  4784. var requestLog string
  4785. var res2 ResultSix
  4786. var ressix10265 ResultSix10265
  4787. if miConfig.MdtrtareaAdmvs == "421300" {
  4788. data := make(map[string]interface{})
  4789. client := &http.Client{}
  4790. data["psn_no"] = his.PsnNo
  4791. data["mdtrt_id"] = his.Number
  4792. data["doctor"] = roles.UserName
  4793. data["department"] = department.Name
  4794. data["org_name"] = miConfig.OrgName
  4795. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4796. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4797. data["fixmedins_code"] = miConfig.Code
  4798. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4799. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4800. data["secret_key"] = miConfig.SecretKey
  4801. data["sick_code"] = sickConfig.CountryCode
  4802. data["sick_name"] = sickConfig.ClassName
  4803. data["dept"] = strconv.FormatInt(department.ID, 10)
  4804. data["config"] = config
  4805. data["begin_time"] = begin_time
  4806. bytesData, _ := json.Marshal(data)
  4807. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  4808. resp, _ := client.Do(req)
  4809. defer resp.Body.Close()
  4810. body, ioErr := ioutil.ReadAll(resp.Body)
  4811. if ioErr != nil {
  4812. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4814. return
  4815. }
  4816. var respJSON map[string]interface{}
  4817. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4818. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4820. return
  4821. }
  4822. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4823. userJSONBytes, _ := json.Marshal(respJSON)
  4824. fmt.Println("log")
  4825. fmt.Println(string(userJSONBytes))
  4826. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4827. utils.ErrorLog("解析失败:%v", err)
  4828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4829. return
  4830. }
  4831. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  4832. //江苏地区国家医保医疗类别
  4833. //职工透析:医疗类别选特殊情况门诊9933
  4834. //居民血透门慢: 医疗类别选门诊慢病1402
  4835. //var med_type string
  4836. //if his.Insutype == "310" {
  4837. // if reg_type == 14 {
  4838. // med_type = "9933"
  4839. // } else if reg_type == 11 {
  4840. // med_type = "11"
  4841. //
  4842. // }
  4843. //} else if his.Insutype == "390" {
  4844. // if reg_type == 14 {
  4845. // med_type = "1402"
  4846. // } else if reg_type == 11 {
  4847. // med_type = "11"
  4848. // }
  4849. //}
  4850. data := make(map[string]interface{})
  4851. client := &http.Client{}
  4852. data["psn_no"] = his.PsnNo
  4853. data["mdtrt_id"] = his.Number
  4854. data["doctor"] = roles.UserName
  4855. data["department"] = department.Name
  4856. data["org_name"] = miConfig.OrgName
  4857. data["med_type"] = strconv.FormatInt(reg_type, 10)
  4858. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  4859. data["fixmedins_code"] = miConfig.Code
  4860. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  4861. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  4862. data["secret_key"] = miConfig.SecretKey
  4863. data["sick_code"] = sickConfig.CountryCode
  4864. data["sick_name"] = sickConfig.ClassName
  4865. data["url"] = miConfig.Url
  4866. data["ak"] = miConfig.AccessKey
  4867. data["begin_time"] = begin_time
  4868. data["cainfo"] = miConfig.Cainfo
  4869. data["dept"] = strconv.FormatInt(department.ID, 10)
  4870. data["config"] = config
  4871. bytesData, _ := json.Marshal(data)
  4872. var req *http.Request
  4873. if miConfig.MdtrtareaAdmvs == "320921" {
  4874. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4875. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  4876. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  4877. } else {
  4878. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  4879. }
  4880. resp, _ := client.Do(req)
  4881. defer resp.Body.Close()
  4882. body, ioErr := ioutil.ReadAll(resp.Body)
  4883. if ioErr != nil {
  4884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4886. return
  4887. }
  4888. var respJSON map[string]interface{}
  4889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  4890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4892. return
  4893. }
  4894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4895. userJSONBytes, _ := json.Marshal(respJSON)
  4896. fmt.Println("log")
  4897. fmt.Println(string(userJSONBytes))
  4898. if err := json.Unmarshal(userJSONBytes, &ressix10265); err != nil {
  4899. utils.ErrorLog("解析失败:%v", err)
  4900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4901. return
  4902. }
  4903. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4904. res2.Output = ressix10265.Output
  4905. res2.ErrMsg = ressix10265.ErrMsg
  4906. res2.Cainfo = ressix10265.Cainfo
  4907. res2.WarnMsg = ressix10265.WarnMsg
  4908. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4909. res2.Infcode = infocode
  4910. } else {
  4911. if miConfig.MdtrtareaAdmvs == "440781" { //
  4912. 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)
  4913. } else {
  4914. if miConfig.Code == "H15049901371" {
  4915. //赤峰地区国家医保医疗类别
  4916. //职工透析:医疗类别选特殊情况门诊990502
  4917. //居民定额血透门慢: 医疗类别选门诊慢病140104
  4918. var med_type string
  4919. if his.Insutype == "390" {
  4920. if reg_type == 14 {
  4921. med_type = "9933"
  4922. } else if reg_type == 11 {
  4923. med_type = "11"
  4924. }
  4925. } else if his.Insutype == "310" {
  4926. if reg_type == 14 {
  4927. med_type = "990502"
  4928. } else if reg_type == 11 {
  4929. med_type = "11"
  4930. }
  4931. }
  4932. 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)
  4933. } else {
  4934. 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)
  4935. }
  4936. }
  4937. saveLog(result, requestLog, "2203", "上传就诊信息")
  4938. var respJSON2 map[string]interface{}
  4939. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  4940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4942. return
  4943. }
  4944. userJSONBytes2, _ := json.Marshal(respJSON2)
  4945. if miConfig.Code == "H15049901371" {
  4946. if err := json.Unmarshal(userJSONBytes2, &ressix10265); err != nil {
  4947. utils.ErrorLog("解析失败:%v", err)
  4948. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4949. return
  4950. }
  4951. res2.InfRefmsgid = ressix10265.InfRefmsgid
  4952. res2.Output = ressix10265.Output
  4953. res2.ErrMsg = ressix10265.ErrMsg
  4954. res2.Cainfo = ressix10265.Cainfo
  4955. res2.WarnMsg = ressix10265.WarnMsg
  4956. infocode, _ := strconv.ParseInt(ressix10265.Infcode, 10, 64)
  4957. res2.Infcode = infocode
  4958. } else {
  4959. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4960. utils.ErrorLog("解析失败:%v", err)
  4961. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4962. return
  4963. }
  4964. }
  4965. }
  4966. if res2.Infcode != 0 {
  4967. adminUser := c.GetAdminUserInfo()
  4968. errlog := &models.HisOrderError{
  4969. UserOrgId: adminUser.CurrentOrgId,
  4970. Ctime: time.Now().Unix(),
  4971. Mtime: time.Now().Unix(),
  4972. ErrMsg: res2.ErrMsg,
  4973. Status: 1,
  4974. PatientId: id,
  4975. RecordTime: recordDateTime,
  4976. Stage: 3,
  4977. }
  4978. service.CreateErrMsgLog(errlog)
  4979. c.ServeSuccessJSON(map[string]interface{}{
  4980. "failed_code": -10,
  4981. "msg": res2.ErrMsg,
  4982. })
  4983. return
  4984. } else {
  4985. his.Diagnosis = diagnosis_id
  4986. his.SickType = sickConfig.ID
  4987. //var p_type int64
  4988. //if reg_type == 1111 || reg_type == 1112 {
  4989. // p_type = 11
  4990. //
  4991. //}
  4992. his.PType = fmt.Sprintf("%d", reg_type)
  4993. service.UpdateHisPatientThree(&his)
  4994. data := make(map[string]interface{})
  4995. if settle_accounts_type == 1 { //日结
  4996. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  4997. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  4998. } else {
  4999. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  5000. }
  5001. //prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  5002. data["pre"] = prescriptions
  5003. } else { //月结
  5004. start_time_str := c.GetString("start_time")
  5005. end_time_str := c.GetString("end_time")
  5006. timeLayout := "2006-01-02"
  5007. loc, _ := time.LoadLocation("Local")
  5008. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  5009. if err != nil {
  5010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5011. return
  5012. }
  5013. recordStartTime := theStartTime.Unix()
  5014. start_time = recordStartTime
  5015. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  5016. if err != nil {
  5017. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5018. return
  5019. }
  5020. recordEndTime := theEndTime.Unix()
  5021. end_time = recordEndTime
  5022. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  5023. data["pre"] = prescriptions
  5024. }
  5025. timestamp := time.Now().Unix()
  5026. tempTime := time.Unix(timestamp, 0)
  5027. timeFormat := tempTime.Format("20060102150405")
  5028. chrgBchno := rand.Intn(100000) + 10000
  5029. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  5030. strconv.FormatInt(his.PatientId, 10)
  5031. client := &http.Client{}
  5032. data["psn_no"] = his.PsnNo
  5033. data["mdtrt_id"] = his.Number
  5034. data["chrg_bchno"] = chrg_bchno
  5035. data["org_name"] = miConfig.OrgName
  5036. data["doctor"] = roles.UserName
  5037. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  5038. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  5039. data["fixmedins_code"] = miConfig.Code
  5040. //if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  5041. // data["dept_code"] = "15"
  5042. //} else {
  5043. data["dept_code"] = department.Number
  5044. //}
  5045. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  5046. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  5047. data["secret_key"] = miConfig.SecretKey
  5048. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  5049. data["url"] = miConfig.Url
  5050. data["ak"] = miConfig.AccessKey
  5051. data["new_doctor_name"] = patientPrescription.Doctor
  5052. data["diag_code"] = sickConfig.CountryCode
  5053. data["cainfo"] = miConfig.Cainfo
  5054. var ids []int64
  5055. for _, item := range prescriptions {
  5056. ids = append(ids, item.ID)
  5057. }
  5058. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5059. if config.IsOpen == 1 { //对接了医保,走医保流程
  5060. var res ResultFour
  5061. var resFour10265 ResultFour10265
  5062. if miConfig.MdtrtareaAdmvs == "421300" {
  5063. bytesData, _ := json.Marshal(data)
  5064. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  5065. resp, _ := client.Do(req)
  5066. defer resp.Body.Close()
  5067. body, ioErr := ioutil.ReadAll(resp.Body)
  5068. if ioErr != nil {
  5069. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5070. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5071. return
  5072. }
  5073. var respJSON map[string]interface{}
  5074. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5075. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5076. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5077. return
  5078. }
  5079. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5080. userJSONBytes, _ := json.Marshal(respJSON)
  5081. fmt.Println("log")
  5082. fmt.Println(string(userJSONBytes))
  5083. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5084. utils.ErrorLog("解析失败:%v", err)
  5085. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5086. return
  5087. }
  5088. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5089. bytesData, _ := json.Marshal(data)
  5090. var req *http.Request
  5091. if miConfig.MdtrtareaAdmvs == "320921" {
  5092. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5093. } else {
  5094. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5095. }
  5096. resp, _ := client.Do(req)
  5097. defer resp.Body.Close()
  5098. body, ioErr := ioutil.ReadAll(resp.Body)
  5099. if ioErr != nil {
  5100. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5101. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5102. return
  5103. }
  5104. var respJSON map[string]interface{}
  5105. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  5106. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5107. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5108. return
  5109. }
  5110. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5111. userJSONBytes, _ := json.Marshal(respJSON)
  5112. fmt.Println("log")
  5113. fmt.Println(string(userJSONBytes))
  5114. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5115. utils.ErrorLog("解析失败:%v", err)
  5116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5117. return
  5118. }
  5119. res.InfRefmsgid = resFour10265.InfRefmsgid
  5120. res.Output = resFour10265.Output
  5121. res.ErrMsg = resFour10265.ErrMsg
  5122. res.Cainfo = resFour10265.Cainfo
  5123. res.WarnMsg = resFour10265.WarnMsg
  5124. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5125. res.Infcode = infocode
  5126. } else {
  5127. if miConfig.Code == "H15049901371" {
  5128. 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)
  5129. var dat map[string]interface{}
  5130. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5131. fmt.Println(dat)
  5132. } else {
  5133. fmt.Println(err)
  5134. }
  5135. saveLog(result, request_log, "2204", "上传费用明细")
  5136. userJSONBytes, _ := json.Marshal(dat)
  5137. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  5138. utils.ErrorLog("解析失败:%v", err)
  5139. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5140. return
  5141. }
  5142. res.InfRefmsgid = resFour10265.InfRefmsgid
  5143. res.Output = resFour10265.Output
  5144. res.ErrMsg = resFour10265.ErrMsg
  5145. res.Cainfo = resFour10265.Cainfo
  5146. res.WarnMsg = resFour10265.WarnMsg
  5147. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  5148. res.Infcode = infocode
  5149. } else {
  5150. 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)
  5151. var dat map[string]interface{}
  5152. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5153. fmt.Println(dat)
  5154. } else {
  5155. fmt.Println(err)
  5156. }
  5157. saveLog(result, request_log, "2204", "上传费用明细")
  5158. userJSONBytes, _ := json.Marshal(dat)
  5159. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5160. utils.ErrorLog("解析失败:%v", err)
  5161. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5162. return
  5163. }
  5164. }
  5165. }
  5166. if res.Infcode == 0 {
  5167. order := &models.HisOrder{
  5168. UserOrgId: adminUser.CurrentOrgId,
  5169. HisPatientId: his.ID,
  5170. PatientId: his.PatientId,
  5171. SettleAccountsDate: recordDateTime,
  5172. MdtrtId: his.Number,
  5173. PsnNo: his.PsnNo,
  5174. MedType: strconv.FormatInt(reg_type, 10),
  5175. Ctime: time.Now().Unix(),
  5176. Mtime: time.Now().Unix(),
  5177. Status: 1,
  5178. Number: chrg_bchno,
  5179. Infcode: res.Infcode,
  5180. WarnMsg: res.WarnMsg,
  5181. Cainfo: res.Cainfo,
  5182. ErrMsg: res.ErrMsg,
  5183. RespondTime: res.RefmsgTime,
  5184. InfRefmsgid: res.InfRefmsgid,
  5185. OrderStatus: 1,
  5186. PayWay: pay_way,
  5187. PayPrice: pay_price,
  5188. PayCardNo: pay_card_no,
  5189. DiscountPrice: discount_price,
  5190. PreferentialPrice: preferential_price,
  5191. RealityPrice: reality_price,
  5192. FoundPrice: found_price,
  5193. MedicalInsurancePrice: medical_insurance_price,
  5194. PrivatePrice: private_price,
  5195. IsMedicineInsurance: 1,
  5196. SettleType: settle_accounts_type,
  5197. SettleStartTime: start_time,
  5198. SettleEndTime: end_time,
  5199. Creator: roles.AdminUserId,
  5200. Modify: roles.AdminUserId,
  5201. FaPiaoNumber: fapiao_number,
  5202. FaPiaoCode: fapiao_code,
  5203. PType: 2,
  5204. Diagnosis: diagnosis_id,
  5205. }
  5206. err = service.CreateOrder(order)
  5207. if err != nil {
  5208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  5209. return
  5210. }
  5211. for _, item := range res.Output.Result {
  5212. temp := strings.Split(item.FeedetlSn, "-")
  5213. var advice_id int64 = 0
  5214. var project_id int64 = 0
  5215. var types int64 = 0
  5216. id, _ := strconv.ParseInt(temp[2], 10, 64)
  5217. types, _ = strconv.ParseInt(temp[1], 10, 64)
  5218. if temp[1] == "1" {
  5219. advice_id = id
  5220. project_id = 0
  5221. } else if temp[1] == "2" {
  5222. advice_id = 0
  5223. project_id = id
  5224. }
  5225. info := &models.HisOrderInfo{
  5226. OrderNumber: order.Number,
  5227. FeedetlSn: item.FeedetlSn,
  5228. UploadDate: time.Now().Unix(),
  5229. AdviceId: advice_id,
  5230. DetItemFeeSumamt: item.DetItemFeeSumamt,
  5231. Cnt: item.Cnt,
  5232. Pric: float64(item.Pric),
  5233. PatientId: his.PatientId,
  5234. PricUplmtAmt: item.PricUplmtAmt,
  5235. SelfpayProp: item.SelfpayProp,
  5236. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  5237. OverlmtAmt: item.OverlmtAmt,
  5238. PreselfpayAmt: item.PreselfpayAmt,
  5239. BasMednFlag: item.BasMednFlag,
  5240. MedChrgitmType: item.MedChrgitmType,
  5241. HiNegoDrugFlag: item.HiNegoDrugFlag,
  5242. Status: 1,
  5243. Memo: item.Memo,
  5244. Mtime: time.Now().Unix(),
  5245. InscpScpAmt: item.InscpScpAmt,
  5246. DrtReimFlag: item.DrtReimFlag,
  5247. Ctime: time.Now().Unix(),
  5248. ListSpItemFlag: item.ListSpItemFlag,
  5249. ChldMedcFlag: item.ChldMedcFlag,
  5250. LmtUsedFlag: item.LmtUsedFlag,
  5251. ChrgitmLv: item.ChrgitmLv,
  5252. UserOrgId: adminUser.CurrentOrgId,
  5253. HisPatientId: his.ID,
  5254. OrderId: order.ID,
  5255. ProjectId: project_id,
  5256. Type: types,
  5257. }
  5258. service.CreateOrderInfo(info)
  5259. }
  5260. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  5261. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  5262. var total float64
  5263. for _, item := range prescriptions {
  5264. if item.Type == 1 { //药品
  5265. for _, subItem := range item.HisDoctorAdviceInfo {
  5266. total = total + (subItem.Price * subItem.PrescribingNumber)
  5267. }
  5268. }
  5269. if item.Type == 2 { //项目
  5270. for _, subItem := range item.HisPrescriptionProject {
  5271. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  5272. total = total + (subItem.Price * cnt)
  5273. }
  5274. }
  5275. }
  5276. for _, item := range prescriptions {
  5277. for _, subItem := range item.HisAdditionalCharge {
  5278. total = total + (subItem.Price * float64(subItem.Count))
  5279. }
  5280. }
  5281. var allTotal string
  5282. if adminUser.CurrentOrgId == 9919 {
  5283. allTotal = fmt.Sprintf("%.4f", total)
  5284. } else {
  5285. allTotal = fmt.Sprintf("%.4f", total)
  5286. }
  5287. if res.Infcode == 0 {
  5288. var rf []*ResultFive
  5289. json.Unmarshal([]byte(his.Iinfo), &rf)
  5290. chrg_bchno := chrg_bchno
  5291. cert_no := his.Certno
  5292. var insutypes []string
  5293. var insutype string
  5294. var is390 int = 0
  5295. var is310 int = 0
  5296. for _, item := range rf {
  5297. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5298. insutypes = append(insutypes, item.Insutype)
  5299. }
  5300. }
  5301. if len(insutypes) == 1 {
  5302. insutype = insutypes[0]
  5303. } else {
  5304. for _, i := range insutypes {
  5305. if i == "390" {
  5306. is390 = 1
  5307. }
  5308. if i == "310" {
  5309. is310 = 1
  5310. }
  5311. }
  5312. }
  5313. if is390 == 1 {
  5314. insutype = "390"
  5315. }
  5316. if is310 == 1 {
  5317. insutype = "310"
  5318. }
  5319. if len(insutypes) == 0 {
  5320. insutype = "310"
  5321. }
  5322. if len(insutypes) == 2 {
  5323. insutype = strconv.FormatInt(his.SocialType, 10)
  5324. }
  5325. insutype = strconv.FormatInt(his.SocialType, 10)
  5326. //insutype = "390"
  5327. if his.IdCardType == 1 {
  5328. // cert_no = his.MedicalInsuranceNumber
  5329. cert_no = his.Certno
  5330. } else {
  5331. cert_no = his.Certno
  5332. }
  5333. var res ResultSeven
  5334. var resSeven10265 ResultSeven10265
  5335. var src_resquest string
  5336. var result2 string
  5337. var acct_used_flag string
  5338. fmt.Println("pay_way")
  5339. fmt.Println(pay_way)
  5340. fmt.Println("pay_way")
  5341. if pay_way == 4 {
  5342. acct_used_flag = "1"
  5343. } else {
  5344. acct_used_flag = "0"
  5345. }
  5346. if miConfig.MdtrtareaAdmvs == "421300" {
  5347. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5348. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5349. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5350. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5351. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5352. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5353. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5354. resp, requestErr := http.Get(api)
  5355. if requestErr != nil {
  5356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5357. return
  5358. }
  5359. body, ioErr := ioutil.ReadAll(resp.Body)
  5360. if ioErr != nil {
  5361. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5362. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5363. return
  5364. }
  5365. var respJSON map[string]interface{}
  5366. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5367. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5368. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5369. return
  5370. }
  5371. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5372. result, _ := json.Marshal(respJSON)
  5373. if miConfig.Code == "H15049901371" {
  5374. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5375. utils.ErrorLog("解析失败:%v", err)
  5376. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5377. return
  5378. }
  5379. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5380. res.Output = resSeven10265.Output
  5381. res.ErrMsg = resSeven10265.ErrMsg
  5382. res.Cainfo = resSeven10265.Cainfo
  5383. res.WarnMsg = resSeven10265.WarnMsg
  5384. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5385. res.Infcode = infocode
  5386. } else {
  5387. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5388. utils.ErrorLog("解析失败:%v", err)
  5389. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5390. return
  5391. }
  5392. }
  5393. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5394. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5395. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5396. //psn_info, _ := service.GetPsnByPatientId(id)
  5397. bas := strings.Split(psn_info.CardInfo, "|")
  5398. if his.IdCardType == 1 {
  5399. cert_no = bas[2]
  5400. } else if his.IdCardType == 3 {
  5401. cert_no = his.Certno
  5402. psn_info.VerifyNumber = his.Certno + "|" + psn_info.VerifyNumber
  5403. } else {
  5404. cert_no = bas[1]
  5405. }
  5406. //江苏地区国家医保医疗类别
  5407. //职工透析:医疗类别选特殊情况门诊9933
  5408. //居民血透门慢: 医疗类别选门诊慢病1402
  5409. //var med_type string
  5410. //if his.Insutype == "310" {
  5411. // if reg_type == 14 {
  5412. // med_type = "9933"
  5413. // } else if reg_type == 11 {
  5414. // med_type = "11"
  5415. //
  5416. // }
  5417. //} else if his.Insutype == "390" {
  5418. // if reg_type == 14 {
  5419. // med_type = "1402"
  5420. // } else if reg_type == 11 {
  5421. // med_type = "11"
  5422. // }
  5423. //}
  5424. //psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5425. var api string
  5426. if miConfig.MdtrtareaAdmvs == "320921" {
  5427. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5428. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5429. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5430. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5431. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5432. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5433. "&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
  5434. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5435. } else {
  5436. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5437. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5438. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5439. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5440. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5441. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5442. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5443. "&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
  5444. }
  5445. resp, requestErr := http.Get(api)
  5446. if requestErr != nil {
  5447. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5448. return
  5449. }
  5450. body, ioErr := ioutil.ReadAll(resp.Body)
  5451. if ioErr != nil {
  5452. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5454. return
  5455. }
  5456. var respJSON map[string]interface{}
  5457. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5458. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5459. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5460. return
  5461. }
  5462. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5463. result, _ := json.Marshal(respJSON)
  5464. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5465. utils.ErrorLog("解析失败:%v", err)
  5466. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5467. return
  5468. }
  5469. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5470. res.Output = resSeven10265.Output
  5471. res.ErrMsg = resSeven10265.ErrMsg
  5472. res.Cainfo = resSeven10265.Cainfo
  5473. res.WarnMsg = resSeven10265.WarnMsg
  5474. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5475. res.Infcode = infocode
  5476. } else {
  5477. if miConfig.Code == "H15049901371" {
  5478. //赤峰地区国家医保医疗类别
  5479. //职工透析:医疗类别选特殊情况门诊990502
  5480. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5481. var med_type string
  5482. if his.Insutype == "390" {
  5483. if reg_type == 14 {
  5484. med_type = "9933"
  5485. } else if reg_type == 11 {
  5486. med_type = "11"
  5487. }
  5488. } else if his.Insutype == "310" {
  5489. if reg_type == 14 {
  5490. med_type = "990502"
  5491. } else if reg_type == 11 {
  5492. med_type = "11"
  5493. }
  5494. }
  5495. 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)
  5496. } else {
  5497. 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)
  5498. }
  5499. //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)
  5500. var dat map[string]interface{}
  5501. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5502. fmt.Println(dat)
  5503. } else {
  5504. fmt.Println(err)
  5505. }
  5506. saveLog(result2, src_resquest, "2207", "结算")
  5507. userJSONBytes, _ := json.Marshal(dat)
  5508. if miConfig.Code == "H15049901371" {
  5509. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5510. utils.ErrorLog("解析失败:%v", err)
  5511. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5512. return
  5513. }
  5514. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5515. res.Output = resSeven10265.Output
  5516. res.ErrMsg = resSeven10265.ErrMsg
  5517. res.Cainfo = resSeven10265.Cainfo
  5518. res.WarnMsg = resSeven10265.WarnMsg
  5519. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5520. res.Infcode = infocode
  5521. } else {
  5522. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5523. utils.ErrorLog("解析失败:%v", err)
  5524. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5525. return
  5526. }
  5527. }
  5528. }
  5529. if res.Infcode != 0 {
  5530. errlog := &models.HisOrderError{
  5531. UserOrgId: adminUser.CurrentOrgId,
  5532. Ctime: time.Now().Unix(),
  5533. Mtime: time.Now().Unix(),
  5534. Number: chrg_bchno,
  5535. ErrMsg: res.ErrMsg,
  5536. Status: 1,
  5537. PatientId: id,
  5538. RecordTime: recordDateTime,
  5539. Stage: 6,
  5540. }
  5541. service.CreateErrMsgLog(errlog)
  5542. c.ServeSuccessJSON(map[string]interface{}{
  5543. "failed_code": -10,
  5544. "msg": res.ErrMsg,
  5545. })
  5546. return
  5547. } else {
  5548. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5549. order.OrderStatus = 2
  5550. order.Status = 1
  5551. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5552. order.SetlId = res.Output.Setlinfo.SetlID
  5553. order.PsnNo = res.Output.Setlinfo.PsnNo
  5554. order.PsnName = res.Output.Setlinfo.PsnName
  5555. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5556. order.Certno = res.Output.Setlinfo.Certno
  5557. order.Gend = res.Output.Setlinfo.Gend
  5558. order.Naty = res.Output.Setlinfo.Naty
  5559. order.Age = res.Output.Setlinfo.Age
  5560. order.Insutype = res.Output.Setlinfo.Insutype
  5561. order.PsnType = res.Output.Setlinfo.PsnType
  5562. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5563. order.SetlTime = res.Output.Setlinfo.SetlTime
  5564. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5565. if res.Output.Setlinfo.MedType == "140101" {
  5566. order.MedType = "14"
  5567. } else {
  5568. order.MedType = res.Output.Setlinfo.MedType
  5569. }
  5570. if reg_type == 1112 {
  5571. order.MedType = "1112"
  5572. }
  5573. if reg_type == 1111 {
  5574. order.MedType = "1111"
  5575. }
  5576. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5577. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5578. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5579. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5580. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5581. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5582. order.HifpPay = res.Output.Setlinfo.HifpPay
  5583. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5584. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5585. order.HifesPay = res.Output.Setlinfo.HifesPay
  5586. order.HifobPay = res.Output.Setlinfo.HifobPay
  5587. order.MafPay = res.Output.Setlinfo.MafPay
  5588. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5589. order.OthPay = res.Output.Setlinfo.OthPay
  5590. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5591. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5592. order.AcctPay = res.Output.Setlinfo.AcctPay
  5593. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5594. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5595. order.Balc = res.Output.Setlinfo.Balc
  5596. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5597. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5598. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5599. order.ClrType = res.Output.Setlinfo.ClrType
  5600. order.ClrWay = res.Output.Setlinfo.ClrWay
  5601. order.Creator = order.Creator
  5602. order.Modify = roles.AdminUserId
  5603. order.RequestLog = src_resquest
  5604. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5605. detailStr := string(setlDetail)
  5606. order.SetlDetail = detailStr
  5607. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5608. err = service.UpDateOrder(order)
  5609. if err == nil {
  5610. //判断是否使用了押金
  5611. if dec_way == "true" {
  5612. tmpstring := strconv.FormatInt(order.ID, 10)
  5613. order.Decimal = decimal
  5614. service.UpDateOrder(order)
  5615. //扣押金
  5616. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5617. if errmsg != nil {
  5618. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5619. return
  5620. }
  5621. }
  5622. c.ServeSuccessJSON(map[string]interface{}{
  5623. "msg": "结算成功",
  5624. })
  5625. } else {
  5626. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5627. return
  5628. }
  5629. }
  5630. } else {
  5631. adminUser := c.GetAdminUserInfo()
  5632. errlog := &models.HisOrderError{
  5633. UserOrgId: adminUser.CurrentOrgId,
  5634. Ctime: time.Now().Unix(),
  5635. Mtime: time.Now().Unix(),
  5636. ErrMsg: res.ErrMsg,
  5637. Status: 1,
  5638. PatientId: id,
  5639. RecordTime: recordDateTime,
  5640. Stage: 4,
  5641. }
  5642. service.CreateErrMsgLog(errlog)
  5643. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  5644. return
  5645. }
  5646. } else {
  5647. adminUser := c.GetAdminUserInfo()
  5648. errlog := &models.HisOrderError{
  5649. UserOrgId: adminUser.CurrentOrgId,
  5650. Ctime: time.Now().Unix(),
  5651. Mtime: time.Now().Unix(),
  5652. ErrMsg: res.ErrMsg,
  5653. Status: 1,
  5654. PatientId: id,
  5655. RecordTime: recordDateTime,
  5656. Stage: 4,
  5657. }
  5658. service.CreateErrMsgLog(errlog)
  5659. c.ServeSuccessJSON(map[string]interface{}{
  5660. "failed_code": -10,
  5661. "msg": res.ErrMsg,
  5662. })
  5663. return
  5664. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  5665. //return
  5666. }
  5667. }
  5668. }
  5669. } else if tempOrder.ID > 0 {
  5670. if tempOrder.IsPre == 1 {
  5671. allTotal := fmt.Sprintf("%.4f", tempOrder.MedfeeSumamt)
  5672. var rf []*ResultFive
  5673. json.Unmarshal([]byte(his.Iinfo), &rf)
  5674. chrg_bchno := tempOrder.Number
  5675. cert_no := his.Certno
  5676. var insutypes []string
  5677. var insutype string
  5678. var is390 int = 0
  5679. var is310 int = 0
  5680. for _, item := range rf {
  5681. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  5682. insutypes = append(insutypes, item.Insutype)
  5683. }
  5684. }
  5685. if len(insutypes) == 1 {
  5686. insutype = insutypes[0]
  5687. } else {
  5688. for _, i := range insutypes {
  5689. if i == "390" {
  5690. is390 = 1
  5691. }
  5692. if i == "310" {
  5693. is310 = 1
  5694. }
  5695. }
  5696. }
  5697. if is390 == 1 {
  5698. insutype = "390"
  5699. }
  5700. if is310 == 1 {
  5701. insutype = "310"
  5702. }
  5703. if len(insutypes) == 0 {
  5704. insutype = "310"
  5705. }
  5706. if len(insutypes) == 2 {
  5707. insutype = strconv.FormatInt(his.SocialType, 64)
  5708. }
  5709. //insutype = "390"
  5710. if his.IdCardType == 1 {
  5711. // cert_no = his.MedicalInsuranceNumber
  5712. cert_no = his.Certno
  5713. } else {
  5714. cert_no = his.Certno
  5715. }
  5716. var res ResultSeven
  5717. var resSeven10265 ResultSeven10265
  5718. var src_resquest string
  5719. var result2 string
  5720. var acct_used_flag string
  5721. fmt.Println("pay_way")
  5722. fmt.Println(pay_way)
  5723. fmt.Println("pay_way")
  5724. if pay_way == 4 {
  5725. acct_used_flag = "1"
  5726. } else {
  5727. acct_used_flag = "0"
  5728. }
  5729. if miConfig.MdtrtareaAdmvs == "421300" {
  5730. api := "http://192.168.124.4:9532/" + "hbyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5731. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5732. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5733. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5734. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5735. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5736. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10) + "&acct_used_flag=" + acct_used_flag
  5737. resp, requestErr := http.Get(api)
  5738. if requestErr != nil {
  5739. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5740. return
  5741. }
  5742. body, ioErr := ioutil.ReadAll(resp.Body)
  5743. if ioErr != nil {
  5744. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5746. return
  5747. }
  5748. var respJSON map[string]interface{}
  5749. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5750. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5752. return
  5753. }
  5754. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5755. result, _ := json.Marshal(respJSON)
  5756. fmt.Println("log")
  5757. fmt.Println(string(result))
  5758. if err := json.Unmarshal([]byte(result), &res); err != nil {
  5759. utils.ErrorLog("解析失败:%v", err)
  5760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5761. return
  5762. }
  5763. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  5764. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  5765. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  5766. //psn_info, _ := service.GetPsnByPatientId(id)
  5767. bas := strings.Split(psn_info.CardInfo, "|")
  5768. if his.IdCardType == 1 {
  5769. cert_no = bas[2]
  5770. } else {
  5771. cert_no = bas[1]
  5772. }
  5773. //江苏地区国家医保医疗类别
  5774. //职工透析:医疗类别选特殊情况门诊9933
  5775. //居民血透门慢: 医疗类别选门诊慢病1402
  5776. //var med_type string
  5777. //if his.Insutype == "310" {
  5778. // if reg_type == 14 {
  5779. // med_type = "9933"
  5780. // } else if reg_type == 11 {
  5781. // med_type = "11"
  5782. //
  5783. // }
  5784. //} else if his.Insutype == "390" {
  5785. // if reg_type == 14 {
  5786. // med_type = "1402"
  5787. // } else if reg_type == 11 {
  5788. // med_type = "11"
  5789. // }
  5790. //}
  5791. var api string
  5792. if miConfig.MdtrtareaAdmvs == "320921" {
  5793. api = "http://192.168.3.111:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5794. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5795. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5796. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5797. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5798. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5799. "&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
  5800. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5801. } else {
  5802. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  5803. api = "http://192.168.5.251:9532/" + "jsyb/2207?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  5804. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  5805. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  5806. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  5807. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  5808. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  5809. "&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
  5810. }
  5811. resp, requestErr := http.Get(api)
  5812. if requestErr != nil {
  5813. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5814. return
  5815. }
  5816. body, ioErr := ioutil.ReadAll(resp.Body)
  5817. if ioErr != nil {
  5818. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  5819. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5820. return
  5821. }
  5822. var respJSON map[string]interface{}
  5823. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  5824. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  5825. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5826. return
  5827. }
  5828. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  5829. result, _ := json.Marshal(respJSON)
  5830. fmt.Println("log")
  5831. fmt.Println(string(result))
  5832. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  5833. utils.ErrorLog("解析失败:%v", err)
  5834. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5835. return
  5836. }
  5837. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5838. res.Output = resSeven10265.Output
  5839. res.ErrMsg = resSeven10265.ErrMsg
  5840. res.Cainfo = resSeven10265.Cainfo
  5841. res.WarnMsg = resSeven10265.WarnMsg
  5842. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5843. res.Infcode = infocode
  5844. } else {
  5845. var src_resquest string
  5846. if miConfig.Code == "H15049901371" {
  5847. //赤峰地区国家医保医疗类别
  5848. //职工透析:医疗类别选特殊情况门诊990502
  5849. //居民定额血透门慢: 医疗类别选门诊慢病140104
  5850. var med_type string
  5851. if his.Insutype == "390" {
  5852. if reg_type == 14 {
  5853. med_type = "9933"
  5854. } else if reg_type == 11 {
  5855. med_type = "11"
  5856. }
  5857. } else if his.Insutype == "310" {
  5858. if reg_type == 14 {
  5859. med_type = "990502"
  5860. } else if reg_type == 11 {
  5861. med_type = "11"
  5862. }
  5863. }
  5864. 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)
  5865. } else {
  5866. 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)
  5867. }
  5868. var dat map[string]interface{}
  5869. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  5870. fmt.Println(dat)
  5871. } else {
  5872. fmt.Println(err)
  5873. }
  5874. saveLog(result2, src_resquest, "2207", "结算")
  5875. userJSONBytes, _ := json.Marshal(dat)
  5876. if miConfig.Code == "H15049901371" {
  5877. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  5878. utils.ErrorLog("解析失败:%v", err)
  5879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5880. return
  5881. }
  5882. res.InfRefmsgid = resSeven10265.InfRefmsgid
  5883. res.Output = resSeven10265.Output
  5884. res.ErrMsg = resSeven10265.ErrMsg
  5885. res.Cainfo = resSeven10265.Cainfo
  5886. res.WarnMsg = resSeven10265.WarnMsg
  5887. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  5888. res.Infcode = infocode
  5889. } else {
  5890. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5891. utils.ErrorLog("解析失败:%v", err)
  5892. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5893. return
  5894. }
  5895. }
  5896. }
  5897. if res.Infcode != 0 {
  5898. errlog := &models.HisOrderError{
  5899. UserOrgId: adminUser.CurrentOrgId,
  5900. Ctime: time.Now().Unix(),
  5901. Mtime: time.Now().Unix(),
  5902. Number: chrg_bchno,
  5903. ErrMsg: res.ErrMsg,
  5904. Status: 1,
  5905. PatientId: id,
  5906. RecordTime: recordDateTime,
  5907. Stage: 6,
  5908. }
  5909. service.CreateErrMsgLog(errlog)
  5910. c.ServeSuccessJSON(map[string]interface{}{
  5911. "failed_code": -10,
  5912. "msg": res.ErrMsg,
  5913. })
  5914. return
  5915. } else {
  5916. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  5917. order.OrderStatus = 2
  5918. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  5919. order.SetlId = res.Output.Setlinfo.SetlID
  5920. order.PsnNo = res.Output.Setlinfo.PsnNo
  5921. order.PsnName = res.Output.Setlinfo.PsnName
  5922. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  5923. order.Certno = res.Output.Setlinfo.Certno
  5924. order.Gend = res.Output.Setlinfo.Gend
  5925. order.Naty = res.Output.Setlinfo.Naty
  5926. order.Age = res.Output.Setlinfo.Age
  5927. order.Insutype = res.Output.Setlinfo.Insutype
  5928. order.PsnType = res.Output.Setlinfo.PsnType
  5929. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  5930. order.SetlTime = res.Output.Setlinfo.SetlTime
  5931. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  5932. //order.MedType = res.Output.Setlinfo.MedType
  5933. if reg_type == 1112 {
  5934. order.MedType = "1112"
  5935. }
  5936. if reg_type == 1111 {
  5937. order.MedType = "1111"
  5938. }
  5939. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  5940. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  5941. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  5942. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  5943. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  5944. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  5945. order.HifpPay = res.Output.Setlinfo.HifpPay
  5946. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  5947. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  5948. order.HifesPay = res.Output.Setlinfo.HifesPay
  5949. order.HifobPay = res.Output.Setlinfo.HifobPay
  5950. order.MafPay = res.Output.Setlinfo.MafPay
  5951. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  5952. order.OthPay = res.Output.Setlinfo.OthPay
  5953. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  5954. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  5955. order.AcctPay = res.Output.Setlinfo.AcctPay
  5956. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  5957. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  5958. order.Balc = res.Output.Setlinfo.Balc
  5959. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  5960. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  5961. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  5962. order.ClrWay = res.Output.Setlinfo.ClrWay
  5963. order.Creator = order.Creator
  5964. order.Modify = roles.AdminUserId
  5965. order.RequestLog = src_resquest
  5966. order.Diagnosis = diagnosis_id
  5967. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  5968. detailStr := string(setlDetail)
  5969. order.SetlDetail = detailStr
  5970. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  5971. err = service.UpDateOrder(order)
  5972. if err == nil {
  5973. //判断是否使用了押金
  5974. if dec_way == "true" {
  5975. tmpstring := strconv.FormatInt(order.ID, 10)
  5976. //扣押金
  5977. order.Decimal = decimal
  5978. service.UpDateOrder(order)
  5979. errmsg = service.SpendDeposit(c.GetAdminUserInfo().CurrentOrgId, id, c.GetAdminUserInfo().AdminUser.Id, tmpstring, decimal)
  5980. if errmsg != nil {
  5981. c.ServeFailJsonSend(enums.ErrorCodeParamWrong, errmsg.Error())
  5982. return
  5983. }
  5984. }
  5985. c.ServeSuccessJSON(map[string]interface{}{
  5986. "msg": "结算成功",
  5987. })
  5988. } else {
  5989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  5990. return
  5991. }
  5992. }
  5993. }
  5994. }
  5995. }
  5996. //func (c *HisApiController) GetPreUploadInfo() {
  5997. // id, _ := c.GetInt64("id")
  5998. // record_time := c.GetString("record_time")
  5999. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6000. // admin_user_id, _ := c.GetInt64("admin_user_id")
  6001. //
  6002. // timeLayout := "2006-01-02"
  6003. // loc, _ := time.LoadLocation("Local")
  6004. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6005. // if err != nil {
  6006. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6007. // return
  6008. // }
  6009. // recordDateTime := theTime.Unix()
  6010. // adminUser := c.GetAdminUserInfo()
  6011. //
  6012. // var prescriptions []*models.HisPrescription
  6013. //
  6014. // var start_time int64
  6015. // var end_time int64
  6016. //
  6017. // data := make(map[string]interface{})
  6018. // if settle_accounts_type == 1 { //日结
  6019. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  6020. // data["pre"] = prescriptions
  6021. //
  6022. // } else { //月结
  6023. // start_time_str := c.GetString("start_time")
  6024. // end_time_str := c.GetString("end_time")
  6025. // timeLayout := "2006-01-02"
  6026. // loc, _ := time.LoadLocation("Local")
  6027. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6028. // if err != nil {
  6029. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6030. // return
  6031. // }
  6032. // recordStartTime := theStartTime.Unix()
  6033. // start_time = recordStartTime
  6034. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6035. // if err != nil {
  6036. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6037. // return
  6038. // }
  6039. // recordEndTime := theEndTime.Unix()
  6040. // end_time = recordEndTime
  6041. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  6042. // data["pre"] = prescriptions
  6043. //
  6044. // }
  6045. //
  6046. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6047. //
  6048. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6049. // timestamp := time.Now().Unix()
  6050. // tempTime := time.Unix(timestamp, 0)
  6051. // timeFormat := tempTime.Format("20060102150405")
  6052. // chrgBchno := rand.Intn(100000) + 10000
  6053. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6054. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6055. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6056. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6057. // strconv.FormatInt(his.PatientId, 10)
  6058. // client := &http.Client{}
  6059. // data["psn_no"] = his.PsnNo
  6060. // data["mdtrt_id"] = his.Number
  6061. // data["chrg_bchno"] = chrg_bchno
  6062. // data["org_name"] = miConfig.OrgName
  6063. // data["doctor"] = roles.UserName
  6064. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6065. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6066. // data["fixmedins_code"] = miConfig.Code
  6067. // data["dept_code"] = department.Number
  6068. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6069. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6070. // data["secret_key"] = miConfig.SecretKey
  6071. // var ids []int64
  6072. //
  6073. // for _, item := range prescriptions {
  6074. // ids = append(ids, item.ID)
  6075. // }
  6076. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6077. // if config.IsOpen == 1 { //对接了医保,走医保流程
  6078. // bytesData, _ := json.Marshal(data)
  6079. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  6080. // resp, _ := client.Do(req)
  6081. // defer resp.Body.Close()
  6082. // body, ioErr := ioutil.ReadAll(resp.Body)
  6083. // if ioErr != nil {
  6084. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6085. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6086. // return
  6087. // }
  6088. // var respJSON map[string]interface{}
  6089. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6090. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6091. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6092. // return
  6093. // }
  6094. //
  6095. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6096. // userJSONBytes, _ := json.Marshal(respJSON)
  6097. // var res ResultFour
  6098. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6099. // utils.ErrorLog("解析失败:%v", err)
  6100. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6101. // return
  6102. // }
  6103. //
  6104. // if res.Infcode == 0 {
  6105. // order := &models.HisOrder{
  6106. // UserOrgId: adminUser.CurrentOrgId,
  6107. // HisPatientId: his.ID,
  6108. // PatientId: his.PatientId,
  6109. // SettleAccountsDate: recordDateTime,
  6110. // Ctime: time.Now().Unix(),
  6111. // Mtime: time.Now().Unix(),
  6112. // Status: 1,
  6113. // Number: chrg_bchno,
  6114. // Infcode: res.Infcode,
  6115. // WarnMsg: res.WarnMsg,
  6116. // Cainfo: res.Cainfo,
  6117. // ErrMsg: res.ErrMsg,
  6118. // RespondTime: res.RefmsgTime,
  6119. // InfRefmsgid: res.InfRefmsgid,
  6120. // OrderStatus: 1,
  6121. // IsMedicineInsurance: 1,
  6122. // SettleType: settle_accounts_type,
  6123. // SettleStartTime: start_time,
  6124. // SettleEndTime: end_time,
  6125. // Creator: roles.ID,
  6126. // Modify: roles.ID,
  6127. // PType: 2,
  6128. // }
  6129. // err = service.CreateOrder(order)
  6130. // if err != nil {
  6131. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6132. // return
  6133. // }
  6134. //
  6135. // for _, item := range res.Output.Result {
  6136. // temp := strings.Split(item.FeedetlSn, "-")
  6137. // var advice_id int64 = 0
  6138. // var project_id int64 = 0
  6139. // var types int64 = 0
  6140. //
  6141. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  6142. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  6143. //
  6144. // if temp[1] == "1" {
  6145. // advice_id = id
  6146. // project_id = 0
  6147. // } else if temp[1] == "2" {
  6148. // advice_id = 0
  6149. // project_id = id
  6150. // }
  6151. //
  6152. // info := &models.HisOrderInfo{
  6153. // OrderNumber: order.Number,
  6154. // FeedetlSn: item.FeedetlSn,
  6155. // UploadDate: time.Now().Unix(),
  6156. // AdviceId: advice_id,
  6157. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  6158. // Cnt: item.Cnt,
  6159. // Pric: float64(item.Pric),
  6160. // PatientId: his.PatientId,
  6161. // PricUplmtAmt: item.PricUplmtAmt,
  6162. // SelfpayProp: item.SelfpayProp,
  6163. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  6164. // OverlmtAmt: item.OverlmtAmt,
  6165. // PreselfpayAmt: item.PreselfpayAmt,
  6166. // BasMednFlag: item.BasMednFlag,
  6167. // MedChrgitmType: item.MedChrgitmType,
  6168. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  6169. // Status: 1,
  6170. // Memo: item.Memo,
  6171. // Mtime: time.Now().Unix(),
  6172. // InscpScpAmt: item.InscpScpAmt,
  6173. // DrtReimFlag: item.DrtReimFlag,
  6174. // Ctime: time.Now().Unix(),
  6175. // ListSpItemFlag: item.ListSpItemFlag,
  6176. // ChldMedcFlag: item.ChldMedcFlag,
  6177. // LmtUsedFlag: item.LmtUsedFlag,
  6178. // ChrgitmLv: item.ChrgitmLv,
  6179. // UserOrgId: adminUser.CurrentOrgId,
  6180. // HisPatientId: his.ID,
  6181. // OrderId: order.ID,
  6182. // ProjectId: project_id,
  6183. // Type: types,
  6184. // }
  6185. // service.CreateOrderInfo(info)
  6186. //
  6187. // }
  6188. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6189. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  6190. //
  6191. // var total float64
  6192. // for _, item := range prescriptions {
  6193. // if item.Type == 1 { //药品
  6194. // for _, subItem := range item.HisDoctorAdviceInfo {
  6195. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6196. // }
  6197. // }
  6198. // if item.Type == 2 { //项目
  6199. // for _, subItem := range item.HisPrescriptionProject {
  6200. // total = total + (subItem.Price * float64(subItem.Count))
  6201. // }
  6202. // }
  6203. // }
  6204. //
  6205. // for _, item := range prescriptions {
  6206. // for _, subItem := range item.HisAdditionalCharge {
  6207. // total = total + (subItem.Price * float64(subItem.Count))
  6208. // }
  6209. // }
  6210. //
  6211. // allTotal := fmt.Sprintf("%.2f", total)
  6212. // if res.Infcode == 0 {
  6213. // var rf []*ResultFive
  6214. // json.Unmarshal([]byte(his.Iinfo), &rf)
  6215. // psn_no := his.PsnNo
  6216. // mdtrt_id := his.Number
  6217. // chrg_bchno := chrg_bchno
  6218. // cert_no := his.Certno
  6219. // insutype := rf[0].Insutype
  6220. //
  6221. // if his.IdCardType == 1 {
  6222. // cert_no = his.MedicalInsuranceNumber
  6223. //
  6224. // } else {
  6225. //
  6226. // cert_no = his.Certno
  6227. //
  6228. // }
  6229. //
  6230. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  6231. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  6232. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  6233. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  6234. // resp, requestErr := http.Get(api)
  6235. // if requestErr != nil {
  6236. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6237. // return
  6238. // }
  6239. // defer resp.Body.Close()
  6240. // body, ioErr := ioutil.ReadAll(resp.Body)
  6241. // if ioErr != nil {
  6242. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6244. // return
  6245. // }
  6246. // var respJSON map[string]interface{}
  6247. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  6248. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6249. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6250. // return
  6251. // }
  6252. // fmt.Println(respJSON)
  6253. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6254. // userJSONBytes, _ := json.Marshal(respJSON)
  6255. // var res ResultSeven
  6256. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6257. // utils.ErrorLog("解析失败:%v", err)
  6258. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6259. // return
  6260. // }
  6261. // if res.Infcode != 0 {
  6262. // errlog := &models.HisOrderError{
  6263. // UserOrgId: adminUser.CurrentOrgId,
  6264. // Ctime: time.Now().Unix(),
  6265. // Mtime: time.Now().Unix(),
  6266. // Number: chrg_bchno,
  6267. // ErrMsg: res.ErrMsg,
  6268. // Status: 1,
  6269. // PatientId: id,
  6270. // RecordTime: recordDateTime,
  6271. // Stage: 7,
  6272. // }
  6273. // service.CreateErrMsgLog(errlog)
  6274. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6275. // return
  6276. // } else {
  6277. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  6278. // order.OrderStatus = 1
  6279. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  6280. // order.SetlId = res.Output.Setlinfo.SetlID
  6281. // order.PsnNo = res.Output.Setlinfo.PsnNo
  6282. // order.PsnName = res.Output.Setlinfo.PsnName
  6283. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  6284. // order.Certno = res.Output.Setlinfo.Certno
  6285. // order.Gend = res.Output.Setlinfo.Gend
  6286. // order.Naty = res.Output.Setlinfo.Naty
  6287. // order.Age = res.Output.Setlinfo.Age
  6288. // order.Insutype = res.Output.Setlinfo.Insutype
  6289. // order.PsnType = res.Output.Setlinfo.PsnType
  6290. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  6291. // order.SetlTime = res.Output.Setlinfo.SetlTime
  6292. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  6293. // order.MedType = res.Output.Setlinfo.MedType
  6294. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  6295. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  6296. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  6297. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  6298. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  6299. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  6300. // order.HifpPay = res.Output.Setlinfo.HifpPay
  6301. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  6302. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  6303. // order.HifesPay = res.Output.Setlinfo.HifesPay
  6304. // order.HifobPay = res.Output.Setlinfo.HifobPay
  6305. // order.MafPay = res.Output.Setlinfo.MafPay
  6306. // order.OthPay = res.Output.Setlinfo.OthPay
  6307. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  6308. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  6309. // order.AcctPay = res.Output.Setlinfo.AcctPay
  6310. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  6311. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  6312. // order.Balc = res.Output.Setlinfo.Balc
  6313. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  6314. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  6315. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  6316. // order.ClrWay = res.Output.Setlinfo.ClrWay
  6317. // order.Creator = order.Creator
  6318. // order.Modify = roles.ID
  6319. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  6320. // detailStr := string(setlDetail)
  6321. // order.SetlDetail = detailStr
  6322. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6323. // err = service.UpDateOrder(order)
  6324. // if err == nil {
  6325. // c.ServeSuccessJSON(map[string]interface{}{
  6326. // "msg": "预结算成功",
  6327. // })
  6328. // } else {
  6329. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6330. // return
  6331. // }
  6332. // }
  6333. // } else {
  6334. // adminUser := c.GetAdminUserInfo()
  6335. // errlog := &models.HisOrderError{
  6336. // UserOrgId: adminUser.CurrentOrgId,
  6337. // Ctime: time.Now().Unix(),
  6338. // Mtime: time.Now().Unix(),
  6339. // ErrMsg: res.ErrMsg,
  6340. // Status: 1,
  6341. // PatientId: id,
  6342. // RecordTime: recordDateTime,
  6343. // Stage: 4,
  6344. // }
  6345. // service.CreateErrMsgLog(errlog)
  6346. //
  6347. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  6348. // return
  6349. // }
  6350. // } else {
  6351. // adminUser := c.GetAdminUserInfo()
  6352. // errlog := &models.HisOrderError{
  6353. // UserOrgId: adminUser.CurrentOrgId,
  6354. // Ctime: time.Now().Unix(),
  6355. // Mtime: time.Now().Unix(),
  6356. // ErrMsg: res.ErrMsg,
  6357. // Status: 1,
  6358. // PatientId: id,
  6359. // RecordTime: recordDateTime,
  6360. // Stage: 4,
  6361. // }
  6362. // service.CreateErrMsgLog(errlog)
  6363. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  6364. // return
  6365. // }
  6366. //
  6367. // } else {
  6368. // var total float64
  6369. // for _, item := range prescriptions {
  6370. // if item.Type == 1 { //药品
  6371. // for _, subItem := range item.HisDoctorAdviceInfo {
  6372. // total = total + (subItem.Price * subItem.PrescribingNumber)
  6373. // }
  6374. // }
  6375. // if item.Type == 2 { //项目
  6376. // for _, subItem := range item.HisPrescriptionProject {
  6377. // total = total + (subItem.Price * float64(subItem.Count))
  6378. // }
  6379. // }
  6380. //
  6381. // for _, subItem := range item.HisAdditionalCharge {
  6382. // total = total + (subItem.Price * float64(subItem.Count))
  6383. // }
  6384. // }
  6385. //
  6386. // allTotal := fmt.Sprintf("%.2f", total)
  6387. // totals, _ := strconv.ParseFloat(allTotal, 64)
  6388. // order := &models.HisOrder{
  6389. // UserOrgId: adminUser.CurrentOrgId,
  6390. // HisPatientId: his.ID,
  6391. // PatientId: id,
  6392. // SettleAccountsDate: recordDateTime,
  6393. // Ctime: time.Now().Unix(),
  6394. // Mtime: time.Now().Unix(),
  6395. // Status: 1,
  6396. // OrderStatus: 2,
  6397. // Number: chrg_bchno,
  6398. // MedfeeSumamt: totals,
  6399. // }
  6400. // err = service.CreateOrder(order)
  6401. // if err != nil {
  6402. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6403. // return
  6404. // }
  6405. //
  6406. // var customs []*Custom
  6407. // for _, item := range prescriptions {
  6408. //
  6409. // if item.Type == 1 { //药品
  6410. // for _, subItem := range item.HisDoctorAdviceInfo {
  6411. // cus := &Custom{
  6412. // AdviceId: subItem.ID,
  6413. // ProjectId: 0,
  6414. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  6415. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  6416. // FeedetlSn: subItem.FeedetlSn,
  6417. // Price: fmt.Sprintf("%.2f", subItem.Price),
  6418. // MedListCodg: subItem.MedListCodg,
  6419. // Type: 1,
  6420. // }
  6421. // customs = append(customs, cus)
  6422. // }
  6423. // }
  6424. //
  6425. // if item.Type == 2 { //项目
  6426. // for _, subItem := range item.HisPrescriptionProject {
  6427. //
  6428. // cus := &Custom{
  6429. // AdviceId: 0,
  6430. // ProjectId: subItem.ID,
  6431. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  6432. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  6433. // FeedetlSn: subItem.FeedetlSn,
  6434. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  6435. // MedListCodg: subItem.MedListCodg,
  6436. // Type: 2,
  6437. // }
  6438. //
  6439. // customs = append(customs, cus)
  6440. // }
  6441. // }
  6442. //
  6443. // for _, item := range item.HisAdditionalCharge {
  6444. // cus := &Custom{
  6445. // ItemId: item.ID,
  6446. // AdviceId: 0,
  6447. // ProjectId: 0,
  6448. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  6449. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  6450. // FeedetlSn: item.FeedetlSn,
  6451. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  6452. // MedListCodg: item.XtHisAddtionConfig.Code,
  6453. // Type: 3,
  6454. // }
  6455. //
  6456. // customs = append(customs, cus)
  6457. // }
  6458. //
  6459. // }
  6460. //
  6461. // for _, item := range customs {
  6462. // var advice_id int64 = 0
  6463. // var project_id int64 = 0
  6464. // var item_id int64 = 0
  6465. //
  6466. // var types int64 = 0
  6467. //
  6468. // if item.Type == 1 {
  6469. // advice_id = item.AdviceId
  6470. // project_id = 0
  6471. // item_id = 0
  6472. // } else if item.Type == 2 {
  6473. // advice_id = 0
  6474. // item_id = 0
  6475. //
  6476. // project_id = item.ProjectId
  6477. // } else if item.Type == 3 {
  6478. // advice_id = 0
  6479. // item_id = item.ItemId
  6480. // project_id = 0
  6481. // }
  6482. //
  6483. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  6484. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  6485. // pric, _ := strconv.ParseFloat(item.Price, 32)
  6486. //
  6487. // info := &models.HisOrderInfo{
  6488. // OrderNumber: order.Number,
  6489. // UploadDate: time.Now().Unix(),
  6490. // AdviceId: advice_id,
  6491. // DetItemFeeSumamt: detItemFeeSumamt,
  6492. // Cnt: cut,
  6493. // Pric: pric,
  6494. // PatientId: id,
  6495. // Status: 1,
  6496. // Mtime: time.Now().Unix(),
  6497. // Ctime: time.Now().Unix(),
  6498. // UserOrgId: adminUser.CurrentOrgId,
  6499. // HisPatientId: his.ID,
  6500. // OrderId: order.ID,
  6501. // ProjectId: project_id,
  6502. // Type: types,
  6503. // ItemId: item_id,
  6504. // }
  6505. // service.CreateOrderInfo(info)
  6506. // }
  6507. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6508. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  6509. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  6510. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  6511. // if err == nil {
  6512. // c.ServeSuccessJSON(map[string]interface{}{
  6513. // "msg": "结算成功",
  6514. // })
  6515. // } else {
  6516. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  6517. // return
  6518. // }
  6519. // }
  6520. //}
  6521. //上传明细-预结算-
  6522. func (c *HisApiController) GetPreUploadInfo() {
  6523. id, _ := c.GetInt64("id")
  6524. record_time := c.GetString("record_time")
  6525. his_patient_id, _ := c.GetInt64("his_patient_id")
  6526. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  6527. admin_user_id, _ := c.GetInt64("admin_user_id")
  6528. diagnosis_id := c.GetString("diagnosis")
  6529. sick_type, _ := c.GetInt64("sick_type")
  6530. reg_type, _ := c.GetInt64("p_type")
  6531. begin_time := c.GetString("begin_time")
  6532. id_str := c.GetString("ids")
  6533. ids_arr := strings.Split(id_str, ",")
  6534. timeLayout := "2006-01-02"
  6535. loc, _ := time.LoadLocation("Local")
  6536. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  6537. if err != nil {
  6538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6539. return
  6540. }
  6541. recordDateTime := theTime.Unix()
  6542. adminUser := c.GetAdminUserInfo()
  6543. diagnosis_ids := strings.Split(diagnosis_id, ",")
  6544. var config []*models.HisXtDiagnoseConfig
  6545. for _, item := range diagnosis_ids {
  6546. id, _ := strconv.ParseInt(item, 10, 64)
  6547. diagnosisConfig, _ := service.FindDiagnoseById(id)
  6548. config = append(config, &diagnosisConfig)
  6549. }
  6550. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  6551. sickConfig, _ := service.FindSickById(sick_type)
  6552. var prescriptions []*models.HisPrescription
  6553. var start_time int64
  6554. var end_time int64
  6555. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  6556. fmt.Println(his_patient_id)
  6557. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6558. timestamp := time.Now().Unix()
  6559. tempTime := time.Unix(timestamp, 0)
  6560. timeFormat := tempTime.Format("20060102150405")
  6561. chrgBchno := rand.Intn(100000) + 10000
  6562. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  6563. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6564. var patientPrescription models.HisPrescriptionInfo
  6565. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  6566. if patientPrescription.ID == 0 {
  6567. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  6568. }
  6569. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  6570. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  6571. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  6572. strconv.FormatInt(his.PatientId, 10)
  6573. var res2 ResultSix
  6574. var resSix10265 ResultSix10265
  6575. var time_stamp string
  6576. if miConfig.MdtrtareaAdmvs == "421300" {
  6577. data := make(map[string]interface{})
  6578. client := &http.Client{}
  6579. data["psn_no"] = his.PsnNo
  6580. data["mdtrt_id"] = his.Number
  6581. data["doctor"] = roles.UserName
  6582. data["department"] = department.Name
  6583. data["org_name"] = miConfig.OrgName
  6584. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6585. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6586. data["fixmedins_code"] = miConfig.Code
  6587. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  6588. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6589. data["secret_key"] = miConfig.SecretKey
  6590. data["sick_code"] = sickConfig.CountryCode
  6591. data["sick_name"] = sickConfig.ClassName
  6592. data["begin_time"] = begin_time
  6593. data["dept"] = strconv.FormatInt(department.ID, 10)
  6594. data["config"] = config
  6595. fmt.Println(data)
  6596. bytesData, _ := json.Marshal(data)
  6597. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2203", bytes.NewReader(bytesData))
  6598. resp, _ := client.Do(req)
  6599. defer resp.Body.Close()
  6600. body, ioErr := ioutil.ReadAll(resp.Body)
  6601. if ioErr != nil {
  6602. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6604. return
  6605. }
  6606. var respJSON map[string]interface{}
  6607. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6608. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6609. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6610. return
  6611. }
  6612. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6613. userJSONBytes, _ := json.Marshal(respJSON)
  6614. fmt.Println("log")
  6615. fmt.Println(string(userJSONBytes))
  6616. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  6617. utils.ErrorLog("解析失败:%v", err)
  6618. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6619. return
  6620. }
  6621. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6622. //江苏地区国家医保医疗类别
  6623. //职工透析:医疗类别选特殊情况门诊9933
  6624. //居民血透门慢: 医疗类别选门诊慢病1402
  6625. //var med_type string
  6626. //if his.Insutype == "310" {
  6627. // if reg_type == 14 {
  6628. // med_type = "9933"
  6629. // } else if reg_type == 11 {
  6630. // med_type = "11"
  6631. //
  6632. // }
  6633. //} else if his.Insutype == "390" {
  6634. // if reg_type == 14 {
  6635. // med_type = "1402"
  6636. // } else if reg_type == 11 {
  6637. // med_type = "11"
  6638. // }
  6639. //}
  6640. data := make(map[string]interface{})
  6641. client := &http.Client{}
  6642. data["psn_no"] = his.PsnNo
  6643. data["mdtrt_id"] = his.Number
  6644. data["doctor"] = roles.UserName
  6645. data["department"] = department.Name
  6646. data["org_name"] = miConfig.OrgName
  6647. data["med_type"] = strconv.FormatInt(reg_type, 10)
  6648. data["doctor_id"] = strconv.FormatInt(doctor_info.AdminUserId, 10)
  6649. data["fixmedins_code"] = miConfig.Code
  6650. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6651. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6652. data["secret_key"] = miConfig.SecretKey
  6653. data["sick_code"] = sickConfig.CountryCode
  6654. data["sick_name"] = sickConfig.ClassName
  6655. data["begin_time"] = begin_time
  6656. data["dept"] = strconv.FormatInt(department.ID, 10)
  6657. data["config"] = config
  6658. data["url"] = miConfig.Url
  6659. data["ak"] = miConfig.AccessKey
  6660. data["cainfo"] = miConfig.Cainfo
  6661. bytesData, _ := json.Marshal(data)
  6662. var req *http.Request
  6663. if miConfig.MdtrtareaAdmvs == "320921" {
  6664. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6665. //api = "http://192.168.3.111:9532/" + "jsyb/readcard?" + "fixmedins_code=" + miConfig.Code + "&secret_key=" + miConfig.SecretKey + "&ak=" + miConfig.AccessKey + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName +
  6666. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&cainfo=" + miConfig.Cainfo
  6667. } else {
  6668. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2203", bytes.NewReader(bytesData))
  6669. }
  6670. resp, _ := client.Do(req)
  6671. defer resp.Body.Close()
  6672. body, ioErr := ioutil.ReadAll(resp.Body)
  6673. if ioErr != nil {
  6674. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6675. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6676. return
  6677. }
  6678. var respJSON map[string]interface{}
  6679. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6680. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6682. return
  6683. }
  6684. time_stamp = strconv.FormatInt(int64(respJSON["data"].(map[string]interface{})["time_stamp"].(float64)), 10)
  6685. //fmt.Println(respJSON["data"].(map[string]interface{})["time_stamp"].(string))
  6686. //time_stamp = respJSON["data"].(map[string]interface{})["time_stamp"].(string)
  6687. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6688. userJSONBytes, _ := json.Marshal(respJSON)
  6689. fmt.Println("log")
  6690. fmt.Println(string(userJSONBytes))
  6691. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  6692. utils.ErrorLog("解析失败:%v", err)
  6693. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6694. return
  6695. }
  6696. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6697. res2.Output = resSix10265.Output
  6698. res2.ErrMsg = resSix10265.ErrMsg
  6699. res2.Cainfo = resSix10265.Cainfo
  6700. res2.WarnMsg = resSix10265.WarnMsg
  6701. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6702. res2.Infcode = infocode
  6703. } else {
  6704. var result string
  6705. var requestLog string
  6706. if miConfig.MdtrtareaAdmvs == "440781" { //
  6707. 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)
  6708. } else {
  6709. if miConfig.Code == "H15049901371" {
  6710. //赤峰地区国家医保医疗类别
  6711. //职工透析:医疗类别选特殊情况门诊990502
  6712. //居民定额血透门慢: 医疗类别选门诊慢病140104
  6713. var med_type string
  6714. if his.Insutype == "390" {
  6715. if reg_type == 14 {
  6716. med_type = "9933"
  6717. } else if reg_type == 11 {
  6718. med_type = "11"
  6719. }
  6720. } else if his.Insutype == "310" {
  6721. if reg_type == 14 {
  6722. med_type = "990502"
  6723. } else if reg_type == 11 {
  6724. med_type = "11"
  6725. }
  6726. }
  6727. 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)
  6728. } else {
  6729. 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)
  6730. }
  6731. saveLog(result, requestLog, "2203", "上传就诊信息")
  6732. var respJSON2 map[string]interface{}
  6733. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  6734. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6735. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6736. return
  6737. }
  6738. userJSONBytes2, _ := json.Marshal(respJSON2)
  6739. if miConfig.Code == "H15049901371" {
  6740. if err := json.Unmarshal(userJSONBytes2, &resSix10265); err != nil {
  6741. utils.ErrorLog("解析失败:%v", err)
  6742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6743. return
  6744. }
  6745. res2.InfRefmsgid = resSix10265.InfRefmsgid
  6746. res2.Output = resSix10265.Output
  6747. res2.ErrMsg = resSix10265.ErrMsg
  6748. res2.Cainfo = resSix10265.Cainfo
  6749. res2.WarnMsg = resSix10265.WarnMsg
  6750. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  6751. res2.Infcode = infocode
  6752. } else {
  6753. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  6754. utils.ErrorLog("解析失败:%v", err)
  6755. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6756. return
  6757. }
  6758. }
  6759. }
  6760. }
  6761. if res2.Infcode != 0 {
  6762. adminUser := c.GetAdminUserInfo()
  6763. errlog := &models.HisOrderError{
  6764. UserOrgId: adminUser.CurrentOrgId,
  6765. Ctime: time.Now().Unix(),
  6766. Mtime: time.Now().Unix(),
  6767. ErrMsg: res2.ErrMsg,
  6768. Status: 1,
  6769. PatientId: id,
  6770. RecordTime: recordDateTime,
  6771. Stage: 3,
  6772. }
  6773. service.CreateErrMsgLog(errlog)
  6774. c.ServeSuccessJSON(map[string]interface{}{
  6775. "failed_code": -10,
  6776. "msg": res2.ErrMsg,
  6777. })
  6778. return
  6779. } else {
  6780. his.Diagnosis = diagnosis_id
  6781. his.SickType = sickConfig.ID
  6782. his.PType = fmt.Sprintf("%d", reg_type)
  6783. service.UpdateHisPatientThree(&his)
  6784. data := make(map[string]interface{})
  6785. if settle_accounts_type == 1 { //日结
  6786. if reg_type == 11 || reg_type == 1111 || reg_type == 1112 {
  6787. prescriptions, _ = service.GetPrescriptionByIds(ids_arr, adminUser.CurrentOrgId)
  6788. } else {
  6789. prescriptions, _ = service.GetNewHisPrescription(adminUser.CurrentOrgId, his_patient_id, recordDateTime, strconv.Itoa(int(reg_type)))
  6790. }
  6791. data["pre"] = prescriptions
  6792. } else { //月结
  6793. start_time_str := c.GetString("start_time")
  6794. end_time_str := c.GetString("end_time")
  6795. timeLayout := "2006-01-02"
  6796. loc, _ := time.LoadLocation("Local")
  6797. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  6798. if err != nil {
  6799. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6800. return
  6801. }
  6802. recordStartTime := theStartTime.Unix()
  6803. start_time = recordStartTime
  6804. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  6805. if err != nil {
  6806. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  6807. return
  6808. }
  6809. recordEndTime := theEndTime.Unix()
  6810. end_time = recordEndTime
  6811. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  6812. data["pre"] = prescriptions
  6813. }
  6814. client := &http.Client{}
  6815. data["psn_no"] = his.PsnNo
  6816. data["mdtrt_id"] = his.Number
  6817. data["chrg_bchno"] = chrg_bchno
  6818. data["org_name"] = miConfig.OrgName
  6819. data["doctor"] = roles.UserName
  6820. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  6821. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  6822. data["fixmedins_code"] = miConfig.Code
  6823. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  6824. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  6825. data["dept_code"] = "15"
  6826. } else {
  6827. data["dept_code"] = department.Number
  6828. }
  6829. data["insuplc_admdvs"] = his.InsuplcAdmdvs
  6830. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  6831. data["secret_key"] = miConfig.SecretKey
  6832. data["url"] = miConfig.Url
  6833. data["ak"] = miConfig.AccessKey
  6834. data["new_doctor_name"] = patientPrescription.Doctor
  6835. data["diag_code"] = sickConfig.CountryCode
  6836. data["time_stamp"] = time_stamp
  6837. data["cainfo"] = miConfig.Cainfo
  6838. var ids []int64
  6839. for _, item := range prescriptions {
  6840. ids = append(ids, item.ID)
  6841. }
  6842. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  6843. if config.IsOpen == 1 { //对接了医保,走医保流程
  6844. var res ResultFour
  6845. var resFour10265 ResultFour10265
  6846. if miConfig.MdtrtareaAdmvs == "421300" {
  6847. bytesData, _ := json.Marshal(data)
  6848. req, _ := http.NewRequest("POST", "http://192.168.124.4:9532/"+"hbyb/2204", bytes.NewReader(bytesData))
  6849. resp, _ := client.Do(req)
  6850. defer resp.Body.Close()
  6851. body, ioErr := ioutil.ReadAll(resp.Body)
  6852. if ioErr != nil {
  6853. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6854. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6855. return
  6856. }
  6857. var respJSON map[string]interface{}
  6858. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6859. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6860. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6861. return
  6862. }
  6863. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6864. userJSONBytes, _ := json.Marshal(respJSON)
  6865. fmt.Println("log")
  6866. fmt.Println(string(userJSONBytes))
  6867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6868. utils.ErrorLog("解析失败:%v", err)
  6869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6870. return
  6871. }
  6872. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  6873. bytesData, _ := json.Marshal(data)
  6874. var req *http.Request
  6875. if miConfig.MdtrtareaAdmvs == "320921" {
  6876. req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6877. } else {
  6878. req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  6879. }
  6880. resp, _ := client.Do(req)
  6881. defer resp.Body.Close()
  6882. body, ioErr := ioutil.ReadAll(resp.Body)
  6883. if ioErr != nil {
  6884. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  6885. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6886. return
  6887. }
  6888. var respJSON map[string]interface{}
  6889. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  6890. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  6891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6892. return
  6893. }
  6894. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  6895. userJSONBytes, _ := json.Marshal(respJSON)
  6896. fmt.Println("log")
  6897. fmt.Println(string(userJSONBytes))
  6898. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6899. utils.ErrorLog("解析失败:%v", err)
  6900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6901. return
  6902. }
  6903. res.InfRefmsgid = resFour10265.InfRefmsgid
  6904. res.Output = resFour10265.Output
  6905. res.ErrMsg = resFour10265.ErrMsg
  6906. res.Cainfo = resFour10265.Cainfo
  6907. res.WarnMsg = resFour10265.WarnMsg
  6908. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6909. res.Infcode = infocode
  6910. } else {
  6911. if miConfig.Code == "H15049901371" {
  6912. 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)
  6913. var dat map[string]interface{}
  6914. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6915. fmt.Println(dat)
  6916. } else {
  6917. fmt.Println(err)
  6918. }
  6919. saveLog(result, request_log, "2204", "上传费用明细")
  6920. userJSONBytes, _ := json.Marshal(dat)
  6921. if err := json.Unmarshal(userJSONBytes, &resFour10265); err != nil {
  6922. utils.ErrorLog("解析失败:%v", err)
  6923. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6924. return
  6925. }
  6926. res.InfRefmsgid = resFour10265.InfRefmsgid
  6927. res.Output = resFour10265.Output
  6928. res.ErrMsg = resFour10265.ErrMsg
  6929. res.Cainfo = resFour10265.Cainfo
  6930. res.WarnMsg = resFour10265.WarnMsg
  6931. infocode, _ := strconv.ParseInt(resFour10265.Infcode, 10, 64)
  6932. res.Infcode = infocode
  6933. } else {
  6934. 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)
  6935. var dat map[string]interface{}
  6936. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  6937. fmt.Println(dat)
  6938. } else {
  6939. fmt.Println(err)
  6940. }
  6941. saveLog(result, request_log, "2204", "上传费用明细")
  6942. userJSONBytes, _ := json.Marshal(dat)
  6943. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  6944. utils.ErrorLog("解析失败:%v", err)
  6945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  6946. return
  6947. }
  6948. }
  6949. }
  6950. if res.Infcode == 0 {
  6951. order := &models.HisOrder{
  6952. UserOrgId: adminUser.CurrentOrgId,
  6953. HisPatientId: his.ID,
  6954. PatientId: his.PatientId,
  6955. SettleAccountsDate: recordDateTime,
  6956. Ctime: time.Now().Unix(),
  6957. Mtime: time.Now().Unix(),
  6958. MdtrtId: his.Number,
  6959. PsnNo: his.PsnNo,
  6960. MedType: strconv.FormatInt(reg_type, 10),
  6961. Status: 1,
  6962. Number: chrg_bchno,
  6963. Infcode: res.Infcode,
  6964. WarnMsg: res.WarnMsg,
  6965. Cainfo: res.Cainfo,
  6966. ErrMsg: res.ErrMsg,
  6967. RespondTime: res.RefmsgTime,
  6968. InfRefmsgid: res.InfRefmsgid,
  6969. OrderStatus: 1,
  6970. IsMedicineInsurance: 1,
  6971. SettleType: settle_accounts_type,
  6972. SettleStartTime: start_time,
  6973. SettleEndTime: end_time,
  6974. Creator: roles.AdminUserId,
  6975. Modify: roles.AdminUserId,
  6976. PType: 2,
  6977. Diagnosis: diagnosis_id,
  6978. }
  6979. err = service.CreateOrder(order)
  6980. if err != nil {
  6981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  6982. return
  6983. }
  6984. for _, item := range res.Output.Result {
  6985. temp := strings.Split(item.FeedetlSn, "-")
  6986. var advice_id int64 = 0
  6987. var project_id int64 = 0
  6988. var types int64 = 0
  6989. id, _ := strconv.ParseInt(temp[2], 10, 64)
  6990. types, _ = strconv.ParseInt(temp[1], 10, 64)
  6991. if temp[1] == "1" {
  6992. advice_id = id
  6993. project_id = 0
  6994. } else if temp[1] == "2" {
  6995. advice_id = 0
  6996. project_id = id
  6997. }
  6998. info := &models.HisOrderInfo{
  6999. OrderNumber: order.Number,
  7000. FeedetlSn: item.FeedetlSn,
  7001. UploadDate: time.Now().Unix(),
  7002. AdviceId: advice_id,
  7003. DetItemFeeSumamt: item.DetItemFeeSumamt,
  7004. Cnt: item.Cnt,
  7005. Pric: float64(item.Pric),
  7006. PatientId: his.PatientId,
  7007. PricUplmtAmt: item.PricUplmtAmt,
  7008. SelfpayProp: item.SelfpayProp,
  7009. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  7010. OverlmtAmt: item.OverlmtAmt,
  7011. PreselfpayAmt: item.PreselfpayAmt,
  7012. BasMednFlag: item.BasMednFlag,
  7013. MedChrgitmType: item.MedChrgitmType,
  7014. HiNegoDrugFlag: item.HiNegoDrugFlag,
  7015. Status: 1,
  7016. Memo: item.Memo,
  7017. Mtime: time.Now().Unix(),
  7018. InscpScpAmt: item.InscpScpAmt,
  7019. DrtReimFlag: item.DrtReimFlag,
  7020. Ctime: time.Now().Unix(),
  7021. ListSpItemFlag: item.ListSpItemFlag,
  7022. ChldMedcFlag: item.ChldMedcFlag,
  7023. LmtUsedFlag: item.LmtUsedFlag,
  7024. ChrgitmLv: item.ChrgitmLv,
  7025. UserOrgId: adminUser.CurrentOrgId,
  7026. HisPatientId: his.ID,
  7027. OrderId: order.ID,
  7028. ProjectId: project_id,
  7029. Type: types,
  7030. }
  7031. service.CreateOrderInfo(info)
  7032. }
  7033. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  7034. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  7035. var total float64
  7036. for _, item := range prescriptions {
  7037. if item.Type == 1 { //药品
  7038. for _, subItem := range item.HisDoctorAdviceInfo {
  7039. total = total + (subItem.Price * subItem.PrescribingNumber)
  7040. }
  7041. }
  7042. if item.Type == 2 { //项目
  7043. for _, subItem := range item.HisPrescriptionProject {
  7044. cnt, _ := strconv.ParseFloat(subItem.Count, 64)
  7045. total = total + (subItem.Price * cnt)
  7046. }
  7047. }
  7048. }
  7049. for _, item := range prescriptions {
  7050. for _, subItem := range item.HisAdditionalCharge {
  7051. total = total + (subItem.Price * float64(subItem.Count))
  7052. }
  7053. }
  7054. allTotal := fmt.Sprintf("%.4f", total)
  7055. if res.Infcode == 0 {
  7056. var rf []*ResultFive
  7057. json.Unmarshal([]byte(his.Iinfo), &rf)
  7058. chrg_bchno := chrg_bchno
  7059. cert_no := his.Certno
  7060. var insutypes []string
  7061. var insutype string
  7062. var is390 int = 0
  7063. var is310 int = 0
  7064. for _, item := range rf {
  7065. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  7066. insutypes = append(insutypes, item.Insutype)
  7067. }
  7068. }
  7069. if len(insutypes) == 1 {
  7070. insutype = insutypes[0]
  7071. } else {
  7072. for _, i := range insutypes {
  7073. if i == "390" {
  7074. is390 = 1
  7075. }
  7076. if i == "310" {
  7077. is310 = 1
  7078. }
  7079. }
  7080. }
  7081. if is390 == 1 {
  7082. insutype = "390"
  7083. }
  7084. if is310 == 1 {
  7085. insutype = "310"
  7086. }
  7087. if len(insutypes) == 0 {
  7088. insutype = "310"
  7089. }
  7090. if len(insutypes) == 2 {
  7091. insutype = strconv.FormatInt(his.SocialType, 64)
  7092. }
  7093. //insutype = "390"
  7094. if his.IdCardType == 1 {
  7095. cert_no = his.MedicalInsuranceNumber
  7096. } else {
  7097. cert_no = his.Certno
  7098. }
  7099. var res ResultSeven
  7100. var resSeven10265 ResultSeven10265
  7101. if miConfig.MdtrtareaAdmvs == "421300" {
  7102. api := "http://192.168.124.4:9532/" + "hbyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7103. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7104. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7105. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7106. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7107. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7108. "&insutype=" + insutype + "&total=" + allTotal + "&med_type=" + strconv.FormatInt(reg_type, 10)
  7109. resp, requestErr := http.Get(api)
  7110. if requestErr != nil {
  7111. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7112. return
  7113. }
  7114. body, ioErr := ioutil.ReadAll(resp.Body)
  7115. if ioErr != nil {
  7116. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7118. return
  7119. }
  7120. var respJSON map[string]interface{}
  7121. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7122. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7123. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7124. return
  7125. }
  7126. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7127. result, _ := json.Marshal(respJSON)
  7128. fmt.Println("log")
  7129. fmt.Println(string(result))
  7130. if err := json.Unmarshal([]byte(result), &res); err != nil {
  7131. utils.ErrorLog("解析失败:%v", err)
  7132. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7133. return
  7134. }
  7135. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7136. psn_info, _ := service.GetPsnByPatientId(his.PatientId)
  7137. psn_info.VerifyNumber = strings.Replace(psn_info.VerifyNumber, "+", "%2B", -1)
  7138. bas := strings.Split(psn_info.CardInfo, "|")
  7139. if his.IdCardType == 1 {
  7140. cert_no = bas[2]
  7141. } else {
  7142. cert_no = bas[1]
  7143. }
  7144. //江苏地区国家医保医疗类别
  7145. //职工透析:医疗类别选特殊情况门诊9933
  7146. //居民血透门慢: 医疗类别选门诊慢病1402
  7147. //var med_type string
  7148. //if his.Insutype == "310" {
  7149. // if reg_type == 14 {
  7150. // med_type = "9933"
  7151. // } else if reg_type == 11 {
  7152. // med_type = "11"
  7153. //
  7154. // }
  7155. //} else if his.Insutype == "390" {
  7156. // if reg_type == 14 {
  7157. // med_type = "1402"
  7158. // } else if reg_type == 11 {
  7159. // med_type = "11"
  7160. // }
  7161. //}
  7162. var api string
  7163. if miConfig.MdtrtareaAdmvs == "320921" {
  7164. api = "http://192.168.3.111:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7165. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7166. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7167. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7168. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7169. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7170. "&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
  7171. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7172. } else {
  7173. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7174. api = "http://192.168.5.251:9532/" + "jsyb/2206?psn_no=" + his.PsnNo + "&mdtrt_id=" +
  7175. his.Number + "&chrg_bchno=" + chrg_bchno + "&org_name=" + miConfig.OrgName +
  7176. "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  7177. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  7178. "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(his.IdCardType, 10) +
  7179. "&certificates=" + strconv.FormatInt(his.IdType, 10) + "&cert_no=" + cert_no +
  7180. "&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
  7181. }
  7182. resp, requestErr := http.Get(api)
  7183. if requestErr != nil {
  7184. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7185. return
  7186. }
  7187. body, ioErr := ioutil.ReadAll(resp.Body)
  7188. if ioErr != nil {
  7189. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  7190. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7191. return
  7192. }
  7193. var respJSON map[string]interface{}
  7194. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  7195. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7196. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7197. return
  7198. }
  7199. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7200. result, _ := json.Marshal(respJSON)
  7201. fmt.Println("log")
  7202. fmt.Println(string(result))
  7203. if err := json.Unmarshal([]byte(result), &resSeven10265); err != nil {
  7204. utils.ErrorLog("解析失败:%v", err)
  7205. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7206. return
  7207. }
  7208. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7209. res.Output = resSeven10265.Output
  7210. res.ErrMsg = resSeven10265.ErrMsg
  7211. res.Cainfo = resSeven10265.Cainfo
  7212. res.WarnMsg = resSeven10265.WarnMsg
  7213. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7214. res.Infcode = infocode
  7215. } else {
  7216. var result string
  7217. var request_log string
  7218. if miConfig.Code == "H15049901371" {
  7219. //赤峰地区国家医保医疗类别
  7220. //职工透析:医疗类别选特殊情况门诊990502
  7221. //居民定额血透门慢: 医疗类别选门诊慢病140104
  7222. var med_type string
  7223. if his.Insutype == "390" {
  7224. if reg_type == 14 {
  7225. med_type = "9933"
  7226. } else if reg_type == 11 {
  7227. med_type = "11"
  7228. }
  7229. } else if his.Insutype == "310" {
  7230. if reg_type == 14 {
  7231. med_type = "990502"
  7232. } else if reg_type == 11 {
  7233. med_type = "11"
  7234. }
  7235. }
  7236. 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)
  7237. } else {
  7238. 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)
  7239. }
  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, "2206", "预结算")
  7247. //userJSONBytes, _ := json.Marshal(dat)
  7248. //
  7249. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7250. // utils.ErrorLog("解析失败:%v", err)
  7251. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7252. // return
  7253. //}
  7254. userJSONBytes, _ := json.Marshal(dat)
  7255. if miConfig.Code == "H15049901371" {
  7256. if err := json.Unmarshal(userJSONBytes, &resSeven10265); err != nil {
  7257. utils.ErrorLog("解析失败:%v", err)
  7258. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7259. return
  7260. }
  7261. res.InfRefmsgid = resSeven10265.InfRefmsgid
  7262. res.Output = resSeven10265.Output
  7263. res.ErrMsg = resSeven10265.ErrMsg
  7264. res.Cainfo = resSeven10265.Cainfo
  7265. res.WarnMsg = resSeven10265.WarnMsg
  7266. infocode, _ := strconv.ParseInt(resSeven10265.Infcode, 10, 64)
  7267. res.Infcode = infocode
  7268. } else {
  7269. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7270. utils.ErrorLog("解析失败:%v", err)
  7271. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7272. return
  7273. }
  7274. }
  7275. }
  7276. if res.Infcode != 0 {
  7277. errlog := &models.HisOrderError{
  7278. UserOrgId: adminUser.CurrentOrgId,
  7279. Ctime: time.Now().Unix(),
  7280. Mtime: time.Now().Unix(),
  7281. Number: chrg_bchno,
  7282. ErrMsg: res.ErrMsg,
  7283. Status: 1,
  7284. PatientId: id,
  7285. RecordTime: recordDateTime,
  7286. Stage: 20,
  7287. }
  7288. service.CreateErrMsgLog(errlog)
  7289. c.ServeSuccessJSON(map[string]interface{}{
  7290. "failed_code": -10,
  7291. "msg": res.ErrMsg,
  7292. })
  7293. return
  7294. } else {
  7295. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  7296. order.OrderStatus = 1
  7297. order.IsPre = 1
  7298. order.Status = 1
  7299. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  7300. order.SetlId = res.Output.Setlinfo.SetlID
  7301. order.PsnNo = res.Output.Setlinfo.PsnNo
  7302. order.PsnName = res.Output.Setlinfo.PsnName
  7303. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  7304. order.Certno = res.Output.Setlinfo.Certno
  7305. order.Gend = res.Output.Setlinfo.Gend
  7306. order.Naty = res.Output.Setlinfo.Naty
  7307. order.Age = res.Output.Setlinfo.Age
  7308. order.Insutype = res.Output.Setlinfo.Insutype
  7309. order.PsnType = res.Output.Setlinfo.PsnType
  7310. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7311. order.SetlTime = res.Output.Setlinfo.SetlTime
  7312. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7313. if res.Output.Setlinfo.MedType == "140101" {
  7314. order.MedType = "14"
  7315. } else {
  7316. order.MedType = res.Output.Setlinfo.MedType
  7317. }
  7318. if reg_type == 1112 {
  7319. order.MedType = "1112"
  7320. }
  7321. if reg_type == 1111 {
  7322. order.MedType = "1111"
  7323. }
  7324. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7325. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7326. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7327. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7328. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7329. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7330. order.HifpPay = res.Output.Setlinfo.HifpPay
  7331. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  7332. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7333. order.HifesPay = res.Output.Setlinfo.HifesPay
  7334. order.HifobPay = res.Output.Setlinfo.HifobPay
  7335. order.MafPay = res.Output.Setlinfo.MafPay
  7336. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  7337. order.OthPay = res.Output.Setlinfo.OthPay
  7338. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7339. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7340. order.AcctPay = res.Output.Setlinfo.AcctPay
  7341. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7342. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7343. order.Balc = res.Output.Setlinfo.Balc
  7344. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7345. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7346. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  7347. order.ClrWay = res.Output.Setlinfo.ClrWay
  7348. order.Creator = order.Creator
  7349. order.Modify = roles.AdminUserId
  7350. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7351. detailStr := string(setlDetail)
  7352. order.SetlDetail = detailStr
  7353. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7354. err = service.UpDateOrder(order)
  7355. if err == nil {
  7356. c.ServeSuccessJSON(map[string]interface{}{
  7357. "msg": "预结算成功",
  7358. })
  7359. } else {
  7360. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7361. return
  7362. }
  7363. }
  7364. } else {
  7365. adminUser := c.GetAdminUserInfo()
  7366. errlog := &models.HisOrderError{
  7367. UserOrgId: adminUser.CurrentOrgId,
  7368. Ctime: time.Now().Unix(),
  7369. Mtime: time.Now().Unix(),
  7370. ErrMsg: res.ErrMsg,
  7371. Status: 1,
  7372. PatientId: id,
  7373. RecordTime: recordDateTime,
  7374. Stage: 4,
  7375. }
  7376. service.CreateErrMsgLog(errlog)
  7377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7378. return
  7379. }
  7380. } else {
  7381. adminUser := c.GetAdminUserInfo()
  7382. errlog := &models.HisOrderError{
  7383. UserOrgId: adminUser.CurrentOrgId,
  7384. Ctime: time.Now().Unix(),
  7385. Mtime: time.Now().Unix(),
  7386. ErrMsg: res.ErrMsg,
  7387. Status: 1,
  7388. PatientId: id,
  7389. RecordTime: recordDateTime,
  7390. Stage: 4,
  7391. }
  7392. service.CreateErrMsgLog(errlog)
  7393. c.ServeSuccessJSON(map[string]interface{}{
  7394. "failed_code": -10,
  7395. "msg": res.ErrMsg,
  7396. })
  7397. return
  7398. }
  7399. }
  7400. }
  7401. }
  7402. //func (c *HisApiController) GetSettleInfo() {
  7403. // id, _ := c.GetInt64("id")
  7404. // order_id, _ := c.GetInt64("order_id")
  7405. //
  7406. // record_time := c.GetString("record_time")
  7407. // pay_way, _ := c.GetInt64("pay_way")
  7408. // pay_price, _ := c.GetFloat("pay_price")
  7409. // pay_card_no := c.GetString("pay_card_no")
  7410. // discount_price, _ := c.GetFloat("discount_price")
  7411. // preferential_price, _ := c.GetFloat("preferential_price")
  7412. // reality_price, _ := c.GetFloat("reality_price")
  7413. // found_price, _ := c.GetFloat("found_price")
  7414. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  7415. // private_price, _ := c.GetFloat("private_price")
  7416. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  7417. // admin_user_id, _ := c.GetInt64("admin_user_id")
  7418. //
  7419. // timeLayout := "2006-01-02"
  7420. // loc, _ := time.LoadLocation("Local")
  7421. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7422. // if err != nil {
  7423. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7424. // return
  7425. // }
  7426. // recordDateTime := theTime.Unix()
  7427. // adminUser := c.GetAdminUserInfo()
  7428. //
  7429. // var prescriptions []*models.HisPrescription
  7430. //
  7431. // data := make(map[string]interface{})
  7432. // if settle_accounts_type == 1 { //日结
  7433. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  7434. // data["pre"] = prescriptions
  7435. //
  7436. // } else { //月结
  7437. // start_time_str := c.GetString("start_time")
  7438. // end_time_str := c.GetString("end_time")
  7439. // timeLayout := "2006-01-02"
  7440. // loc, _ := time.LoadLocation("Local")
  7441. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  7442. // if err != nil {
  7443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7444. // return
  7445. // }
  7446. // recordStartTime := theStartTime.Unix()
  7447. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  7448. // if err != nil {
  7449. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7450. // return
  7451. // }
  7452. // recordEndTime := theEndTime.Unix()
  7453. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  7454. // data["pre"] = prescriptions
  7455. //
  7456. // }
  7457. //
  7458. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7459. //
  7460. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7461. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7462. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  7463. // strconv.FormatInt(his.PatientId, 10)
  7464. //
  7465. // order_src, _ := service.GetHisOrderByID(order_id)
  7466. //
  7467. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7468. // if config.IsOpen == 1 { //对接了医保,走医保流程
  7469. //
  7470. // var total float64
  7471. // for _, item := range prescriptions {
  7472. // if item.Type == 1 { //药品
  7473. // for _, subItem := range item.HisDoctorAdviceInfo {
  7474. // total = total + (subItem.Price * subItem.PrescribingNumber)
  7475. // }
  7476. // }
  7477. // if item.Type == 2 { //项目
  7478. // for _, subItem := range item.HisPrescriptionProject {
  7479. // total = total + (subItem.Price * float64(subItem.Count))
  7480. // }
  7481. // }
  7482. // }
  7483. //
  7484. // for _, item := range prescriptions {
  7485. // for _, subItem := range item.HisAdditionalCharge {
  7486. // total = total + (subItem.Price * float64(subItem.Count))
  7487. // }
  7488. // }
  7489. //
  7490. // allTotal := fmt.Sprintf("%.2f", total)
  7491. // var rf []*ResultFive
  7492. // json.Unmarshal([]byte(his.Iinfo), &rf)
  7493. // psn_no := order_src.PsnNo
  7494. // mdtrt_id := order_src.MdtrtId
  7495. // chrg_bchno := order_src.Number
  7496. // cert_no := order_src.Certno
  7497. // insutype := rf[0].Insutype
  7498. //
  7499. // if his.IdCardType == 1 {
  7500. // cert_no = his.MedicalInsuranceNumber
  7501. // } else {
  7502. // cert_no = his.Certno
  7503. // }
  7504. //
  7505. // result, src_resquest := service.Gdyb2207(his.PsnNo, his.Number, chrg_bchno, cert_no, insutype, strconv.FormatFloat(total, 'E', -1, 64) ,miConfig.OrgName,roles.UserName,miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, strconv.FormatInt(patientPrescription.RegisterType, 10),his.IdCardType, order_src.FulamtOwnpayAmt,order_src.OverlmtSelfPay,order_src.PreselfpayAmt,order_src.InscpScpAmt)
  7506. // var dat map[string]interface{}
  7507. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7508. // fmt.Println(dat)
  7509. // } else {
  7510. // fmt.Println(err)
  7511. // }
  7512. //
  7513. // userJSONBytes, _ := json.Marshal(dat)
  7514. //
  7515. //
  7516. //
  7517. // var res ResultSeven
  7518. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7519. // utils.ErrorLog("解析失败:%v", err)
  7520. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7521. // return
  7522. // }
  7523. // if res.Infcode == -1 {
  7524. // errlog := &models.HisOrderError{
  7525. // UserOrgId: adminUser.CurrentOrgId,
  7526. // Ctime: time.Now().Unix(),
  7527. // Mtime: time.Now().Unix(),
  7528. // Number: chrg_bchno,
  7529. // ErrMsg: res.ErrMsg,
  7530. // Status: 1,
  7531. // PatientId: id,
  7532. // RecordTime: recordDateTime,
  7533. // Stage: 6,
  7534. // }
  7535. // service.CreateErrMsgLog(errlog)
  7536. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  7537. // return
  7538. // } else {
  7539. // order_src.OrderStatus = 2
  7540. // order_src.PayWay = pay_way
  7541. // order_src.PayPrice = pay_price
  7542. // order_src.PayCardNo = pay_card_no
  7543. // order_src.DiscountPrice = discount_price
  7544. // order_src.PreferentialPrice = preferential_price
  7545. // order_src.RealityPrice = reality_price
  7546. // order_src.FoundPrice = found_price
  7547. // order_src.MedicalInsurancePrice = medical_insurance_price
  7548. // order_src.PrivatePrice = private_price
  7549. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  7550. // order_src.SetlId = res.Output.Setlinfo.SetlID
  7551. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  7552. // order_src.PsnName = res.Output.Setlinfo.PsnName
  7553. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  7554. // order_src.Certno = res.Output.Setlinfo.Certno
  7555. // order_src.Gend = res.Output.Setlinfo.Gend
  7556. // order_src.Naty = res.Output.Setlinfo.Naty
  7557. // order_src.Age = res.Output.Setlinfo.Age
  7558. // order_src.Insutype = res.Output.Setlinfo.Insutype
  7559. // order_src.PsnType = res.Output.Setlinfo.PsnType
  7560. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  7561. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  7562. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  7563. // order_src.MedType = res.Output.Setlinfo.MedType
  7564. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  7565. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  7566. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  7567. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  7568. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  7569. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  7570. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  7571. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  7572. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  7573. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  7574. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  7575. // order_src.MafPay = res.Output.Setlinfo.MafPay
  7576. // order_src.OthPay = res.Output.Setlinfo.OthPay
  7577. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  7578. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  7579. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  7580. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  7581. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  7582. // order_src.Balc = res.Output.Setlinfo.Balc
  7583. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  7584. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  7585. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  7586. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  7587. // order_src.Creator = order_src.Creator
  7588. // order_src.Modify = roles.ID
  7589. // order_src.RequestLog = src_resquest
  7590. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  7591. // detailStr := string(setlDetail)
  7592. // order_src.SetlDetail = detailStr
  7593. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  7594. // err = service.UpDateOrder(order_src)
  7595. //
  7596. // if err == nil {
  7597. // c.ServeSuccessJSON(map[string]interface{}{
  7598. // "msg": "结算成功",
  7599. // })
  7600. // } else {
  7601. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  7602. // return
  7603. // }
  7604. // }
  7605. // }
  7606. //}
  7607. //退款
  7608. func (c *HisApiController) Refund() {
  7609. order_id, _ := c.GetInt64("order_id")
  7610. admin_user_id, _ := c.GetInt64("admin_user_id")
  7611. adminUser := c.GetAdminUserInfo()
  7612. var order models.HisOrder
  7613. order, _ = service.GetHisOrderByID(order_id)
  7614. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7615. if order.ID == 0 {
  7616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7617. return
  7618. }
  7619. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  7620. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7621. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7622. if config.IsOpen == 1 { //对接了医保,走医保流程
  7623. var res ResultSixteen
  7624. var resSixteen10265 ResultSixteen10265
  7625. var src_resquest string
  7626. var result string
  7627. if miConfig.MdtrtareaAdmvs == "421300" {
  7628. api3 := "http://192.168.124.4:9532/" + "hbyb/2208?psn_no=" + order.PsnNo +
  7629. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7630. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7631. resp3, requestErr3 := http.Get(api3)
  7632. if requestErr3 != nil {
  7633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7634. return
  7635. }
  7636. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7637. if ioErr3 != nil {
  7638. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7639. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7640. return
  7641. }
  7642. var respJSON3 map[string]interface{}
  7643. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7644. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7645. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7646. return
  7647. }
  7648. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7649. userJSONBytes3, _ := json.Marshal(respJSON3)
  7650. fmt.Println("log")
  7651. fmt.Println(string(userJSONBytes3))
  7652. if err := json.Unmarshal(userJSONBytes3, &res); err != nil {
  7653. utils.ErrorLog("解析失败:%v", err)
  7654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7655. return
  7656. }
  7657. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7658. var api3 string
  7659. if miConfig.MdtrtareaAdmvs == "320921" {
  7660. api3 = "http://192.168.3.111:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7661. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7662. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7663. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7664. } else {
  7665. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7666. api3 = "http://192.168.5.251:9532/" + "jsyb/2208?psn_no=" + order.PsnNo +
  7667. "&mdtrt_id=" + order.MdtrtId + "&setl_id=" + order.SetlId + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7668. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7669. }
  7670. resp3, requestErr3 := http.Get(api3)
  7671. if requestErr3 != nil {
  7672. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7673. return
  7674. }
  7675. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7676. if ioErr3 != nil {
  7677. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7678. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7679. return
  7680. }
  7681. var respJSON3 map[string]interface{}
  7682. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7683. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7685. return
  7686. }
  7687. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7688. userJSONBytes3, _ := json.Marshal(respJSON3)
  7689. if err := json.Unmarshal(userJSONBytes3, &resSixteen10265); err != nil {
  7690. utils.ErrorLog("解析失败:%v", err)
  7691. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7692. return
  7693. }
  7694. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7695. res.Output = resSixteen10265.Output
  7696. res.ErrMsg = resSixteen10265.ErrMsg
  7697. res.Cainfo = resSixteen10265.Cainfo
  7698. res.WarnMsg = resSixteen10265.WarnMsg
  7699. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7700. res.Infcode = infocode
  7701. } else {
  7702. if miConfig.Code == "H15049901371" {
  7703. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7704. var dat map[string]interface{}
  7705. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7706. fmt.Println(dat)
  7707. } else {
  7708. fmt.Println(err)
  7709. }
  7710. saveLog(result, src_resquest, "2208", "退费")
  7711. userJSONBytes, _ := json.Marshal(dat)
  7712. if err := json.Unmarshal(userJSONBytes, &resSixteen10265); err != nil {
  7713. utils.ErrorLog("解析失败:%v", err)
  7714. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7715. return
  7716. }
  7717. res.InfRefmsgid = resSixteen10265.InfRefmsgid
  7718. res.Output = resSixteen10265.Output
  7719. res.ErrMsg = resSixteen10265.ErrMsg
  7720. res.Cainfo = resSixteen10265.Cainfo
  7721. res.WarnMsg = resSixteen10265.WarnMsg
  7722. infocode, _ := strconv.ParseInt(resSixteen10265.Infcode, 10, 64)
  7723. res.Infcode = infocode
  7724. } else {
  7725. result, src_resquest = service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  7726. var dat map[string]interface{}
  7727. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  7728. fmt.Println(dat)
  7729. } else {
  7730. fmt.Println(err)
  7731. }
  7732. saveLog(result, src_resquest, "2208", "退费")
  7733. userJSONBytes, _ := json.Marshal(dat)
  7734. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  7735. utils.ErrorLog("解析失败:%v", err)
  7736. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7737. return
  7738. }
  7739. }
  7740. }
  7741. if res.Infcode == 0 {
  7742. var res2 ResultSix
  7743. var resSix10265 ResultSix10265
  7744. if miConfig.MdtrtareaAdmvs == "421300" {
  7745. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  7746. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7747. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7748. resp3, requestErr3 := http.Get(api3)
  7749. if requestErr3 != nil {
  7750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7751. return
  7752. }
  7753. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7754. if ioErr3 != nil {
  7755. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7757. return
  7758. }
  7759. var respJSON3 map[string]interface{}
  7760. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7761. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7762. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7763. return
  7764. }
  7765. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7766. userJSONBytes3, _ := json.Marshal(respJSON3)
  7767. fmt.Println("log")
  7768. fmt.Println(string(userJSONBytes3))
  7769. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7770. utils.ErrorLog("解析失败:%v", err)
  7771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7772. return
  7773. }
  7774. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7775. var api3 string
  7776. if miConfig.MdtrtareaAdmvs == "320921" {
  7777. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7778. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7779. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7780. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7781. } else {
  7782. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7783. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  7784. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7785. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7786. }
  7787. resp3, requestErr3 := http.Get(api3)
  7788. if requestErr3 != nil {
  7789. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7790. return
  7791. }
  7792. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7793. if ioErr3 != nil {
  7794. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7795. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7796. return
  7797. }
  7798. var respJSON3 map[string]interface{}
  7799. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7800. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7802. return
  7803. }
  7804. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7805. userJSONBytes3, _ := json.Marshal(respJSON3)
  7806. fmt.Println("log")
  7807. fmt.Println(string(userJSONBytes3))
  7808. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7809. utils.ErrorLog("解析失败:%v", err)
  7810. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7811. return
  7812. }
  7813. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7814. res2.Output = resSix10265.Output
  7815. res2.ErrMsg = resSix10265.ErrMsg
  7816. res2.Cainfo = resSix10265.Cainfo
  7817. res2.WarnMsg = resSix10265.WarnMsg
  7818. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7819. res2.Infcode = infocode
  7820. } else {
  7821. if miConfig.Code == "H15049901371" {
  7822. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7823. var dat map[string]interface{}
  7824. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7825. fmt.Println(dat)
  7826. } else {
  7827. fmt.Println(err)
  7828. }
  7829. saveLog(result2, src_request, "2205", "撤销明细")
  7830. userJSONBytes, _ := json.Marshal(dat)
  7831. if err := json.Unmarshal(userJSONBytes, &resSix10265); err != nil {
  7832. utils.ErrorLog("解析失败:%v", err)
  7833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7834. return
  7835. }
  7836. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7837. res2.Output = resSix10265.Output
  7838. res2.ErrMsg = resSix10265.ErrMsg
  7839. res2.Cainfo = resSix10265.Cainfo
  7840. res2.WarnMsg = resSix10265.WarnMsg
  7841. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7842. res2.Infcode = infocode
  7843. } else {
  7844. result2, src_request := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, his.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  7845. var dat map[string]interface{}
  7846. if err := json.Unmarshal([]byte(result2), &dat); err == nil {
  7847. fmt.Println(dat)
  7848. } else {
  7849. fmt.Println(err)
  7850. }
  7851. saveLog(result2, src_request, "2205", "撤销明细")
  7852. userJSONBytes, _ := json.Marshal(dat)
  7853. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  7854. utils.ErrorLog("解析失败:%v", err)
  7855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7856. return
  7857. }
  7858. }
  7859. }
  7860. if res2.Infcode == 0 {
  7861. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  7862. if err == nil {
  7863. //当押金不为零时产生退费记录
  7864. if order.Decimal != 0 {
  7865. tmp := strconv.FormatInt(order.ID, 10)
  7866. err = service.MoneyIncrease(adminUser.CurrentOrgId, order.PatientId, tmp, order.Decimal)
  7867. if err != nil {
  7868. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7869. return
  7870. }
  7871. }
  7872. c.ServeSuccessJSON(map[string]interface{}{
  7873. "msg": "退费成功",
  7874. })
  7875. } else {
  7876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7877. return
  7878. }
  7879. } else {
  7880. c.ServeSuccessJSON(map[string]interface{}{
  7881. "code": -10,
  7882. "msg": res2.ErrMsg,
  7883. })
  7884. }
  7885. } else {
  7886. c.ServeSuccessJSON(map[string]interface{}{
  7887. "code": -10,
  7888. "msg": res.ErrMsg,
  7889. })
  7890. }
  7891. }
  7892. }
  7893. func (c *HisApiController) RefundNumber() {
  7894. record_time := c.GetString("record_time")
  7895. //patient_id, _ := c.GetInt64("patient_id")
  7896. admin_user_id, _ := c.GetInt64("admin_user_id")
  7897. his_patient_id, _ := c.GetInt64("id")
  7898. timeLayout := "2006-01-02"
  7899. loc, _ := time.LoadLocation("Local")
  7900. adminUser := c.GetAdminUserInfo()
  7901. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  7902. fmt.Println(err)
  7903. if err != nil {
  7904. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  7905. return
  7906. }
  7907. recordDateTime := theTime.Unix()
  7908. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7909. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  7910. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  7911. //order, _ := service.GetHisOrderByID(order_id)
  7912. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  7913. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  7914. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  7915. count, _ := service.GetOrderCountByNumber(adminUser.CurrentOrgId, his.PatientId, recordDateTime, his.Number)
  7916. if count > 0 {
  7917. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeOrderParamWrong)
  7918. return
  7919. }
  7920. if config.IsOpen == 1 { //对接了医保,走医保流程
  7921. var res2 ResultSix
  7922. var resSix10265 ResultSix10265
  7923. if miConfig.MdtrtareaAdmvs == "421300" {
  7924. api3 := "http://192.168.124.4:9532/" + "hbyb/2202?psn_no=" + his.PsnNo +
  7925. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7926. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  7927. resp3, requestErr3 := http.Get(api3)
  7928. if requestErr3 != nil {
  7929. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7930. return
  7931. }
  7932. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7933. if ioErr3 != nil {
  7934. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7935. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7936. return
  7937. }
  7938. var respJSON3 map[string]interface{}
  7939. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7940. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7942. return
  7943. }
  7944. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7945. userJSONBytes3, _ := json.Marshal(respJSON3)
  7946. fmt.Println("log")
  7947. fmt.Println(string(userJSONBytes3))
  7948. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  7949. utils.ErrorLog("解析失败:%v", err)
  7950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7951. return
  7952. }
  7953. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  7954. var api3 string
  7955. if miConfig.MdtrtareaAdmvs == "320921" {
  7956. api3 = "http://192.168.3.111:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7957. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7958. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7959. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7960. } else {
  7961. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  7962. api3 = "http://192.168.5.251:9532/" + "jsyb/2202?psn_no=" + his.PsnNo +
  7963. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  7964. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  7965. }
  7966. resp3, requestErr3 := http.Get(api3)
  7967. if requestErr3 != nil {
  7968. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7969. return
  7970. }
  7971. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  7972. if ioErr3 != nil {
  7973. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  7974. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7975. return
  7976. }
  7977. var respJSON3 map[string]interface{}
  7978. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  7979. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  7980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7981. return
  7982. }
  7983. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  7984. userJSONBytes3, _ := json.Marshal(respJSON3)
  7985. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  7986. utils.ErrorLog("解析失败:%v", err)
  7987. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  7988. return
  7989. }
  7990. res2.InfRefmsgid = resSix10265.InfRefmsgid
  7991. res2.Output = resSix10265.Output
  7992. res2.ErrMsg = resSix10265.ErrMsg
  7993. res2.Cainfo = resSix10265.Cainfo
  7994. res2.WarnMsg = resSix10265.WarnMsg
  7995. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  7996. res2.Infcode = infocode
  7997. } else {
  7998. var api3 string
  7999. if miConfig.Code == "H15049901371" {
  8000. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8001. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8002. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8003. } else {
  8004. api3 = "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  8005. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8006. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8007. }
  8008. resp3, requestErr3 := http.Get(api3)
  8009. if requestErr3 != nil {
  8010. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8011. return
  8012. }
  8013. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8014. if ioErr3 != nil {
  8015. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8016. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8017. return
  8018. }
  8019. var respJSON3 map[string]interface{}
  8020. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8021. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8023. return
  8024. }
  8025. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8026. userJSONBytes3, _ := json.Marshal(respJSON3)
  8027. if miConfig.Code == "H15049901371" {
  8028. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8029. utils.ErrorLog("解析失败:%v", err)
  8030. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8031. return
  8032. }
  8033. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8034. res2.Output = resSix10265.Output
  8035. res2.ErrMsg = resSix10265.ErrMsg
  8036. res2.Cainfo = resSix10265.Cainfo
  8037. res2.WarnMsg = resSix10265.WarnMsg
  8038. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8039. res2.Infcode = infocode
  8040. } else {
  8041. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8042. utils.ErrorLog("解析失败:%v", err)
  8043. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8044. return
  8045. }
  8046. }
  8047. }
  8048. if res2.Infcode == 0 {
  8049. if err == nil {
  8050. c.ServeSuccessJSON(map[string]interface{}{
  8051. "msg": "退号成功",
  8052. })
  8053. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  8054. } else {
  8055. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8056. return
  8057. }
  8058. } else {
  8059. c.ServeSuccessJSON(map[string]interface{}{
  8060. "code": -10,
  8061. "msg": res2.ErrMsg,
  8062. })
  8063. }
  8064. } else {
  8065. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  8066. //if err == nil {
  8067. // c.ServeSuccessJSON(map[string]interface{}{
  8068. // "msg": "退费成功",
  8069. // })
  8070. //} else {
  8071. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8072. // return
  8073. //}
  8074. }
  8075. }
  8076. func (c *HisApiController) RefundDetail() {
  8077. order_id, _ := c.GetInt64("order_id")
  8078. //admin_user_id, _ := c.GetInt64("admin_user_id")
  8079. //his_patient_id, _ := c.GetInt64("his_patient_id")
  8080. number := c.GetString("number")
  8081. record_time := c.GetString("record_time")
  8082. patient_id, _ := c.GetInt64("patient_id")
  8083. //med_type, _ := c.GetInt64("med_type")
  8084. timeLayout := "2006-01-02"
  8085. loc, _ := time.LoadLocation("Local")
  8086. adminUser := c.GetAdminUserInfo()
  8087. //roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8088. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8089. fmt.Println(err)
  8090. if err != nil {
  8091. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8092. return
  8093. }
  8094. recordDateTime := theTime.Unix()
  8095. //his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  8096. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  8097. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8098. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8099. var order models.HisOrder
  8100. order, _ = service.GetHisOrderByID(order_id)
  8101. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8102. if config.IsOpen == 1 { //对接了医保,走医保流程
  8103. var res2 ResultSix
  8104. if miConfig.MdtrtareaAdmvs == "421300" {
  8105. api3 := "http://192.168.124.4:9532/" + "hbyb/2205?psn_no=" + order.PsnNo +
  8106. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8107. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8108. resp3, requestErr3 := http.Get(api3)
  8109. if requestErr3 != nil {
  8110. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8111. return
  8112. }
  8113. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8114. if ioErr3 != nil {
  8115. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8117. return
  8118. }
  8119. var respJSON3 map[string]interface{}
  8120. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8121. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8123. return
  8124. }
  8125. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8126. userJSONBytes3, _ := json.Marshal(respJSON3)
  8127. fmt.Println("log")
  8128. fmt.Println(string(userJSONBytes3))
  8129. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  8130. utils.ErrorLog("解析失败:%v", err)
  8131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8132. return
  8133. }
  8134. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8135. if err == nil {
  8136. c.ServeSuccessJSON(map[string]interface{}{
  8137. "msg": "撤销明细成功",
  8138. })
  8139. return
  8140. } else {
  8141. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8142. return
  8143. }
  8144. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8145. var resSix10265 ResultSix10265
  8146. var api3 string
  8147. if miConfig.MdtrtareaAdmvs == "320921" {
  8148. api3 = "http://192.168.3.111:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8149. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8150. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8151. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8152. } else {
  8153. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8154. api3 = "http://192.168.5.251:9532/" + "jsyb/2205?psn_no=" + order.PsnNo +
  8155. "&mdtrt_id=" + order.MdtrtId + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8156. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8157. }
  8158. resp3, requestErr3 := http.Get(api3)
  8159. if requestErr3 != nil {
  8160. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8161. return
  8162. }
  8163. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  8164. if ioErr3 != nil {
  8165. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  8166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8167. return
  8168. }
  8169. var respJSON3 map[string]interface{}
  8170. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  8171. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8172. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8173. return
  8174. }
  8175. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8176. userJSONBytes3, _ := json.Marshal(respJSON3)
  8177. fmt.Println("log")
  8178. fmt.Println(string(userJSONBytes3))
  8179. if err := json.Unmarshal(userJSONBytes3, &resSix10265); err != nil {
  8180. utils.ErrorLog("解析失败:%v", err)
  8181. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8182. return
  8183. }
  8184. res2.InfRefmsgid = resSix10265.InfRefmsgid
  8185. res2.Output = resSix10265.Output
  8186. res2.ErrMsg = resSix10265.ErrMsg
  8187. res2.Cainfo = resSix10265.Cainfo
  8188. res2.WarnMsg = resSix10265.WarnMsg
  8189. infocode, _ := strconv.ParseInt(resSix10265.Infcode, 10, 64)
  8190. res2.Infcode = infocode
  8191. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8192. if err == nil {
  8193. c.ServeSuccessJSON(map[string]interface{}{
  8194. "msg": "撤销明细成功",
  8195. })
  8196. return
  8197. } else {
  8198. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8199. return
  8200. }
  8201. } else {
  8202. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  8203. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  8204. "&insuplc_admdvs=" + his.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8205. resp2, requestErr2 := http.Get(api2)
  8206. if requestErr2 != nil {
  8207. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8208. return
  8209. }
  8210. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  8211. if ioErr2 != nil {
  8212. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  8213. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8214. return
  8215. }
  8216. var respJSON2 map[string]interface{}
  8217. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  8218. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8219. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8220. return
  8221. }
  8222. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8223. if err == nil {
  8224. c.ServeSuccessJSON(map[string]interface{}{
  8225. "msg": "撤销明细成功",
  8226. })
  8227. return
  8228. } else {
  8229. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8230. return
  8231. }
  8232. }
  8233. } else {
  8234. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  8235. if err == nil {
  8236. c.ServeSuccessJSON(map[string]interface{}{
  8237. "msg": "退费成功",
  8238. })
  8239. } else {
  8240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8241. return
  8242. }
  8243. }
  8244. }
  8245. //对账
  8246. func (c *HisApiController) GetCheckAccount() {
  8247. start_time := c.GetString("start_time")
  8248. end_time := c.GetString("end_time")
  8249. insutype := c.GetString("insutype")
  8250. clr_type := c.GetString("clr_type")
  8251. clr_org := c.GetString("clr_optins")
  8252. admin_user_id, _ := c.GetInt64("admin_user_id")
  8253. adminUser := c.GetAdminUserInfo()
  8254. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8255. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8256. if len(clr_org) == 0 {
  8257. clr_org = miConfig.MdtrtareaAdmvs
  8258. }
  8259. timeLayout := "2006-01-02"
  8260. loc, _ := time.LoadLocation("Local")
  8261. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8262. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8263. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, "", clr_type)
  8264. fixmedins_setl_cnt := int64(len(orders))
  8265. var medfee_sumamt float64
  8266. var acct_pay float64
  8267. var fund_pay_sumamt float64
  8268. for _, item := range orders {
  8269. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8270. acct_pay = acct_pay + item.AcctPay
  8271. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8272. }
  8273. var user_name string
  8274. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8275. if role.ID == 0 {
  8276. user_name = "xxx"
  8277. } else {
  8278. user_name = role.UserName
  8279. }
  8280. var res ResultEight
  8281. var res10188 ResultEightFor10188
  8282. if config.IsOpen == 1 {
  8283. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8284. api := "http://192.168.3.111:9532/" + "jsyb/3201?" +
  8285. "insutype=" + insutype +
  8286. "&clr_type=" + "11" +
  8287. "&setl_optins=" + clr_org +
  8288. "&stmt_begndate=" + start_time +
  8289. "&stm_enddate=" + end_time +
  8290. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8291. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8292. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8293. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8294. "&fixmedins_code=" + miConfig.Code +
  8295. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8296. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8297. "&secret_key=" + miConfig.SecretKey +
  8298. "&org_name=" + miConfig.OrgName +
  8299. "&doctor=" + user_name +
  8300. "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8301. fmt.Println(api)
  8302. resp, requestErr := http.Get(api)
  8303. if requestErr != nil {
  8304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8305. return
  8306. }
  8307. body, ioErr := ioutil.ReadAll(resp.Body)
  8308. fmt.Println(body)
  8309. if ioErr != nil {
  8310. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8311. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8312. return
  8313. }
  8314. var respJSON map[string]interface{}
  8315. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8316. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8317. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8318. return
  8319. }
  8320. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8321. userJSONBytes, _ := json.Marshal(respJSON)
  8322. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8323. utils.ErrorLog("解析失败:%v", err)
  8324. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8325. return
  8326. }
  8327. res.InfRefmsgid = res10188.InfRefmsgid
  8328. res.Output = res10188.Output
  8329. res.ErrMsg = res10188.ErrMsg
  8330. res.Cainfo = res10188.Cainfo
  8331. res.WarnMsg = res10188.WarnMsg
  8332. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8333. res.Infcode = infocode
  8334. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8335. api := "http://172.16.13.254:9532/" + "nmyb/3201?" +
  8336. "insutype=" + insutype +
  8337. "&clr_type=" + "11" +
  8338. "&setl_optins=" + clr_org +
  8339. "&stmt_begndate=" + start_time +
  8340. "&stm_enddate=" + end_time +
  8341. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8342. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8343. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8344. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8345. "&fixmedins_code=" + miConfig.Code +
  8346. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8347. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8348. "&secret_key=" + miConfig.SecretKey +
  8349. "&org_name=" + miConfig.OrgName +
  8350. "&doctor=" + user_name
  8351. resp, requestErr := http.Get(api)
  8352. if requestErr != nil {
  8353. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8354. return
  8355. }
  8356. body, ioErr := ioutil.ReadAll(resp.Body)
  8357. if ioErr != nil {
  8358. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8359. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8360. return
  8361. }
  8362. var respJSON map[string]interface{}
  8363. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8364. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8365. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8366. return
  8367. }
  8368. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8369. result, _ := json.Marshal(respJSON)
  8370. fmt.Println("log")
  8371. fmt.Println(string(result))
  8372. if err := json.Unmarshal([]byte(result), &res10188); err != nil {
  8373. utils.ErrorLog("解析失败:%v", err)
  8374. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8375. return
  8376. }
  8377. res.InfRefmsgid = res10188.InfRefmsgid
  8378. res.Output = res10188.Output
  8379. res.ErrMsg = res10188.ErrMsg
  8380. res.Cainfo = res10188.Cainfo
  8381. res.WarnMsg = res10188.WarnMsg
  8382. infocode, _ := strconv.ParseInt(res10188.Infcode, 10, 64)
  8383. res.Infcode = infocode
  8384. } else {
  8385. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8386. "insutype=" + insutype +
  8387. "&clr_type=" + clr_type +
  8388. "&setl_optins=" + clr_org +
  8389. "&stmt_begndate=" + start_time +
  8390. "&stm_enddate=" + end_time +
  8391. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8392. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8393. "&acct_pay=" + fmt.Sprintf("%.4f", acct_pay) +
  8394. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8395. "&fixmedins_code=" + miConfig.Code +
  8396. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8397. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8398. "&secret_key=" + miConfig.SecretKey +
  8399. "&org_name=" + miConfig.OrgName +
  8400. "&doctor=" + user_name
  8401. fmt.Println(api)
  8402. resp, requestErr := http.Get(api)
  8403. if requestErr != nil {
  8404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8405. return
  8406. }
  8407. body, ioErr := ioutil.ReadAll(resp.Body)
  8408. fmt.Println(body)
  8409. if ioErr != nil {
  8410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8412. return
  8413. }
  8414. var respJSON map[string]interface{}
  8415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8418. return
  8419. }
  8420. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8421. userJSONBytes, _ := json.Marshal(respJSON)
  8422. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8423. utils.ErrorLog("解析失败:%v", err)
  8424. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8425. return
  8426. }
  8427. }
  8428. if res.Infcode == 0 {
  8429. if res.Output.Stmtinfo.StmtRslt == "0" {
  8430. micc := &models.MedicalInsuranceCostCompare{
  8431. StartTime: startime.Unix(),
  8432. EndTime: endtime.Unix(),
  8433. Insutype: insutype,
  8434. CheckType: 1,
  8435. Num: fixmedins_setl_cnt,
  8436. Mtime: time.Now().Unix(),
  8437. Status: 1,
  8438. UserOrgId: adminUser.CurrentOrgId,
  8439. CostTotal: medfee_sumamt,
  8440. FuncTotal: fund_pay_sumamt,
  8441. PsnPay: acct_pay,
  8442. Creator: admin_user_id,
  8443. Ctime: time.Now().Unix(),
  8444. ClrType: clr_type,
  8445. }
  8446. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  8447. if err == nil {
  8448. c.ServeSuccessJSON(map[string]interface{}{
  8449. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8450. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8451. })
  8452. } else {
  8453. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8454. }
  8455. } else {
  8456. c.ServeSuccessJSON(map[string]interface{}{
  8457. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  8458. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  8459. })
  8460. }
  8461. } else {
  8462. c.ServeSuccessJSON(map[string]interface{}{
  8463. "code": -10,
  8464. "msg": res.ErrMsg,
  8465. })
  8466. }
  8467. }
  8468. }
  8469. func (c *HisApiController) Check310() {
  8470. adminUser := c.GetAdminUserInfo()
  8471. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8472. var user_name string
  8473. user_name = "高慧裕"
  8474. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8475. "insutype=" + "310" +
  8476. "&clr_type=" + "" +
  8477. "&setl_optins=" + "441202" +
  8478. "&stmt_begndate=" + "2022-03-01" +
  8479. "&stm_enddate=" + "2022-03-31" +
  8480. "&medfee_sumamt=" + "194930.12" +
  8481. "&fund_pay_sumamt=" + "188741.46" +
  8482. "&acct_pay=" + "0" +
  8483. "&fixmedins_setl_cnt=" + "452" +
  8484. "&fixmedins_code=" + miConfig.Code +
  8485. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8486. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8487. "&secret_key=" + miConfig.SecretKey +
  8488. "&org_name=" + miConfig.OrgName +
  8489. "&doctor=" + user_name
  8490. fmt.Println(api)
  8491. resp, requestErr := http.Get(api)
  8492. if requestErr != nil {
  8493. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8494. return
  8495. }
  8496. body, ioErr := ioutil.ReadAll(resp.Body)
  8497. fmt.Println(body)
  8498. if ioErr != nil {
  8499. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8500. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8501. return
  8502. }
  8503. var respJSON map[string]interface{}
  8504. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8505. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8506. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8507. return
  8508. }
  8509. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8510. userJSONBytes, _ := json.Marshal(respJSON)
  8511. var res ResultEight
  8512. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8513. utils.ErrorLog("解析失败:%v", err)
  8514. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8515. return
  8516. }
  8517. }
  8518. func (c *HisApiController) Check390() {
  8519. adminUser := c.GetAdminUserInfo()
  8520. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8521. var user_name string
  8522. user_name = "高慧裕"
  8523. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  8524. "insutype=" + "390" +
  8525. "&clr_type=" + "" +
  8526. "&setl_optins=" + "441202" +
  8527. "&stmt_begndate=" + "2022-03-01" +
  8528. "&stm_enddate=" + "2022-03-31" +
  8529. "&medfee_sumamt=" + "1068448.89" +
  8530. "&fund_pay_sumamt=" + "1014677.62" +
  8531. "&acct_pay=" + "0" +
  8532. "&fixmedins_setl_cnt=" + "1950" +
  8533. "&fixmedins_code=" + miConfig.Code +
  8534. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8535. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8536. "&secret_key=" + miConfig.SecretKey +
  8537. "&org_name=" + miConfig.OrgName +
  8538. "&doctor=" + user_name
  8539. fmt.Println(api)
  8540. resp, requestErr := http.Get(api)
  8541. if requestErr != nil {
  8542. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8543. return
  8544. }
  8545. body, ioErr := ioutil.ReadAll(resp.Body)
  8546. fmt.Println(body)
  8547. if ioErr != nil {
  8548. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8549. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8550. return
  8551. }
  8552. var respJSON map[string]interface{}
  8553. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8554. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8555. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8556. return
  8557. }
  8558. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8559. userJSONBytes, _ := json.Marshal(respJSON)
  8560. var res ResultEight
  8561. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8562. utils.ErrorLog("解析失败:%v", err)
  8563. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8564. return
  8565. }
  8566. }
  8567. //对账明细
  8568. func (c *HisApiController) GetCheckDetailAccount() {
  8569. start_time := c.GetString("start_time")
  8570. end_time := c.GetString("end_time")
  8571. admin_user_id, _ := c.GetInt64("admin_user_id")
  8572. adminUser := c.GetAdminUserInfo()
  8573. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8574. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8575. timeLayout := "2006-01-02"
  8576. loc, _ := time.LoadLocation("Local")
  8577. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  8578. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  8579. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  8580. rand.Seed(time.Now().UnixNano())
  8581. num := rand.Intn(30000)
  8582. Mkdir(miConfig.OrgName)
  8583. file := strconv.FormatInt(int64(num), 10)
  8584. file_name := file + ".txt"
  8585. zip_name := file + ".zip"
  8586. zip_path := miConfig.OrgName + "/" + zip_name
  8587. file_path := miConfig.OrgName + "/" + file_name
  8588. decimal.DivisionPrecision = 2
  8589. var medfee_sumamt float64
  8590. var psn_cash_pay float64
  8591. var fund_pay_sumamt float64
  8592. fixmedins_setl_cnt := int64(len(orders))
  8593. for _, item := range orders {
  8594. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  8595. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  8596. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  8597. }
  8598. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  8599. defer f.Close()
  8600. if err != nil {
  8601. fmt.Println(err.Error())
  8602. } else {
  8603. for _, item := range orders {
  8604. var refd_setl_flag string
  8605. if item.OrderStatus == 2 {
  8606. refd_setl_flag = "0"
  8607. var str string
  8608. str = item.SetlId + " " +
  8609. item.MdtrtId + " " +
  8610. item.PsnNo + " " +
  8611. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8612. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8613. fmt.Sprintf("%.4f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  8614. _, err = f.Write([]byte(str))
  8615. }
  8616. if item.OrderStatus == 3 {
  8617. var str string
  8618. str = item.SetlId + " " +
  8619. item.MdtrtId + " " +
  8620. item.PsnNo + " " +
  8621. fmt.Sprintf("%.4f", item.MedfeeSumamt) + " " +
  8622. fmt.Sprintf("%.4f", item.FundPaySumamt) + " " +
  8623. fmt.Sprintf("%.4f", item.AcctPay) + " " + "1" + "\r\n"
  8624. _, err = f.Write([]byte(str))
  8625. var str2 string
  8626. str2 = item.SetlId + " " +
  8627. item.MdtrtId + " " +
  8628. item.PsnNo + " " +
  8629. fmt.Sprintf("%.4f", 0-item.MedfeeSumamt) + " " +
  8630. fmt.Sprintf("%.4f", 0-item.FundPaySumamt) + " " +
  8631. fmt.Sprintf("%.4f", 0-item.AcctPay) + " " + "1" + "\r\n"
  8632. _, err = f.Write([]byte(str2))
  8633. }
  8634. }
  8635. }
  8636. Zip(file_path, zip_path)
  8637. fmt.Println(ReadFile(zip_path))
  8638. fmt.Println(string(ReadFile(zip_path)))
  8639. if config.IsOpen == 1 {
  8640. var user_name string
  8641. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8642. if role.ID == 0 {
  8643. user_name = "管理员"
  8644. } else {
  8645. user_name = role.UserName
  8646. }
  8647. baseParams := models.BaseParams{
  8648. SecretKey: miConfig.SecretKey,
  8649. FixmedinsCode: miConfig.Code,
  8650. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8651. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8652. OrgName: miConfig.OrgName,
  8653. Doctor: user_name,
  8654. }
  8655. result := service.Gdyb9101(baseParams, file_name, ReadFile(file_path))
  8656. var dat map[string]interface{}
  8657. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  8658. fmt.Println(dat)
  8659. } else {
  8660. fmt.Println(err)
  8661. }
  8662. userJSONBytes, _ := json.Marshal(dat)
  8663. var res ResultNine
  8664. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8665. utils.ErrorLog("解析失败:%v", err)
  8666. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8667. return
  8668. }
  8669. if res.Infcode == 0 {
  8670. fileNo := res.Output.FileQuryNo
  8671. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  8672. "file_qury_no=" + fileNo +
  8673. "&setl_optins=" + "定点医保中心" +
  8674. "&stmt_begndate=" + start_time +
  8675. "&stm_enddate=" + end_time +
  8676. "&medfee_sumamt=" + fmt.Sprintf("%.4f", medfee_sumamt) +
  8677. "&fund_pay_sumamt=" + fmt.Sprintf("%.4f", fund_pay_sumamt) +
  8678. "&cash_payamt=" + fmt.Sprintf("%.4f", psn_cash_pay) +
  8679. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  8680. "&fixmedins_code=" + miConfig.Code +
  8681. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  8682. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  8683. "&secret_key=" + miConfig.SecretKey +
  8684. "&org_name=" + miConfig.OrgName +
  8685. "&doctor=" + user_name
  8686. resp, requestErr := http.Get(api)
  8687. if requestErr != nil {
  8688. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8689. return
  8690. }
  8691. body, ioErr := ioutil.ReadAll(resp.Body)
  8692. if ioErr != nil {
  8693. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8695. return
  8696. }
  8697. var respJSON map[string]interface{}
  8698. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8699. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8700. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8701. return
  8702. }
  8703. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8704. userJSONBytes, _ := json.Marshal(respJSON)
  8705. var res ResultTen
  8706. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  8707. utils.ErrorLog("解析失败:%v", err)
  8708. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8709. return
  8710. }
  8711. if res.Infcode == 0 {
  8712. service.Gdyb9102(baseParams, zip_name, fileNo)
  8713. micc := &models.MedicalInsuranceCostCompare{
  8714. StartTime: startime.Unix(),
  8715. EndTime: endtime.Unix(),
  8716. Insutype: "0",
  8717. CheckType: 2,
  8718. Num: fixmedins_setl_cnt,
  8719. Mtime: time.Now().Unix(),
  8720. Status: 1,
  8721. UserOrgId: adminUser.CurrentOrgId,
  8722. CostTotal: medfee_sumamt,
  8723. FuncTotal: fund_pay_sumamt,
  8724. PsnPay: psn_cash_pay,
  8725. Creator: admin_user_id,
  8726. Ctime: time.Now().Unix(),
  8727. }
  8728. service.CreateMedicalInsuranceCostCompareRecord(micc)
  8729. c.ServeSuccessJSON(map[string]interface{}{
  8730. "msg": "明细对账成功",
  8731. })
  8732. }
  8733. } else {
  8734. }
  8735. }
  8736. }
  8737. type CustomOrderInfo struct {
  8738. Name string
  8739. Spec string
  8740. Unit string
  8741. Count float64
  8742. Price float64
  8743. Total float64
  8744. }
  8745. func (c *HisApiController) GetSettleAccounts() {
  8746. //id, _ := c.GetInt64("id")
  8747. //record_time := c.GetString("record_time")
  8748. order_id, _ := c.GetInt64("order_id")
  8749. admin_user_id, _ := c.GetInt64("admin_user_id")
  8750. //timeLayout := "2006-01-02"
  8751. //loc, _ := time.LoadLocation("Local")
  8752. //
  8753. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  8754. //if err != nil {
  8755. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  8756. // return
  8757. //}
  8758. //recordDateTime := theTime.Unix()
  8759. adminUser := c.GetAdminUserInfo()
  8760. order, _ := service.GetHisOrderByID(order_id)
  8761. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  8762. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  8763. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  8764. orderInfos = append(orderInfos, orderInfos_two...)
  8765. his_hospital, _ := service.GetInHospitalRecordByNumber(order.MdtrtId)
  8766. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  8767. var diagnosis_ids []string
  8768. if his.ID > 0 {
  8769. diagnosis_ids = strings.Split(his.Diagnosis, ",")
  8770. } else {
  8771. diagnosis_ids = strings.Split(his_hospital.Diagnosis, ",")
  8772. }
  8773. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, order.PatientId)
  8774. var dia_config []*models.HisXtDiagnoseConfig
  8775. var name string
  8776. for _, item := range diagnosis_ids {
  8777. id, _ := strconv.ParseInt(item, 10, 64)
  8778. diagnosisConfig, _ := service.FindDiagnoseById(id)
  8779. dia_config = append(dia_config, &diagnosisConfig)
  8780. if len(name) == 0 {
  8781. name = diagnosisConfig.ClassName
  8782. } else {
  8783. name = name + "," + diagnosisConfig.ClassName
  8784. }
  8785. }
  8786. var bedCostTotal float64 = 0 //床位总费
  8787. var bedCostSelfTotal float64 = 0 //床位自费
  8788. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  8789. var operationCostTotal float64 = 0 //手术费
  8790. var operationCostSelfTotal float64 = 0 //手术费
  8791. var operationCostPartSelfTotal float64 = 0 //手术费
  8792. var otherCostTotal float64 = 0 //其他费用
  8793. var otherCostSelfTotal float64 = 0 //其他费用
  8794. var otherCostPartSelfTotal float64 = 0 //其他费用
  8795. var materialCostTotal float64 = 0 //材料费
  8796. var materialCostSelfTotal float64 = 0 //材料费
  8797. var materialCostPartSelfTotal float64 = 0 //材料费
  8798. var westernMedicineCostTotal float64 = 0 //西药费
  8799. var westernMedicineCostSelfTotal float64 = 0 //西药费
  8800. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  8801. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  8802. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  8803. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  8804. var checkCostTotal float64 = 0 //检查费
  8805. var checkCostSelfTotal float64 = 0 //检查费
  8806. var checkCostPartSelfTotal float64 = 0 //检查费
  8807. var laboratoryCostTotal float64 = 0 //化验费
  8808. var laboratoryCostSelfTotal float64 = 0 //化验费
  8809. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  8810. var treatCostTotal float64 = 0 //治疗费用
  8811. var treatCostSelfTotal float64 = 0 //治疗费用
  8812. var treatCostPartSelfTotal float64 = 0 //治疗费用
  8813. decimal.DivisionPrecision = 2
  8814. for _, item := range orderInfos {
  8815. if item.MedChrgitmType == "01" { //床位费
  8816. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8817. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8818. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8819. }
  8820. if c.GetAdminUserInfo().CurrentOrgId == 10188 || c.GetAdminUserInfo().CurrentOrgId == 10217 {
  8821. if item.MedChrgitmType == "03" { //检查费
  8822. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8823. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8824. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8825. }
  8826. } else {
  8827. if item.MedChrgitmType == "03" { //检查费
  8828. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8829. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8830. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8831. }
  8832. }
  8833. if item.MedChrgitmType == "04" { //化验费
  8834. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8835. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8836. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8837. }
  8838. if item.MedChrgitmType == "05" || item.MedChrgitmType == "1402" || item.MedChrgitmType == "1403" { //治疗费
  8839. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8840. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8841. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8842. }
  8843. if item.MedChrgitmType == "06" { //手术费
  8844. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8845. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8846. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8847. }
  8848. if item.MedChrgitmType == "08" { //材料费
  8849. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8850. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8851. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8852. }
  8853. if item.MedChrgitmType == "09" { //西药费
  8854. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8855. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8856. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8857. }
  8858. if item.MedChrgitmType == "11" { //中成费
  8859. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8860. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8861. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8862. }
  8863. if item.MedChrgitmType == "14" || item.MedChrgitmType == "0" || item.MedChrgitmType == "12" || item.MedChrgitmType == "02" { //其他费
  8864. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  8865. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  8866. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  8867. }
  8868. }
  8869. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  8870. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  8871. var user_name string
  8872. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  8873. if role.ID == 0 {
  8874. user_name = "管理员"
  8875. } else {
  8876. user_name = role.UserName
  8877. }
  8878. baseParams := models.BaseParams{
  8879. SecretKey: miConfig.SecretKey,
  8880. FixmedinsCode: miConfig.Code,
  8881. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  8882. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  8883. OrgName: miConfig.OrgName,
  8884. Doctor: user_name,
  8885. }
  8886. businessParams := models.BusinessParams{
  8887. PsnNo: order.PsnNo,
  8888. MdtrtId: order.MdtrtId,
  8889. SetlId: order.SetlId,
  8890. }
  8891. var res ResultEleven
  8892. var resEleven10265 ResultEleven10265
  8893. if config.IsOpen == 1 {
  8894. if miConfig.MdtrtareaAdmvs == "421300" {
  8895. api := "http://192.168.124.4:9532/" + "hbyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8896. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8897. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8898. resp, requestErr := http.Get(api)
  8899. if requestErr != nil {
  8900. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8901. return
  8902. }
  8903. body, ioErr := ioutil.ReadAll(resp.Body)
  8904. if ioErr != nil {
  8905. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8907. return
  8908. }
  8909. var respJSON map[string]interface{}
  8910. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8911. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8913. return
  8914. }
  8915. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8916. result, _ := json.Marshal(respJSON)
  8917. fmt.Println("log")
  8918. fmt.Println(string(result))
  8919. if err := json.Unmarshal([]byte(result), &res); err != nil {
  8920. utils.ErrorLog("解析失败:%v", err)
  8921. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8922. return
  8923. }
  8924. } else if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  8925. var api string
  8926. if miConfig.MdtrtareaAdmvs == "320921" {
  8927. api = "http://192.168.3.111:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8928. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8929. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8930. //req, _ = http.NewRequest("POST", "http://192.168.3.111:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8931. } else {
  8932. //req, _ = http.NewRequest("POST", "http://192.168.5.251:9532/"+"jsyb/2204", bytes.NewReader(bytesData))
  8933. api = "http://192.168.5.251:9532/" + "jsyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8934. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8935. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&url=" + miConfig.Url + "&ak=" + miConfig.AccessKey + "&cainfo=" + miConfig.Cainfo
  8936. }
  8937. resp, requestErr := http.Get(api)
  8938. if requestErr != nil {
  8939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8940. return
  8941. }
  8942. body, ioErr := ioutil.ReadAll(resp.Body)
  8943. if ioErr != nil {
  8944. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8945. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8946. return
  8947. }
  8948. var respJSON map[string]interface{}
  8949. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8950. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8951. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8952. return
  8953. }
  8954. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8955. result, _ := json.Marshal(respJSON)
  8956. fmt.Println("log")
  8957. fmt.Println(string(result))
  8958. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8959. utils.ErrorLog("解析失败:%v", err)
  8960. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8961. return
  8962. }
  8963. res.InfRefmsgid = resEleven10265.InfRefmsgid
  8964. res.Output = resEleven10265.Output
  8965. res.ErrMsg = resEleven10265.ErrMsg
  8966. res.Cainfo = resEleven10265.Cainfo
  8967. res.WarnMsg = resEleven10265.WarnMsg
  8968. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  8969. res.Infcode = infocode
  8970. } else if miConfig.MdtrtareaAdmvs == "150499" {
  8971. fmt.Println("~~~~~~~")
  8972. api := "http://172.16.13.254:9532/" + "nmyb/5203?psn_no=" + businessParams.PsnNo + "&mdtrt_id=" + businessParams.MdtrtId + "&setl_id=" + businessParams.SetlId +
  8973. "&org_name=" + miConfig.OrgName + "&doctor=" + baseParams.Doctor + "&fixmedins_code=" + miConfig.Code +
  8974. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  8975. resp, requestErr := http.Get(api)
  8976. if requestErr != nil {
  8977. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8978. return
  8979. }
  8980. body, ioErr := ioutil.ReadAll(resp.Body)
  8981. if ioErr != nil {
  8982. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  8983. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8984. return
  8985. }
  8986. var respJSON map[string]interface{}
  8987. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  8988. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  8989. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8990. return
  8991. }
  8992. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  8993. result, _ := json.Marshal(respJSON)
  8994. fmt.Println("log")
  8995. fmt.Println(string(result))
  8996. if err := json.Unmarshal([]byte(result), &resEleven10265); err != nil {
  8997. utils.ErrorLog("解析失败:%v", err)
  8998. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  8999. return
  9000. }
  9001. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9002. res.Output = resEleven10265.Output
  9003. res.ErrMsg = resEleven10265.ErrMsg
  9004. res.Cainfo = resEleven10265.Cainfo
  9005. res.WarnMsg = resEleven10265.WarnMsg
  9006. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9007. res.Infcode = infocode
  9008. } else {
  9009. result := service.Gdyb5203(baseParams, businessParams)
  9010. //service.Gdyb5204(baseParams, businessParams)
  9011. //service.Gdyb5302(businessParams.PsnNo, baseParams.OrgName, baseParams.Doctor, baseParams.FixmedinsCode, baseParams.InsuplcAdmdvs, baseParams.MdtrtareaAdmvs, baseParams.SecretKey)
  9012. var dat map[string]interface{}
  9013. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9014. fmt.Println(dat)
  9015. } else {
  9016. fmt.Println(err)
  9017. }
  9018. userJSONBytes, _ := json.Marshal(dat)
  9019. if miConfig.Code == "H15049901371" {
  9020. if err := json.Unmarshal(userJSONBytes, &resEleven10265); err != nil {
  9021. utils.ErrorLog("解析失败:%v", err)
  9022. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9023. return
  9024. }
  9025. res.InfRefmsgid = resEleven10265.InfRefmsgid
  9026. res.Output = resEleven10265.Output
  9027. res.ErrMsg = resEleven10265.ErrMsg
  9028. res.Cainfo = resEleven10265.Cainfo
  9029. res.WarnMsg = resEleven10265.WarnMsg
  9030. infocode, _ := strconv.ParseInt(resEleven10265.Infcode, 10, 64)
  9031. res.Infcode = infocode
  9032. } else {
  9033. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9034. utils.ErrorLog("解析失败:%v", err)
  9035. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9036. return
  9037. }
  9038. }
  9039. }
  9040. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9041. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  9042. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, order.PatientId, order.SettleAccountsDate)
  9043. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  9044. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, his_hospital.Doctor)
  9045. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9046. var doctor_name string
  9047. if roles.ID == 0 {
  9048. doctor_name = "管理员"
  9049. } else {
  9050. doctor_name = roles.UserName
  9051. }
  9052. yiliao_leibie := ""
  9053. switch order.MedType {
  9054. case "11":
  9055. yiliao_leibie = "普通门诊"
  9056. break
  9057. case "12":
  9058. yiliao_leibie = "门诊挂号"
  9059. break
  9060. case "13":
  9061. yiliao_leibie = "急诊"
  9062. break
  9063. case "14":
  9064. yiliao_leibie = "门诊特殊病"
  9065. break
  9066. case "15":
  9067. yiliao_leibie = "门诊统筹"
  9068. break
  9069. case "16":
  9070. yiliao_leibie = "门诊慢性病"
  9071. break
  9072. case "21":
  9073. yiliao_leibie = "普通住院"
  9074. break
  9075. }
  9076. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9077. if res.Infcode == 0 {
  9078. c.ServeSuccessJSON(map[string]interface{}{
  9079. "diagnosis": name,
  9080. "order_infos": orderInfos,
  9081. "number": order.MdtrtId,
  9082. "date": order.SettleAccountsDate,
  9083. "charge_admin": charge_admin,
  9084. "printor_admin": printor_admin,
  9085. "info": res.Output.Setlinfo,
  9086. "order": order,
  9087. "bedCostTotal": bedCostTotal,
  9088. "bedCostSelfTotal": bedCostSelfTotal,
  9089. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  9090. "operationCostTotal": operationCostTotal,
  9091. "operationCostSelfTotal": operationCostSelfTotal,
  9092. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  9093. "otherCostTotal": otherCostTotal,
  9094. "otherCostSelfTotal": otherCostSelfTotal,
  9095. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  9096. "materialCostTotal": materialCostTotal,
  9097. "materialCostSelfTotal": materialCostSelfTotal,
  9098. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  9099. "westernMedicineCostTotal": westernMedicineCostTotal,
  9100. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  9101. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  9102. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  9103. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  9104. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  9105. "checkCostTotal": checkCostTotal,
  9106. "checkCostSelfTotal": checkCostSelfTotal,
  9107. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  9108. "laboratoryCostTotal": laboratoryCostTotal,
  9109. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  9110. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  9111. "treatCostTotal": treatCostTotal,
  9112. "treatCostSelfTotal": treatCostSelfTotal,
  9113. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  9114. "doctor_info": doctor_info,
  9115. "doctor_code": adminRole_two.DoctorCode,
  9116. "doctor_name": doctor_name,
  9117. "health_card_no": order.PsnNo,
  9118. "department": departments.Name,
  9119. "yiliao_leibie": yiliao_leibie,
  9120. "after_money": order.AccountPrice,
  9121. "patient": patient,
  9122. "org_name": miConfig.OrgName,
  9123. "org_code": miConfig.Code,
  9124. "order_number": order.Number,
  9125. "his_hospital": his_hospital,
  9126. "his": his,
  9127. "dia_config": dia_config,
  9128. //"check_order_info": cus_slice,
  9129. })
  9130. }
  9131. }
  9132. }
  9133. func (c *HisApiController) CheckTreatment() {
  9134. patient_id, _ := c.GetInt64("patient_id")
  9135. id_card_no := c.GetString("id_card_no")
  9136. insutype := c.GetString("insutype")
  9137. med_type := c.GetString("med_type")
  9138. admin_user_id, _ := c.GetInt64("admin_user_id")
  9139. adminUser := c.GetAdminUserInfo()
  9140. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9141. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9142. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9143. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9144. if miConfig.MdtrtareaAdmvs == "421300" {
  9145. var res ResultTwo
  9146. api := "http://192.168.124.4:9532/" + "hbyb/1101?cert_no=" + "" +
  9147. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9148. "&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)
  9149. resp, requestErr := http.Get(api)
  9150. if requestErr != nil {
  9151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9152. return
  9153. }
  9154. body, ioErr := ioutil.ReadAll(resp.Body)
  9155. if ioErr != nil {
  9156. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9158. return
  9159. }
  9160. var respJSON map[string]interface{}
  9161. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9162. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9164. return
  9165. }
  9166. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9167. result, _ := json.Marshal(respJSON)
  9168. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9169. utils.ErrorLog("解析失败:%v", err)
  9170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9171. return
  9172. }
  9173. if res.Infcode == 0 {
  9174. api := "http://192.168.124.4:9532/" + "hbyb/2001?cert_no=" + "" +
  9175. "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code +
  9176. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&psn_no=" + res.Output.Baseinfo.PsnNo + "&insutype=" + insutype + "&med_type=" + med_type
  9177. resp, requestErr := http.Get(api)
  9178. if requestErr != nil {
  9179. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9180. return
  9181. }
  9182. body, ioErr := ioutil.ReadAll(resp.Body)
  9183. if ioErr != nil {
  9184. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9185. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9186. return
  9187. }
  9188. var respJSON map[string]interface{}
  9189. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9190. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9191. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9192. return
  9193. }
  9194. var res Result2001
  9195. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9196. result2, _ := json.Marshal(respJSON)
  9197. if err := json.Unmarshal([]byte(result2), &res); err != nil {
  9198. utils.ErrorLog("解析失败:%v", err)
  9199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9200. return
  9201. }
  9202. if res.Infcode == 0 {
  9203. c.ServeSuccessJSON(map[string]interface{}{
  9204. "msg": res.Output.Trtinfo,
  9205. })
  9206. }
  9207. } else {
  9208. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  9209. return
  9210. }
  9211. } else {
  9212. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9213. var dat map[string]interface{}
  9214. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9215. fmt.Println(dat)
  9216. } else {
  9217. fmt.Println(err)
  9218. }
  9219. userJSONBytes, _ := json.Marshal(dat)
  9220. var res ResultTwo
  9221. var res10265 ResultTwo10265
  9222. if miConfig.Code == "H15049901371" {
  9223. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9224. utils.ErrorLog("解析失败:%v", err)
  9225. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9226. return
  9227. }
  9228. res.ErrMsg = res10265.ErrMsg
  9229. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9230. res.Infcode = infocode
  9231. res.Output = res10265.Output
  9232. res.InfRefmsgid = res10265.InfRefmsgid
  9233. } else {
  9234. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9235. utils.ErrorLog("解析失败:%v", err)
  9236. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9237. return
  9238. }
  9239. }
  9240. var user_name string
  9241. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  9242. if role.ID == 0 {
  9243. user_name = "xxx"
  9244. } else {
  9245. user_name = role.UserName
  9246. }
  9247. baseParams := models.BaseParams{
  9248. SecretKey: miConfig.SecretKey,
  9249. FixmedinsCode: miConfig.Code,
  9250. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9251. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9252. OrgName: miConfig.OrgName,
  9253. Doctor: user_name,
  9254. }
  9255. if config.IsOpen == 1 {
  9256. if miConfig.Code == "H15049901371" {
  9257. if med_type == "14" {
  9258. if insutype == "390" {
  9259. med_type = "9933"
  9260. } else if insutype == "310" {
  9261. med_type = "990502"
  9262. }
  9263. } else if med_type == "11" {
  9264. med_type = "11"
  9265. }
  9266. }
  9267. result := service.Gdyb2001(baseParams, res.Output.Baseinfo.PsnNo, insutype, med_type)
  9268. var dat map[string]interface{}
  9269. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9270. fmt.Println(dat)
  9271. } else {
  9272. fmt.Println(err)
  9273. }
  9274. var res Result2001
  9275. var res10265 Result2001Org10265
  9276. if miConfig.Code == "H15049901371" {
  9277. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9278. utils.ErrorLog("解析失败:%v", err)
  9279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9280. return
  9281. }
  9282. res.ErrMsg = res10265.ErrMsg
  9283. res.Output = res10265.Output
  9284. res.InfRefmsgid = res10265.InfRefmsgid
  9285. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9286. res.Infcode = infocode
  9287. } else {
  9288. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9289. utils.ErrorLog("解析失败:%v", err)
  9290. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9291. return
  9292. }
  9293. }
  9294. if res.Infcode == 0 {
  9295. c.ServeSuccessJSON(map[string]interface{}{
  9296. "msg": res.Output.Trtinfo,
  9297. })
  9298. }
  9299. }
  9300. }
  9301. }
  9302. //func (c *HisApiController) PutRecord() {
  9303. // id, _ := c.GetInt64("id")
  9304. // record_time := c.GetString("record_time")
  9305. // timeLayout := "2006-01-02"
  9306. // loc, _ := time.LoadLocation("Local")
  9307. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9308. // if err != nil {
  9309. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9310. // return
  9311. // }
  9312. // recordDateTime := theTime.Unix()
  9313. //
  9314. // adminInfo := c.GetAdminUserInfo()
  9315. // patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  9316. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9317. //
  9318. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9319. //
  9320. // fmt.Println(miConfig.SecretKey)
  9321. //
  9322. // if patient == nil {
  9323. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9324. // return
  9325. // }
  9326. // if len(patient.IdCardNo) == 0 {
  9327. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  9328. // return
  9329. // }
  9330. // config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  9331. // if config.IsOpen == 1 {
  9332. // 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
  9333. // resp, requestErr := http.Get(api)
  9334. // if requestErr != nil {
  9335. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9336. // return
  9337. // }
  9338. // defer resp.Body.Close()
  9339. // body, ioErr := ioutil.ReadAll(resp.Body)
  9340. // if ioErr != nil {
  9341. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9342. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9343. // return
  9344. // }
  9345. // var respJSON map[string]interface{}
  9346. //
  9347. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9348. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9349. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9350. // return
  9351. // }
  9352. //
  9353. // userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9354. // userJSONBytes, _ := json.Marshal(userJSON)
  9355. // var res ResultTwo
  9356. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9357. // utils.ErrorLog("解析失败:%v", err)
  9358. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9359. // return
  9360. // }
  9361. // Iinfos, _ := json.Marshal(res.Output.Iinfo)
  9362. // Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  9363. // infoStr := string(Iinfos)
  9364. // idetinfoStr := string(Idetinfos)
  9365. //
  9366. // if res.Infcode == 0 {
  9367. // his := models.VMHisPatient{
  9368. // Status: 1,
  9369. // Ctime: time.Now().Unix(),
  9370. // Mtime: time.Now().Unix(),
  9371. // PsnNo: res.Output.Baseinfo.PsnNo,
  9372. // PsnCertType: res.Output.Baseinfo.PsnCertType,
  9373. // Certno: res.Output.Baseinfo.Certno,
  9374. // PsnName: res.Output.Baseinfo.PsnName,
  9375. // Gend: res.Output.Baseinfo.Gend,
  9376. // Naty: res.Output.Baseinfo.Naty,
  9377. // Brdy: res.Output.Baseinfo.Brdy,
  9378. // Age: res.Output.Baseinfo.Age,
  9379. // Iinfo: infoStr,
  9380. // Idetinfo: idetinfoStr,
  9381. // PatientId: patient.ID,
  9382. // RecordDate: theTime.Unix(),
  9383. // UserOrgId: adminInfo.CurrentOrgId,
  9384. // AdminUserId: adminInfo.AdminUser.Id,
  9385. // IsReturn: 1,
  9386. // }
  9387. //
  9388. // //doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  9389. // //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")
  9390. // //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")
  9391. //
  9392. // //var dat map[string]interface{}
  9393. // //if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9394. // // fmt.Println(dat)
  9395. // //} else {
  9396. // // fmt.Println(err)
  9397. // //}
  9398. //
  9399. // var dat2 map[string]interface{}
  9400. // if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  9401. // fmt.Println(dat2)
  9402. // } else {
  9403. // fmt.Println(err)
  9404. // }
  9405. //
  9406. // } else {
  9407. // adminUser := c.GetAdminUserInfo()
  9408. // errlog := &models.HisOrderError{
  9409. // UserOrgId: adminUser.CurrentOrgId,
  9410. // Ctime: time.Now().Unix(),
  9411. // Mtime: time.Now().Unix(),
  9412. // ErrMsg: res.ErrMsg,
  9413. // Status: 1,
  9414. // PatientId: id,
  9415. // RecordTime: recordDateTime,
  9416. // Stage: 1,
  9417. // }
  9418. // service.CreateErrMsgLog(errlog)
  9419. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  9420. // return
  9421. // }
  9422. // }
  9423. //
  9424. //}
  9425. //func (c *HisApiController) GetUploadDiag() {
  9426. // id, _ := c.GetInt64("id")
  9427. // record_time := c.GetString("record_time")
  9428. //
  9429. // diagnosis_id, _ := c.GetInt64("diagnosis")
  9430. // sick_type, _ := c.GetInt64("sick_type")
  9431. // reg_type, _ := c.GetInt64("reg_type")
  9432. //
  9433. // timeLayout := "2006-01-02"
  9434. // loc, _ := time.LoadLocation("Local")
  9435. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  9436. // if err != nil {
  9437. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  9438. // return
  9439. // }
  9440. //
  9441. // var patientPrescription models.HisPrescriptionInfo
  9442. // recordDateTime := theTime.Unix()
  9443. // adminInfo := c.GetAdminUserInfo()
  9444. // patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9445. //
  9446. // if patientPrescription.ID == 0 {
  9447. // patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9448. // }
  9449. //
  9450. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  9451. // diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  9452. // his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  9453. // sickConfig, _ := service.FindSickById(sick_type)
  9454. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  9455. //
  9456. // api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  9457. // "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  9458. // "&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 +
  9459. // "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.ContentCode + "&sick_name=" + sickConfig.ClassName
  9460. // resp2, requestErr2 := http.Get(api2)
  9461. // if requestErr2 != nil {
  9462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9463. // return
  9464. // }
  9465. // body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  9466. // if ioErr2 != nil {
  9467. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  9468. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9469. // return
  9470. // }
  9471. // var respJSON2 map[string]interface{}
  9472. // if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  9473. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9474. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9475. // return
  9476. // }
  9477. // respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9478. // userJSONBytes2, _ := json.Marshal(respJSON2)
  9479. //
  9480. // var res2 ResultSix
  9481. // if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  9482. // utils.ErrorLog("解析失败:%v", err)
  9483. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9484. // return
  9485. // }
  9486. // if res2.Infcode != 0 {
  9487. // adminUser := c.GetAdminUserInfo()
  9488. // errlog := &models.HisOrderError{
  9489. // UserOrgId: adminUser.CurrentOrgId,
  9490. // Ctime: time.Now().Unix(),
  9491. // Mtime: time.Now().Unix(),
  9492. // ErrMsg: res2.ErrMsg,
  9493. // Status: 1,
  9494. // PatientId: id,
  9495. // RecordTime: recordDateTime,
  9496. // Stage: 3,
  9497. // }
  9498. // service.CreateErrMsgLog(errlog)
  9499. //
  9500. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  9501. // return
  9502. // }
  9503. //
  9504. // c.ServeSuccessJSON(map[string]interface{}{
  9505. // "msg": "上传成功",
  9506. // })
  9507. //
  9508. //}
  9509. type QueryResult struct {
  9510. ID int64
  9511. Name string
  9512. Code string
  9513. List_type_code string
  9514. }
  9515. func (c *HisApiController) GetCheckCode() {
  9516. ids_str := c.GetString("ids")
  9517. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9518. ids_arr := strings.Split(ids_str, ",")
  9519. var queryResult []QueryResult
  9520. ids := make([]int64, 0)
  9521. for _, item := range ids_arr {
  9522. id, _ := strconv.ParseInt(item, 10, 64)
  9523. ids = append(ids, id)
  9524. }
  9525. if record_type == 1 {
  9526. drugs, _ := service.GetBatchDrugList(ids)
  9527. for _, item := range drugs {
  9528. result := QueryResult{
  9529. ID: item.ID,
  9530. Name: item.DrugName,
  9531. Code: item.MedicalInsuranceNumber,
  9532. List_type_code: "101",
  9533. }
  9534. queryResult = append(queryResult, result)
  9535. }
  9536. } else if record_type == 2 {
  9537. goods, _ := service.GetBatchGoodInformationList(ids)
  9538. for _, item := range goods {
  9539. result := QueryResult{
  9540. ID: item.ID,
  9541. Name: item.GoodName,
  9542. Code: item.MedicalInsuranceNumber,
  9543. List_type_code: "301",
  9544. }
  9545. queryResult = append(queryResult, result)
  9546. }
  9547. } else if record_type == 3 {
  9548. projects, _ := service.GetBathchMyPorjecgList(ids)
  9549. for _, item := range projects {
  9550. result := QueryResult{
  9551. ID: item.ID,
  9552. Name: item.ProjectName,
  9553. Code: item.MedicalCode,
  9554. List_type_code: "201",
  9555. }
  9556. queryResult = append(queryResult, result)
  9557. }
  9558. }
  9559. admin_user_id, _ := c.GetInt64("admin_user_id")
  9560. adminUser := c.GetAdminUserInfo()
  9561. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9562. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9563. var user_name string
  9564. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9565. if role.ID == 0 {
  9566. user_name = "xxx"
  9567. } else {
  9568. user_name = role.UserName
  9569. }
  9570. baseParams := &models.BaseParams{
  9571. SecretKey: miConfig.SecretKey,
  9572. FixmedinsCode: miConfig.Code,
  9573. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9574. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9575. OrgName: miConfig.OrgName,
  9576. Doctor: user_name,
  9577. }
  9578. if config.IsOpen == 1 {
  9579. for _, item := range queryResult {
  9580. var result string
  9581. if record_type == 1 {
  9582. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9583. } else if record_type == 2 {
  9584. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9585. } else if record_type == 3 {
  9586. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  9587. }
  9588. var dat map[string]interface{}
  9589. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9590. fmt.Println(dat)
  9591. } else {
  9592. fmt.Println(err)
  9593. }
  9594. userJSONBytes, _ := json.Marshal(dat)
  9595. var res ResultSix
  9596. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9597. utils.ErrorLog("解析失败:%v", err)
  9598. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9599. return
  9600. }
  9601. if res.Infcode == 0 {
  9602. if record_type == 1 {
  9603. service.UpdateBaseDrugById(item.ID)
  9604. } else if record_type == 2 {
  9605. service.UpdateGoodInformaitonByDetail(item.ID)
  9606. } else if record_type == 3 {
  9607. service.UpdateProjectById(item.ID)
  9608. }
  9609. c.ServeSuccessJSON(map[string]interface{}{
  9610. "failed_code": 0,
  9611. "msg": "目录对照成功",
  9612. })
  9613. } else {
  9614. c.ServeSuccessJSON(map[string]interface{}{
  9615. "failed_code": -10,
  9616. "msg": res.ErrMsg,
  9617. })
  9618. }
  9619. }
  9620. }
  9621. }
  9622. func (c *HisApiController) UnCheckCode() {
  9623. ids_str := c.GetString("ids")
  9624. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  9625. admin_user_id, _ := c.GetInt64("admin_user_id")
  9626. ids_arr := strings.Split(ids_str, ",")
  9627. var queryResult []QueryResult
  9628. ids := make([]int64, 0)
  9629. for _, item := range ids_arr {
  9630. id, _ := strconv.ParseInt(item, 10, 64)
  9631. ids = append(ids, id)
  9632. }
  9633. if record_type == 1 {
  9634. drugs, _ := service.GetBatchDrugList(ids)
  9635. for _, item := range drugs {
  9636. result := QueryResult{
  9637. ID: item.ID,
  9638. Name: item.DrugName,
  9639. Code: item.MedicalInsuranceNumber,
  9640. List_type_code: "101",
  9641. }
  9642. queryResult = append(queryResult, result)
  9643. }
  9644. } else if record_type == 2 {
  9645. goods, _ := service.GetBatchGoodInformationList(ids)
  9646. for _, item := range goods {
  9647. result := QueryResult{
  9648. ID: item.ID,
  9649. Name: item.GoodName,
  9650. Code: item.MedicalInsuranceNumber,
  9651. List_type_code: "301",
  9652. }
  9653. queryResult = append(queryResult, result)
  9654. }
  9655. } else if record_type == 3 {
  9656. projects, _ := service.GetBathchMyPorjecgList(ids)
  9657. for _, item := range projects {
  9658. result := QueryResult{
  9659. ID: item.ID,
  9660. Name: item.ProjectName,
  9661. Code: item.MedicalCode,
  9662. List_type_code: "201",
  9663. }
  9664. queryResult = append(queryResult, result)
  9665. }
  9666. }
  9667. adminUser := c.GetAdminUserInfo()
  9668. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9669. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9670. var user_name string
  9671. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9672. if role.ID == 0 {
  9673. user_name = "xxx"
  9674. } else {
  9675. user_name = role.UserName
  9676. }
  9677. baseParams := &models.BaseParams{
  9678. SecretKey: miConfig.SecretKey,
  9679. FixmedinsCode: miConfig.Code,
  9680. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  9681. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  9682. OrgName: miConfig.OrgName,
  9683. Doctor: user_name,
  9684. }
  9685. if config.IsOpen == 1 {
  9686. for _, item := range queryResult {
  9687. var result string
  9688. if record_type == 1 {
  9689. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9690. } else if record_type == 2 {
  9691. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9692. } else if record_type == 3 {
  9693. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  9694. }
  9695. var dat2 map[string]interface{}
  9696. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  9697. fmt.Println(dat2)
  9698. } else {
  9699. fmt.Println(err)
  9700. }
  9701. userJSONBytes, _ := json.Marshal(dat2)
  9702. var res ResultSix
  9703. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9704. utils.ErrorLog("解析失败:%v", err)
  9705. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9706. return
  9707. }
  9708. if res.Infcode == 0 {
  9709. if record_type == 1 {
  9710. service.UpdateDrugByIdDetail(item.ID)
  9711. } else if record_type == 2 {
  9712. service.UpdateGoodInfoById(item.ID)
  9713. } else if record_type == 3 {
  9714. service.UpdateMyProjectById(item.ID)
  9715. }
  9716. c.ServeSuccessJSON(map[string]interface{}{
  9717. "failed_code": 0,
  9718. "msg": "撤销目录对照成功",
  9719. })
  9720. } else {
  9721. c.ServeSuccessJSON(map[string]interface{}{
  9722. "failed_code": -10,
  9723. "msg": res.ErrMsg,
  9724. })
  9725. }
  9726. }
  9727. }
  9728. }
  9729. func (c *HisApiController) GetPatientInfo() {
  9730. id_card_no := c.GetString("id_card_no")
  9731. admin_user_id, _ := c.GetInt64("admin_user_id")
  9732. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  9733. if patient.ID == 0 {
  9734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  9735. return
  9736. }
  9737. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  9738. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  9739. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  9740. if config.IsOpen == 1 {
  9741. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, patient.Name)
  9742. var dat map[string]interface{}
  9743. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9744. fmt.Println(dat)
  9745. } else {
  9746. fmt.Println(err)
  9747. }
  9748. userJSONBytes, _ := json.Marshal(dat)
  9749. var res ResultTwo
  9750. var res10265 ResultTwo10265
  9751. if miConfig.Code == "H15049901371" {
  9752. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  9753. utils.ErrorLog("解析失败:%v", err)
  9754. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9755. return
  9756. }
  9757. res.ErrMsg = res10265.ErrMsg
  9758. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9759. res.Infcode = infocode
  9760. res.Output = res10265.Output
  9761. res.InfRefmsgid = res10265.InfRefmsgid
  9762. } else {
  9763. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9764. utils.ErrorLog("解析失败:%v", err)
  9765. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9766. return
  9767. }
  9768. }
  9769. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9770. // utils.ErrorLog("解析失败:%v", err)
  9771. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9772. // return
  9773. //}
  9774. if res.Infcode != 0 {
  9775. c.ServeSuccessJSON(map[string]interface{}{
  9776. "failed_code": -10,
  9777. "msg": res.ErrMsg,
  9778. })
  9779. } else {
  9780. c.ServeSuccessJSON(map[string]interface{}{
  9781. "failed_code": 0,
  9782. "info": res,
  9783. })
  9784. }
  9785. }
  9786. }
  9787. func (c *HisApiController) PsnPutOnRecord() {
  9788. record_type, _ := c.GetInt64("type")
  9789. patient_id, _ := c.GetInt64("patient_id")
  9790. admin_user_id, _ := c.GetInt64("admin_user_id")
  9791. start_time := c.GetString("start_time")
  9792. end_time := c.GetString("end_time")
  9793. adminUser := c.GetAdminUserInfo()
  9794. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9795. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9796. var patients []*models.Patients
  9797. if record_type == 1 { //全部备案
  9798. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  9799. patients = append(patients, patient...)
  9800. } else { //单个备案
  9801. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9802. patients = append(patients, patient)
  9803. }
  9804. var user_name string
  9805. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9806. if role.ID == 0 {
  9807. user_name = "xxx"
  9808. } else {
  9809. user_name = role.UserName
  9810. }
  9811. if config.IsOpen == 1 {
  9812. for _, item := range patients {
  9813. 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
  9814. resp, requestErr := http.Get(api)
  9815. if requestErr != nil {
  9816. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9817. return
  9818. }
  9819. defer resp.Body.Close()
  9820. body, ioErr := ioutil.ReadAll(resp.Body)
  9821. if ioErr != nil {
  9822. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9823. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9824. return
  9825. }
  9826. var respJSON map[string]interface{}
  9827. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9828. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9829. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9830. return
  9831. }
  9832. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9833. userJSONBytes, _ := json.Marshal(userJSON)
  9834. var res ResultTwo
  9835. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9836. utils.ErrorLog("解析失败:%v", err)
  9837. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9838. return
  9839. }
  9840. if res.Infcode == 0 {
  9841. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  9842. var dat map[string]interface{}
  9843. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9844. fmt.Println(dat)
  9845. } else {
  9846. fmt.Println(err)
  9847. }
  9848. userJSONBytes, _ := json.Marshal(dat)
  9849. var res2 ResultThirteen
  9850. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  9851. utils.ErrorLog("解析失败:%v", err)
  9852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9853. return
  9854. }
  9855. if res2.Infcode == 0 {
  9856. psnResult := &models.GdybPsnRecord{
  9857. UserOrgId: adminUser.CurrentOrgId,
  9858. PatientId: item.ID,
  9859. PsnNo: res.Output.Baseinfo.PsnNo,
  9860. Ctime: time.Now().Unix(),
  9861. Mtime: time.Now().Unix(),
  9862. Status: 1,
  9863. IsCancel: 1,
  9864. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  9865. }
  9866. service.CreatePsnRecord(psnResult)
  9867. } else {
  9868. c.ServeSuccessJSON(map[string]interface{}{
  9869. "failed_code": -10,
  9870. "msg": res2.ErrMsg,
  9871. })
  9872. return
  9873. }
  9874. }
  9875. }
  9876. }
  9877. }
  9878. func (c *HisApiController) PsnUnPutOnRecord() {
  9879. id, _ := c.GetInt64("id")
  9880. //record_type, _ := c.GetInt64("type")
  9881. admin_user_id, _ := c.GetInt64("admin_user_id")
  9882. adminUser := c.GetAdminUserInfo()
  9883. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9884. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9885. var user_name string
  9886. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  9887. if role.ID == 0 {
  9888. user_name = "xxx"
  9889. } else {
  9890. user_name = role.UserName
  9891. }
  9892. psn_record, _ := service.GetPsnRecordById(id)
  9893. if psn_record.ID == 0 {
  9894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  9895. return
  9896. }
  9897. if config.IsOpen == 1 {
  9898. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  9899. var dat map[string]interface{}
  9900. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  9901. fmt.Println(dat)
  9902. } else {
  9903. fmt.Println(err)
  9904. }
  9905. userJSONBytes, _ := json.Marshal(dat)
  9906. var res ResultFourteen
  9907. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  9908. utils.ErrorLog("解析失败:%v", err)
  9909. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9910. return
  9911. }
  9912. if res.Infcode == 0 {
  9913. psn_record.IsCancel = 2
  9914. service.CreatePsnRecord(&psn_record)
  9915. } else {
  9916. c.ServeSuccessJSON(map[string]interface{}{
  9917. "failed_code": -10,
  9918. "msg": res.ErrMsg,
  9919. })
  9920. return
  9921. }
  9922. }
  9923. }
  9924. func (c *HisApiController) PsnPutNCDSOnRecord() {
  9925. patient_id, _ := c.GetInt64("patient_id")
  9926. insutype_two := c.GetString("insutype")
  9927. psn_no := c.GetString("psn_no")
  9928. doctor_id, _ := c.GetInt64("doctor_id")
  9929. sick_id, _ := c.GetInt64("sick_id")
  9930. department_id, _ := c.GetInt64("department_id")
  9931. start_time := c.GetString("start_time")
  9932. end_time := c.GetString("end_time")
  9933. check_time := c.GetString("check_time")
  9934. adminUser := c.GetAdminUserInfo()
  9935. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  9936. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  9937. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  9938. sick, _ := service.FindSickById(sick_id)
  9939. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9940. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  9941. var res ResultTwo
  9942. var res10265 ResultTwo10265
  9943. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  9944. psn_info, _ := service.GetPsnByPatientId(patient.ID)
  9945. api := "http://192.168.3.111:9532/" + "hbyb/1101?cert_no=" + "" +
  9946. "&org_name=" + miConfig.OrgName + "&doctor=" + role.UserName + "&fixmedins_code=" + miConfig.Code +
  9947. "&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
  9948. resp, requestErr := http.Get(api)
  9949. if requestErr != nil {
  9950. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9951. return
  9952. }
  9953. body, ioErr := ioutil.ReadAll(resp.Body)
  9954. if ioErr != nil {
  9955. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  9956. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9957. return
  9958. }
  9959. var respJSON map[string]interface{}
  9960. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  9961. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  9962. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9963. return
  9964. }
  9965. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  9966. result, _ := json.Marshal(respJSON)
  9967. fmt.Println("log")
  9968. fmt.Println(string(result))
  9969. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9970. utils.ErrorLog("解析失败:%v", err)
  9971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9972. return
  9973. }
  9974. res.ErrMsg = res10265.ErrMsg
  9975. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9976. res.Infcode = infocode
  9977. res.Output = res10265.Output
  9978. res.InfRefmsgid = res10265.InfRefmsgid
  9979. } else {
  9980. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  9981. if miConfig.Code == "H15049901371" {
  9982. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  9983. utils.ErrorLog("解析失败:%v", err)
  9984. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9985. return
  9986. }
  9987. res.ErrMsg = res10265.ErrMsg
  9988. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  9989. res.Infcode = infocode
  9990. res.Output = res10265.Output
  9991. res.InfRefmsgid = res10265.InfRefmsgid
  9992. } else {
  9993. if err := json.Unmarshal([]byte(result), &res); err != nil {
  9994. utils.ErrorLog("解析失败:%v", err)
  9995. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  9996. return
  9997. }
  9998. }
  9999. }
  10000. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10001. infoStr := string(Iinfos)
  10002. var rf []*ResultFive
  10003. json.Unmarshal([]byte(infoStr), &rf)
  10004. var insuplc_admdvs string
  10005. var insutype string
  10006. var is390 int = 0
  10007. var is310 int = 0
  10008. var insutypes []*ResultFive
  10009. for _, item := range rf {
  10010. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10011. insutypes = append(insutypes, item)
  10012. }
  10013. }
  10014. if len(insutypes) == 1 {
  10015. insutype = insutypes[0].Insutype
  10016. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10017. } else {
  10018. for _, i := range insutypes {
  10019. if i.Insutype == "390" {
  10020. is390 = 1
  10021. }
  10022. if i.Insutype == "310" {
  10023. is310 = 1
  10024. }
  10025. }
  10026. }
  10027. if is390 == 1 {
  10028. insutype = "390"
  10029. }
  10030. if is310 == 1 {
  10031. insutype = "310"
  10032. }
  10033. if len(insutypes) == 2 {
  10034. insutype = insutype_two
  10035. }
  10036. if len(insutypes) == 0 {
  10037. insutype = "310"
  10038. }
  10039. insutype = insutype_two
  10040. fmt.Println(insutype)
  10041. for _, item := range rf {
  10042. fmt.Println(item.Insutype)
  10043. fmt.Println(insutype)
  10044. if item.Insutype == insutype {
  10045. fmt.Println(item.Insutype)
  10046. fmt.Println(insutype)
  10047. insuplc_admdvs = item.InsuplcAdmdvs
  10048. }
  10049. }
  10050. fmt.Println(insuplc_admdvs)
  10051. var res2 ResultThirteen
  10052. var res10265_2 ResultThirteen10265
  10053. if config.IsOpen == 1 {
  10054. if miConfig.MdtrtareaAdmvs == "320921" || miConfig.MdtrtareaAdmvs == "320982" {
  10055. } else {
  10056. 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)
  10057. var dat map[string]interface{}
  10058. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10059. fmt.Println(dat)
  10060. } else {
  10061. fmt.Println(err)
  10062. }
  10063. userJSONBytes, _ := json.Marshal(dat)
  10064. if miConfig.Code == "H15049901371" {
  10065. if err := json.Unmarshal(userJSONBytes, &res10265_2); err != nil {
  10066. utils.ErrorLog("解析失败:%v", err)
  10067. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10068. return
  10069. }
  10070. res2.ErrMsg = res10265_2.ErrMsg
  10071. infocode, _ := strconv.ParseInt(res10265_2.Infcode, 10, 64)
  10072. res2.Infcode = infocode
  10073. res2.Output = res10265_2.Output
  10074. res2.InfRefmsgid = res10265_2.InfRefmsgid
  10075. } else {
  10076. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  10077. utils.ErrorLog("解析失败:%v", err)
  10078. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10079. return
  10080. }
  10081. }
  10082. }
  10083. if res2.Infcode == 0 {
  10084. psnResult := &models.GdybPsnNcdsRecord{
  10085. UserOrgId: adminUser.CurrentOrgId,
  10086. PatientId: patient.ID,
  10087. PsnNo: psn_no,
  10088. DoctorId: doctor.AdminUserId,
  10089. DepartmentId: department_id,
  10090. SickType: sick_id,
  10091. Insutype: insutype,
  10092. Ctime: time.Now().Unix(),
  10093. Mtime: time.Now().Unix(),
  10094. Status: 1,
  10095. IsCancel: 1,
  10096. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  10097. }
  10098. service.CreatePsnNCDSRecord(psnResult)
  10099. c.ServeSuccessJSON(map[string]interface{}{
  10100. "failed_code": 0,
  10101. "msg": "备案成功",
  10102. "result": psnResult,
  10103. })
  10104. } else {
  10105. c.ServeSuccessJSON(map[string]interface{}{
  10106. "failed_code": -10,
  10107. "msg": res2.ErrMsg,
  10108. })
  10109. return
  10110. }
  10111. }
  10112. }
  10113. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  10114. id, _ := c.GetInt64("id")
  10115. admin_user_id, _ := c.GetInt64("admin_user_id")
  10116. adminUser := c.GetAdminUserInfo()
  10117. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10118. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  10119. //config, _ := service.Ge(adminUser.CurrentOrgId)
  10120. patient, _ := service.GetPatientByID(c.GetAdminUserInfo().CurrentOrgId, id)
  10121. //role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10122. //var user_name string
  10123. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10124. //if role.ID == 0 {
  10125. // user_name = "xxx"
  10126. //} else {
  10127. // user_name = role.UserName
  10128. //}
  10129. psn_record, _ := service.GetPsnNCDSRecordById(id)
  10130. if psn_record.ID == 0 {
  10131. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  10132. return
  10133. }
  10134. result, _ := service.Gdyb1101(patient.IdCardNo, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 2, "", "0", patient.Name)
  10135. var res ResultTwo
  10136. var res10265 ResultTwo10265
  10137. if miConfig.Code == "H15049901371" {
  10138. if err := json.Unmarshal([]byte(result), &res10265); err != nil {
  10139. utils.ErrorLog("解析失败:%v", err)
  10140. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10141. return
  10142. }
  10143. res.ErrMsg = res10265.ErrMsg
  10144. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10145. res.Infcode = infocode
  10146. res.Output = res10265.Output
  10147. res.InfRefmsgid = res10265.InfRefmsgid
  10148. } else {
  10149. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10150. utils.ErrorLog("解析失败:%v", err)
  10151. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10152. return
  10153. }
  10154. }
  10155. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  10156. infoStr := string(Iinfos)
  10157. var rf []*ResultFive
  10158. json.Unmarshal([]byte(infoStr), &rf)
  10159. var insuplc_admdvs string
  10160. var insutype string
  10161. var is390 int = 0
  10162. var is310 int = 0
  10163. var insutypes []*ResultFive
  10164. for _, item := range rf {
  10165. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  10166. insutypes = append(insutypes, item)
  10167. }
  10168. }
  10169. if len(insutypes) == 1 {
  10170. insutype = insutypes[0].Insutype
  10171. //insuplc_admdvs = insutypes[0].InsuplcAdmdvs
  10172. } else {
  10173. for _, i := range insutypes {
  10174. if i.Insutype == "390" {
  10175. is390 = 1
  10176. }
  10177. if i.Insutype == "310" {
  10178. is310 = 1
  10179. }
  10180. }
  10181. }
  10182. if is390 == 1 {
  10183. insutype = "390"
  10184. }
  10185. if is310 == 1 {
  10186. insutype = "310"
  10187. }
  10188. if len(insutypes) == 0 {
  10189. insutype = "310"
  10190. }
  10191. insutype = psn_record.Insutype
  10192. for _, item := range rf {
  10193. if item.Insutype == insutype {
  10194. insuplc_admdvs = item.InsuplcAdmdvs
  10195. }
  10196. }
  10197. if config.IsOpen == 1 {
  10198. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, role.UserName, miConfig.Code, insuplc_admdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  10199. var dat map[string]interface{}
  10200. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10201. fmt.Println(dat)
  10202. } else {
  10203. fmt.Println(err)
  10204. }
  10205. userJSONBytes, _ := json.Marshal(dat)
  10206. var res ResultFourteen
  10207. var res10265 ResultFourteen10265
  10208. if miConfig.Code == "H15049901371" {
  10209. if err := json.Unmarshal(userJSONBytes, &res10265); err != nil {
  10210. utils.ErrorLog("解析失败:%v", err)
  10211. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10212. return
  10213. }
  10214. res.ErrMsg = res10265.ErrMsg
  10215. infocode, _ := strconv.ParseInt(res10265.Infcode, 10, 64)
  10216. res.Infcode = infocode
  10217. res.Output = res10265.Output
  10218. res.InfRefmsgid = res10265.InfRefmsgid
  10219. } else {
  10220. if err := json.Unmarshal([]byte(result), &res); err != nil {
  10221. utils.ErrorLog("解析失败:%v", err)
  10222. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10223. return
  10224. }
  10225. }
  10226. //if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10227. // utils.ErrorLog("解析失败:%v", err)
  10228. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10229. // return
  10230. //}
  10231. if res.Infcode == 0 {
  10232. psn_record.IsCancel = 2
  10233. service.CreatePsnNCDSRecord(&psn_record)
  10234. c.ServeSuccessJSON(map[string]interface{}{
  10235. "failed_code": 0,
  10236. "msg": "撤销备案成功",
  10237. })
  10238. } else {
  10239. c.ServeSuccessJSON(map[string]interface{}{
  10240. "failed_code": -10,
  10241. "msg": res.ErrMsg,
  10242. })
  10243. return
  10244. }
  10245. }
  10246. }
  10247. func (c *HisApiController) TestTest() {
  10248. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  10249. fmt.Println(patient.Iinfo)
  10250. }
  10251. type CustomData struct {
  10252. MsgId string
  10253. PsnNo string
  10254. Info string
  10255. }
  10256. func (c *HisApiController) ReversalData() {
  10257. var customData []*CustomData
  10258. custom := &CustomData{
  10259. MsgId: "H44022900158202103301714472004",
  10260. PsnNo: "44020000001101329945",
  10261. Info: "2207",
  10262. }
  10263. customData = append(customData, custom)
  10264. custom1 := &CustomData{
  10265. MsgId: "H4402290015820210330172057803",
  10266. PsnNo: "44020000001101161813",
  10267. Info: "2207",
  10268. }
  10269. customData = append(customData, custom1)
  10270. custom2 := &CustomData{
  10271. MsgId: "H44022900158202103301705198813",
  10272. PsnNo: "44190000133097375417",
  10273. Info: "2207",
  10274. }
  10275. customData = append(customData, custom2)
  10276. custom3 := &CustomData{
  10277. MsgId: "H44022900158202103301715524756",
  10278. PsnNo: "44020000001100187221",
  10279. Info: "2207",
  10280. }
  10281. customData = append(customData, custom3)
  10282. custom4 := &CustomData{
  10283. MsgId: "H44022900158202103301730376224",
  10284. PsnNo: "44020000001101959155",
  10285. Info: "2207",
  10286. }
  10287. customData = append(customData, custom4)
  10288. custom5 := &CustomData{
  10289. MsgId: "H44022900158202103301748008725",
  10290. PsnNo: "44020000001104246641",
  10291. Info: "2207",
  10292. }
  10293. customData = append(customData, custom5)
  10294. custom6 := &CustomData{
  10295. MsgId: "H44022900158202103301718096755",
  10296. PsnNo: "44020000001102211860",
  10297. Info: "2207",
  10298. }
  10299. customData = append(customData, custom6)
  10300. custom7 := &CustomData{
  10301. MsgId: "H44022900158202103301736551640",
  10302. PsnNo: "44020000001102687718",
  10303. Info: "2207",
  10304. }
  10305. customData = append(customData, custom7)
  10306. custom8 := &CustomData{
  10307. MsgId: "H44022900158202103301743097676",
  10308. PsnNo: "44020000001102127785",
  10309. Info: "2207",
  10310. }
  10311. customData = append(customData, custom8)
  10312. custom9 := &CustomData{
  10313. MsgId: "H44022900158202103301712304203",
  10314. PsnNo: "44020000001101518097",
  10315. Info: "2207",
  10316. }
  10317. customData = append(customData, custom9)
  10318. custom10 := &CustomData{
  10319. MsgId: "H44022900158202103301738448785",
  10320. PsnNo: "44020000001100500813",
  10321. Info: "2207",
  10322. }
  10323. customData = append(customData, custom10)
  10324. custom11 := &CustomData{
  10325. MsgId: "H44022900158202103301732455843",
  10326. PsnNo: "44020000001102690557",
  10327. Info: "2207",
  10328. }
  10329. customData = append(customData, custom11)
  10330. custom12 := &CustomData{
  10331. MsgId: "H44022900158202103301745421708",
  10332. PsnNo: "44020000001102211928",
  10333. Info: "2207",
  10334. }
  10335. customData = append(customData, custom12)
  10336. custom1212 := &CustomData{
  10337. MsgId: "H440229001582021033017351627",
  10338. PsnNo: "44020000001102481733",
  10339. Info: "2207",
  10340. }
  10341. customData = append(customData, custom1212)
  10342. custom13 := &CustomData{
  10343. MsgId: "H44022900158202103301740327951",
  10344. PsnNo: "44020000001103174866",
  10345. Info: "2207",
  10346. }
  10347. customData = append(customData, custom13)
  10348. custom14 := &CustomData{
  10349. MsgId: "H4402290015820210330174922668",
  10350. PsnNo: "44020000001102927272",
  10351. Info: "2207",
  10352. }
  10353. customData = append(customData, custom14)
  10354. custom15 := &CustomData{
  10355. MsgId: "H44022900158202103301752362273",
  10356. PsnNo: "44020000001102942890",
  10357. Info: "2207",
  10358. }
  10359. customData = append(customData, custom15)
  10360. custom16 := &CustomData{
  10361. MsgId: "H44022900158202103301751082917",
  10362. PsnNo: "44020000001101662162",
  10363. Info: "2207",
  10364. }
  10365. customData = append(customData, custom16)
  10366. custom17 := &CustomData{
  10367. MsgId: "H44022900158202103301754147728",
  10368. PsnNo: "44020000000229014511",
  10369. Info: "2207",
  10370. }
  10371. customData = append(customData, custom17)
  10372. adminUser := c.GetAdminUserInfo()
  10373. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10374. for _, item := range customData {
  10375. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10376. fmt.Println(result)
  10377. }
  10378. }
  10379. func (c *HisApiController) GetAllopatry() {
  10380. year := c.GetString("year")
  10381. month := c.GetString("month")
  10382. admin_user_id, _ := c.GetInt64("admin_user_id")
  10383. adminUser := c.GetAdminUserInfo()
  10384. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10385. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10386. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10387. var dat map[string]interface{}
  10388. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10389. fmt.Println(dat)
  10390. } else {
  10391. fmt.Println(err)
  10392. }
  10393. userJSONBytes, _ := json.Marshal(dat)
  10394. var res models.Result9001
  10395. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10396. utils.ErrorLog("解析失败:%v", err)
  10397. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10398. return
  10399. }
  10400. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10401. var dat2 map[string]interface{}
  10402. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10403. fmt.Println(dat)
  10404. } else {
  10405. fmt.Println(err)
  10406. }
  10407. userJSONBytes2, _ := json.Marshal(dat2)
  10408. var res2 models.Result3260
  10409. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10410. utils.ErrorLog("解析失败:%v", err)
  10411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10412. return
  10413. }
  10414. if res2.Infcode == 0 {
  10415. c.ServeSuccessJSON(map[string]interface{}{
  10416. "list": res2.Output.Data,
  10417. })
  10418. return
  10419. } else {
  10420. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10421. return
  10422. }
  10423. }
  10424. func (c *HisApiController) ComfirmAllopatry() {
  10425. year := c.GetString("year")
  10426. month := c.GetString("month")
  10427. admin_user_id, _ := c.GetInt64("admin_user_id")
  10428. adminUser := c.GetAdminUserInfo()
  10429. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10430. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10431. result, _ := service.Gdyb9001(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1669)
  10432. var dat map[string]interface{}
  10433. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10434. fmt.Println(dat)
  10435. } else {
  10436. fmt.Println(err)
  10437. }
  10438. userJSONBytes, _ := json.Marshal(dat)
  10439. var res models.Result9001
  10440. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  10441. utils.ErrorLog("解析失败:%v", err)
  10442. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10443. return
  10444. }
  10445. result2, _ := service.Gdyb3260(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res.Output.Signinoutb.SignNo)
  10446. var dat2 map[string]interface{}
  10447. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  10448. fmt.Println(dat)
  10449. } else {
  10450. fmt.Println(err)
  10451. }
  10452. userJSONBytes2, _ := json.Marshal(dat2)
  10453. var res2 models.Result3260
  10454. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  10455. utils.ErrorLog("解析失败:%v", err)
  10456. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10457. return
  10458. }
  10459. if res2.Infcode == 0 {
  10460. result, _, msgId := service.Gdyb3261(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, res2)
  10461. var dat map[string]interface{}
  10462. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10463. fmt.Println(dat)
  10464. } else {
  10465. fmt.Println(err)
  10466. }
  10467. userJSONBytes, _ := json.Marshal(dat)
  10468. var res3 models.Result3261
  10469. if err := json.Unmarshal(userJSONBytes, &res3); err != nil {
  10470. utils.ErrorLog("解析失败:%v", err)
  10471. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10472. return
  10473. }
  10474. if res3.Infcode == 0 {
  10475. record := &models.HisYidiClearRecord{
  10476. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  10477. Ctime: time.Now().Unix(),
  10478. Mtime: time.Now().Unix(),
  10479. Status: 1,
  10480. MsgId: msgId,
  10481. }
  10482. service.SaveClearRecord(record)
  10483. c.ServeSuccessJSON(map[string]interface{}{
  10484. "msg": "提取成功",
  10485. })
  10486. }
  10487. }
  10488. }
  10489. func (c *HisApiController) RefundAllopatry() {
  10490. year := c.GetString("year")
  10491. month := c.GetString("month")
  10492. id, _ := c.GetInt64("id")
  10493. admin_user_id, _ := c.GetInt64("admin_user_id")
  10494. adminUser := c.GetAdminUserInfo()
  10495. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10496. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  10497. record, _ := service.GetClearRecordById(id)
  10498. result, _ := service.Gdyb3262(miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, year, month, record.MsgId)
  10499. var dat map[string]interface{}
  10500. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  10501. fmt.Println(dat)
  10502. } else {
  10503. fmt.Println(err)
  10504. }
  10505. userJSONBytes, _ := json.Marshal(dat)
  10506. var empty ResultFourteen
  10507. if err := json.Unmarshal(userJSONBytes, &empty); err != nil {
  10508. utils.ErrorLog("解析失败:%v", err)
  10509. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  10510. return
  10511. }
  10512. if empty.Infcode == 0 {
  10513. c.ServeSuccessJSON(map[string]interface{}{
  10514. "msg": "撤销成功",
  10515. })
  10516. return
  10517. }
  10518. }
  10519. func (c *HisApiController) ReversalOtherData() {
  10520. var customData []*CustomData
  10521. custom := &CustomData{
  10522. MsgId: "H44022900158202103301714472004",
  10523. PsnNo: "44020000001101329945",
  10524. Info: "2208",
  10525. }
  10526. customData = append(customData, custom)
  10527. custom1 := &CustomData{
  10528. MsgId: "H4402290015820210330172057803",
  10529. PsnNo: "44020000001101161813",
  10530. Info: "2208",
  10531. }
  10532. customData = append(customData, custom1)
  10533. custom2 := &CustomData{
  10534. MsgId: "H44022900158202103301705198813",
  10535. PsnNo: "44190000133097375417",
  10536. Info: "2208",
  10537. }
  10538. customData = append(customData, custom2)
  10539. custom3 := &CustomData{
  10540. MsgId: "H44022900158202103301715524756",
  10541. PsnNo: "44020000001100187221",
  10542. Info: "2208",
  10543. }
  10544. customData = append(customData, custom3)
  10545. custom4 := &CustomData{
  10546. MsgId: "H44022900158202103301730376224",
  10547. PsnNo: "44020000001101959155",
  10548. Info: "2208",
  10549. }
  10550. customData = append(customData, custom4)
  10551. custom5 := &CustomData{
  10552. MsgId: "H44022900158202103301748008725",
  10553. PsnNo: "44020000001104246641",
  10554. Info: "2208",
  10555. }
  10556. customData = append(customData, custom5)
  10557. custom6 := &CustomData{
  10558. MsgId: "H44022900158202103301718096755",
  10559. PsnNo: "44020000001102211860",
  10560. Info: "2208",
  10561. }
  10562. customData = append(customData, custom6)
  10563. custom7 := &CustomData{
  10564. MsgId: "H44022900158202103301736551640",
  10565. PsnNo: "44020000001102687718",
  10566. Info: "2208",
  10567. }
  10568. customData = append(customData, custom7)
  10569. custom8 := &CustomData{
  10570. MsgId: "H44022900158202103301743097676",
  10571. PsnNo: "44020000001102127785",
  10572. Info: "2208",
  10573. }
  10574. customData = append(customData, custom8)
  10575. custom9 := &CustomData{
  10576. MsgId: "H44022900158202103301712304203",
  10577. PsnNo: "44020000001101518097",
  10578. Info: "2208",
  10579. }
  10580. customData = append(customData, custom9)
  10581. custom10 := &CustomData{
  10582. MsgId: "H44022900158202103301738448785",
  10583. PsnNo: "44020000001100500813",
  10584. Info: "2208",
  10585. }
  10586. customData = append(customData, custom10)
  10587. custom11 := &CustomData{
  10588. MsgId: "H44022900158202103301732455843",
  10589. PsnNo: "44020000001102690557",
  10590. Info: "2208",
  10591. }
  10592. customData = append(customData, custom11)
  10593. custom12 := &CustomData{
  10594. MsgId: "H44022900158202103301745421708",
  10595. PsnNo: "44020000001102211928",
  10596. Info: "2208",
  10597. }
  10598. customData = append(customData, custom12)
  10599. custom1212 := &CustomData{
  10600. MsgId: "H440229001582021033017351627",
  10601. PsnNo: "44020000001102481733",
  10602. Info: "2208",
  10603. }
  10604. customData = append(customData, custom1212)
  10605. custom13 := &CustomData{
  10606. MsgId: "H44022900158202103301740327951",
  10607. PsnNo: "44020000001103174866",
  10608. Info: "2208",
  10609. }
  10610. customData = append(customData, custom13)
  10611. custom14 := &CustomData{
  10612. MsgId: "H4402290015820210330174922668",
  10613. PsnNo: "44020000001102927272",
  10614. Info: "2208",
  10615. }
  10616. customData = append(customData, custom14)
  10617. custom15 := &CustomData{
  10618. MsgId: "H44022900158202103301752362273",
  10619. PsnNo: "44020000001102942890",
  10620. Info: "2208",
  10621. }
  10622. customData = append(customData, custom15)
  10623. custom16 := &CustomData{
  10624. MsgId: "H44022900158202103301751082917",
  10625. PsnNo: "44020000001101662162",
  10626. Info: "2208",
  10627. }
  10628. customData = append(customData, custom16)
  10629. custom17 := &CustomData{
  10630. MsgId: "H44022900158202103301754147728",
  10631. PsnNo: "44020000000229014511",
  10632. Info: "2208",
  10633. }
  10634. customData = append(customData, custom17)
  10635. adminUser := c.GetAdminUserInfo()
  10636. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  10637. for _, item := range customData {
  10638. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  10639. fmt.Println(result)
  10640. }
  10641. }
  10642. func PathExists(path string) (bool, error) {
  10643. _, err := os.Stat(path)
  10644. if err == nil {
  10645. return true, nil
  10646. }
  10647. if os.IsNotExist(err) {
  10648. return false, nil
  10649. }
  10650. return false, err
  10651. }
  10652. //创建文件夹
  10653. func Mkdir(dir string) {
  10654. // 创建文件夹
  10655. exist, err := PathExists(dir)
  10656. if err != nil {
  10657. fmt.Println(err.Error())
  10658. } else {
  10659. if exist {
  10660. fmt.Println(dir + "文件夹已存在!")
  10661. } else {
  10662. // 文件夹名称,权限
  10663. err := os.Mkdir(dir, os.ModePerm)
  10664. if err != nil {
  10665. fmt.Println(dir+"文件夹创建失败:", err.Error())
  10666. } else {
  10667. fmt.Println(dir + "文件夹创建成功!")
  10668. }
  10669. }
  10670. }
  10671. }
  10672. //压缩文件
  10673. func Zip(srcFile string, destZip string) error {
  10674. zipfile, err := os.Create(destZip)
  10675. if err != nil {
  10676. return err
  10677. }
  10678. defer zipfile.Close()
  10679. archive := zip.NewWriter(zipfile)
  10680. defer archive.Close()
  10681. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  10682. if err != nil {
  10683. return err
  10684. }
  10685. header, err := zip.FileInfoHeader(info)
  10686. if err != nil {
  10687. return err
  10688. }
  10689. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  10690. // header.Name = path
  10691. if info.IsDir() {
  10692. header.Name += "/"
  10693. } else {
  10694. header.Method = zip.Deflate
  10695. }
  10696. writer, err := archive.CreateHeader(header)
  10697. if err != nil {
  10698. return err
  10699. }
  10700. if !info.IsDir() {
  10701. file, err := os.Open(path)
  10702. if err != nil {
  10703. return err
  10704. }
  10705. defer file.Close()
  10706. _, err = io.Copy(writer, file)
  10707. }
  10708. return err
  10709. })
  10710. return err
  10711. }
  10712. func ReadFile(filePath string) []byte {
  10713. f, err := os.Open(filePath)
  10714. if err != nil {
  10715. fmt.Println("read file fail", err)
  10716. return nil
  10717. }
  10718. defer f.Close()
  10719. fd, err := ioutil.ReadAll(f)
  10720. if err != nil {
  10721. fmt.Println("read to fd fail", err)
  10722. return nil
  10723. }
  10724. return fd
  10725. }
  10726. func saveLog(result string, request string, infno string, desc string) {
  10727. org_id, _ := beego.AppConfig.Int64("org_id")
  10728. miConfig, _ := service.FindMedicalInsuranceInfo(org_id)
  10729. dir := miConfig.OrgName + "日志"
  10730. utils.Mkdir(dir)
  10731. month := time.Unix(1557042972, 0).Format("1")
  10732. year := time.Now().Format("2006")
  10733. month = time.Now().Format("01")
  10734. day := time.Now().Format("02")
  10735. hour := time.Now().Format("15")
  10736. min := time.Now().Format("04")
  10737. sec := time.Now().Format("05")
  10738. result_time := year + "-" + month + "-" + day + " " + hour + ":" + min + ":" + sec
  10739. file := strconv.FormatInt(org_id, 10) + "_" + year + month + day + "_log"
  10740. file_name := file + ".txt"
  10741. file_path := miConfig.OrgName + "日志" + "/" + file_name
  10742. exist, _ := utils.PathExists(file_path)
  10743. if exist { //存在
  10744. fmt.Println("存在")
  10745. f, err := os.OpenFile(file_path, os.O_WRONLY, 0644)
  10746. if err != nil {
  10747. fmt.Println("read fail")
  10748. }
  10749. content := "\r\n" + "\r\n" + "\r\n" + result_time + " " + "【 " + desc + infno + "入参" + " 】:" + "\r\n" + request + "\r\n" + result_time + " " + "【 " + desc + infno + "出参" + " 】:" + "\r\n" + result
  10750. n, _ := f.Seek(0, 2)
  10751. _, err = f.WriteAt([]byte(content), n)
  10752. } else { //不存在
  10753. fmt.Println("文件不存在,创建文件")
  10754. f, err := os.Create(miConfig.OrgName + "日志" + "/" + file_name)
  10755. defer f.Close()
  10756. if err != nil {
  10757. } else {
  10758. _, err = f.Write([]byte("记录日志"))
  10759. }
  10760. }
  10761. }
  10762. type Charset string
  10763. const (
  10764. UTF8 = Charset("UTF-8")
  10765. GB18030 = Charset("GB18030")
  10766. )
  10767. func ConvertToString(src string, srcCode string, tagCode string) string {
  10768. srcCoder := mahonia.NewDecoder(srcCode)
  10769. srcResult := srcCoder.ConvertString(src)
  10770. tagCoder := mahonia.NewDecoder(tagCode)
  10771. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  10772. result := string(cdata)
  10773. return result
  10774. }