his_api_controller.go 206KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960
  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/jinzhu/gorm"
  14. "github.com/shopspring/decimal"
  15. "io"
  16. "io/ioutil"
  17. "math/rand"
  18. "net/http"
  19. "os"
  20. "path/filepath"
  21. "strconv"
  22. "strings"
  23. "syscall"
  24. "time"
  25. "unsafe"
  26. )
  27. type HisApiController struct {
  28. controllers.BaseAuthAPIController
  29. }
  30. func HisManagerApiRegistRouters() {
  31. beego.Router("/api/register/get", &HisApiController{}, "get:GetRegisterInfo")
  32. beego.Router("/api/diag/upload", &HisApiController{}, "get:GetUploadDiag")
  33. beego.Router("/api/upload/get", &HisApiController{}, "get:GetUploadInfo")
  34. beego.Router("/api/settle/query", &HisApiController{}, "get:GetSettleAccounts")
  35. beego.Router("/api/checkaccount/get", &HisApiController{}, "get:GetCheckAccount")
  36. beego.Router("/api/checkdetailaccount/get", &HisApiController{}, "get:GetCheckDetailAccount")
  37. beego.Router("/api/refund/post", &HisApiController{}, "get:Refund")
  38. //beego.Router("/api/sscard", &HisApiController{}, "get:Sscard")
  39. beego.Router("/api/refundnumber/post", &HisApiController{}, "get:RefundNumber")
  40. beego.Router("/api/refunddetail/post", &HisApiController{}, "get:RefundDetail")
  41. beego.Router("/api/treatment/check", &HisApiController{}, "get:CheckTreatment")
  42. beego.Router("/api/record/put", &HisApiController{}, "get:PutRecord")
  43. //beego.Router("/api/patient/info", &HisApiController{}, "get:GetHisPatientInfo")
  44. beego.Router("/api/org/info", &HisApiController{}, "get:GetOrgInfo")
  45. //beego.Router("/api/testcard", &HisApiController{}, "get:TestGetBasBaseInfo")
  46. //beego.Router("/api/readcard", &HisApiController{}, "get:ReadCard")
  47. //beego.Router("/api/testpay", &HisApiController{}, "get:TestPay")
  48. beego.Router("/api/presettle/get", &HisApiController{}, "get:GetPreUploadInfo")
  49. //beego.Router("/api/settle/get", &HisApiController{}, "get:GetSettleInfo")
  50. beego.Router("/api/310", &HisApiController{}, "get:Check310")
  51. beego.Router("/api/390", &HisApiController{}, "get:Check390")
  52. beego.Router("/api/patient/info", &HisApiController{}, "get:GetPatientInfo")
  53. //备案撤销相关接口
  54. beego.Router("/api/checkcode/get", &HisApiController{}, "get:GetCheckCode")
  55. beego.Router("/api/uncheckcode/get", &HisApiController{}, "get:UnCheckCode")
  56. beego.Router("/api/psn/putonrecord", &HisApiController{}, "get:PsnPutOnRecord")
  57. beego.Router("/api/psn/unputonrecord", &HisApiController{}, "get:PsnUnPutOnRecord")
  58. beego.Router("/api/psn/ncds/putonrecord", &HisApiController{}, "get:PsnPutNCDSOnRecord")
  59. beego.Router("/api/psn/ncds/unputonrecord", &HisApiController{}, "get:PsnPutUnNCDSOnRecord")
  60. beego.Router("/api/reversal", &HisApiController{}, "get:ReversalData")
  61. beego.Router("/api/reversal/other", &HisApiController{}, "get:ReversalOtherData")
  62. //beego.Router("/api/reversal/one", &HisApiController{}, "get:ReversalOtherOneData")
  63. beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  64. beego.Router("/api/pwd/check", &HisApiController{}, "get:CheckCardPWD")
  65. //beego.Router("/api/settlelist/get", &HisApiController{}, "get:GetSettleList")
  66. //beego.Router("/api/testinit", &HisApiController{}, "get:TestGetBasBaseInit")
  67. //beego.Router("/api/test", &HisApiController{}, "get:TestGetBasBaseInfo")
  68. }
  69. func (c *HisApiController) CheckCardPWD() {
  70. card_pwd := c.GetString("card_pwd")
  71. his_patient_id, _ := c.GetInt64("his_patient_id")
  72. admin_user_id, _ := c.GetInt64("admin_user_id")
  73. roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  74. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  75. his, _ := service.GetNewHisPatientInfoFour(c.GetAdminUserInfo().CurrentOrgId, his_patient_id)
  76. result := service.Gdyb90991(his.PsnNo, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, card_pwd)
  77. var dat map[string]interface{}
  78. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  79. fmt.Println(dat)
  80. } else {
  81. fmt.Println(err)
  82. }
  83. userJSONBytes, _ := json.Marshal(dat)
  84. var res Result90991
  85. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  86. utils.ErrorLog("解析失败:%v", err)
  87. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  88. return
  89. }
  90. if res.Infcode != 0 {
  91. c.ServeSuccessJSON(map[string]interface{}{
  92. "failed_code": -10,
  93. "msg": res.ErrMsg,
  94. })
  95. return
  96. } else {
  97. if res.Output.Result.CheckStat == "0" {
  98. var msg string
  99. switch res.Output.Result.CardStat {
  100. case "00":
  101. msg = "未激活"
  102. break
  103. case "10":
  104. msg = "激活"
  105. break
  106. case "20":
  107. msg = "窗口挂失"
  108. break
  109. case "21":
  110. msg = "电话挂失"
  111. break
  112. case "22":
  113. msg = "单位网上申报挂失"
  114. break
  115. case "23":
  116. msg = "保健办挂失"
  117. break
  118. case "24":
  119. msg = "个人网上挂失"
  120. break
  121. case "25":
  122. msg = "网上服务大厅挂失"
  123. break
  124. case "30":
  125. msg = "注销"
  126. break
  127. case "40":
  128. msg = "回收"
  129. break
  130. case "99":
  131. msg = "制卡中(无效卡)"
  132. break
  133. }
  134. c.ServeSuccessJSON(map[string]interface{}{
  135. "failed_code": -10,
  136. "msg": msg,
  137. })
  138. return
  139. } else {
  140. c.ServeSuccessJSON(map[string]interface{}{
  141. "msg": "校验成功",
  142. })
  143. return
  144. }
  145. }
  146. }
  147. //func (c *HisApiController) ReadCard() {
  148. // id_card_type, _ := c.GetInt64("id_card_type")
  149. // admin_user_id, _ := c.GetInt64("admin_user_id")
  150. // certificates, _ := c.GetInt64("certificates")
  151. //
  152. // roles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  153. // miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  154. // if initFlag == 0 {
  155. // c.TestGetBasBaseInit()
  156. // }
  157. // switch id_card_type {
  158. // case 1:
  159. // basStr := c.GetBasBaseInfo()
  160. // if len(basStr) == 0 {
  161. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  162. // return
  163. // }
  164. // fmt.Println(basStr)
  165. // bas := strings.Split(basStr, "|")
  166. // basNumber := bas[2]
  167. // fmt.Println(basNumber)
  168. // card_sn := bas[3]
  169. // fmt.Println(card_sn)
  170. // result := service.Gdyb1101B(basNumber, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  171. // var dat map[string]interface{}
  172. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  173. // fmt.Println(dat)
  174. // } else {
  175. // fmt.Println(err)
  176. // }
  177. //
  178. // userJSONBytes, _ := json.Marshal(dat)
  179. // var res ResultTwo
  180. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  181. // utils.ErrorLog("解析失败:%v", err)
  182. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  183. // return
  184. // }
  185. //
  186. // if res.Infcode == 0 {
  187. // patient, err := service.GetPatientByNumber(basNumber, c.GetAdminUserInfo().CurrentOrgId)
  188. // if err == gorm.ErrRecordNotFound {
  189. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  190. // return
  191. // } else if err != nil {
  192. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  193. // return
  194. //
  195. // } else {
  196. // c.ServeSuccessJSON(map[string]interface{}{
  197. // "patient": patient,
  198. // "number": basNumber,
  199. // })
  200. // }
  201. // } else {
  202. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  203. // return
  204. // }
  205. // break
  206. // case 2:
  207. // SFZStr := c.GetSFZBaseInfo()
  208. // id_card_str := strings.Split(SFZStr, "^")
  209. // id_card_number := id_card_str[0]
  210. // card_sn := ""
  211. // result := service.Gdyb1101B(id_card_number, miConfig.OrgName, roles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, id_card_type, card_sn, certificates)
  212. // var dat map[string]interface{}
  213. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  214. // fmt.Println(dat)
  215. // } else {
  216. // fmt.Println(err)
  217. // }
  218. //
  219. // userJSONBytes, _ := json.Marshal(dat)
  220. // var res ResultTwo
  221. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  222. // utils.ErrorLog("解析失败:%v", err)
  223. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  224. // return
  225. // }
  226. //
  227. // if res.Infcode == 0 {
  228. // patient, err := service.GetPatientByNumber(id_card_number, c.GetAdminUserInfo().CurrentOrgId)
  229. // if err == gorm.ErrRecordNotFound {
  230. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  231. // return
  232. // } else if err != nil {
  233. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  234. // return
  235. //
  236. // } else {
  237. // c.ServeSuccessJSON(map[string]interface{}{
  238. // "patient": patient,
  239. // "number": id_card_number,
  240. // })
  241. // }
  242. // } else {
  243. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  244. // return
  245. // }
  246. //
  247. // break
  248. // case 3:
  249. // break
  250. // }
  251. //
  252. //}
  253. var initFlag int64 = 0
  254. //func (c *HisApiController) TestGetBasBaseInit() {
  255. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  256. // Iinit := DllDef.MustFindProc("Init")
  257. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  258. // if ret != 0 {
  259. // fmt.Println("SSCard的报错原因:", err)
  260. // fmt.Println("SSCard的运算结果为:", ret)
  261. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  262. // return
  263. // }
  264. //
  265. // result := int(ret)
  266. // fmt.Println("SSCard的运算结果为1:", result)
  267. // initFlag = 1
  268. // return
  269. //}
  270. //func (c *HisApiController) GetSFZBaseInfo() string {
  271. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  272. // readCard := DllDef.MustFindProc("ReadSFZ")
  273. // if readCard == nil {
  274. // fmt.Println("readcard is nil")
  275. // readCard = DllDef.MustFindProc("ReadSFZ")
  276. // }
  277. //
  278. // str := make([]byte, 256)
  279. // str1 := make([]byte, 256)
  280. // r, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  281. //
  282. // fmt.Println(r)
  283. // return string(str)
  284. //}
  285. //func (c *HisApiController) GetBasBaseInfo() string {
  286. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  287. // readCard := DllDef.MustFindProc("ReadCardBas")
  288. // if readCard == nil {
  289. // fmt.Println("readcard is nil")
  290. // readCard = DllDef.MustFindProc("ReadCardBas")
  291. // }
  292. //
  293. // str := make([]byte, 1024)
  294. // str1 := make([]byte, 1024)
  295. // ret2, _, _ := readCard.Call((uintptr)(unsafe.Pointer(&str[0])), uintptr(1024), (uintptr)(unsafe.Pointer(&str1[0])), uintptr(1024))
  296. //
  297. // fmt.Println(string(str1))
  298. // fmt.Println(string(str))
  299. //
  300. // if ret2 != 0 {
  301. // return ""
  302. // }
  303. // return string(str)
  304. //
  305. //}
  306. func prttostr(vcode uintptr) string {
  307. var vbyte []byte
  308. for i := 0; i < 10; i++ {
  309. sbyte := *((*byte)(unsafe.Pointer(vcode)))
  310. if sbyte == 0 {
  311. break
  312. }
  313. vbyte = append(vbyte, sbyte)
  314. vcode += 1
  315. }
  316. return string(vbyte)
  317. }
  318. type CustomFundPay struct {
  319. FundPayType string `json:"fund_pay_type"`
  320. FundPayamt float64 `json:"fund_payamt"`
  321. }
  322. func (c *HisApiController) GetSettleList() {
  323. order_id, _ := c.GetInt64("order_id")
  324. admin_user_id, _ := c.GetInt64("admin_user_id")
  325. order, _ := service.GetHisOrderByIDTwo(order_id)
  326. roles, _ := service.GetDoctorListTwo(c.GetAdminUserInfo().CurrentOrgId)
  327. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  328. admin, _ := service.GetAdminUserByUserID(roles[0].AdminUserId)
  329. curRoles, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  330. depart, _ := service.GetDepartMentDetail(curRoles.DepartmentId)
  331. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  332. if order.ID == 0 {
  333. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  334. return
  335. }
  336. struct4101 := service.Struct4101{
  337. PsnNo: order.PsnNo,
  338. MdtrtId: order.MdtrtId,
  339. SetlId: order.SetlId,
  340. PsnName: order.PsnName,
  341. Gend: order.Gend,
  342. Brdy: his.Brdy,
  343. Age: his.Age,
  344. Naty: order.Naty,
  345. PatnCertType: "01",
  346. Certno: order.Certno,
  347. Prfs: "90",
  348. ConerName: roles[0].UserName,
  349. PatnRlts: "99",
  350. ConerAddr: miConfig.OrgName,
  351. ConerTel: admin.Mobile,
  352. HiType: order.Insutype,
  353. Insuplc: miConfig.InsuplcAdmdvs,
  354. MaindiagFlag: "1",
  355. BillCode: order.FaPiaoCode,
  356. BillNo: order.FaPiaoNumber,
  357. BizSn: order.Number,
  358. PsnSelfPay: order.PsnPartAmt,
  359. PsnOwnPay: order.PsnPartAmt,
  360. AcctPay: order.AcctPay,
  361. PsnCashpay: order.PsnCashPay,
  362. HiPaymtd: "1",
  363. Hsorg: miConfig.InsuplcAdmdvs,
  364. HsorgOpter: miConfig.InsuplcAdmdvs,
  365. MedinsFillPsn: curRoles.UserName,
  366. MedinsFillDept: depart.Name,
  367. IptMedType: "2",
  368. }
  369. if order.SettleType == 1 {
  370. t := time.Unix(int64(order.SettleAccountsDate), 0)
  371. dateStr := t.Format("2006-01-02")
  372. struct4101.SetlBegnDate = dateStr
  373. struct4101.SetlEndDate = dateStr
  374. } else {
  375. t := time.Unix(int64(order.SettleStartTime), 0)
  376. t2 := time.Unix(int64(order.SettleEndTime), 0)
  377. dateStartStr := t.Format("2006-01-02")
  378. dateEndStr := t2.Format("2006-01-02")
  379. struct4101.SetlBegnDate = dateStartStr
  380. struct4101.SetlEndDate = dateEndStr
  381. }
  382. var rf []CustomFundPay
  383. json.Unmarshal([]byte(order.SetlDetail), &rf)
  384. var tempFunPays []service.CustomStruct
  385. for _, item := range rf {
  386. var tempFunPay service.CustomStruct
  387. tempFunPay.FundPayamt = item.FundPayamt
  388. tempFunPay.FundPayType = item.FundPayType
  389. tempFunPays = append(tempFunPays, tempFunPay)
  390. }
  391. struct4101.CustomStruct = tempFunPays
  392. var tempOpspdiseinfos []service.OpspdiseinfoStruct
  393. var tempOpspdiseinfo2 service.OpspdiseinfoStruct
  394. //sickConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  395. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  396. var config []*models.HisXtDiagnoseConfig
  397. for _, item := range diagnosis_ids {
  398. id, _ := strconv.ParseInt(item, 10, 64)
  399. diagnosisConfig, _ := service.FindDiagnoseById(id)
  400. config = append(config, diagnosisConfig)
  401. }
  402. for _, item := range config {
  403. var tempOpspdiseinfo service.OpspdiseinfoStruct
  404. tempOpspdiseinfo.DiagCode = item.CountryCode
  405. tempOpspdiseinfo.DiagName = item.CountryContentName
  406. tempOpspdiseinfo.MaindiagFlag = "1"
  407. tempOpspdiseinfo.OprnOprtCode = ""
  408. tempOpspdiseinfo.OprnOprtName = ""
  409. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo)
  410. }
  411. sickConfigTwo, _ := service.FindSickById(his.SickType)
  412. tempOpspdiseinfo2.DiagCode = sickConfigTwo.CountryCode
  413. tempOpspdiseinfo2.DiagName = sickConfigTwo.CountryContentName
  414. tempOpspdiseinfo2.MaindiagFlag = "2"
  415. tempOpspdiseinfo2.OprnOprtCode = ""
  416. tempOpspdiseinfo2.OprnOprtName = ""
  417. tempOpspdiseinfos = append(tempOpspdiseinfos, tempOpspdiseinfo2)
  418. struct4101.OpspdiseinfoStruct = tempOpspdiseinfos
  419. var iteminfo service.IteminfoStruct
  420. var bedCostTotal float64 = 0 //床位总费
  421. var bedCostSelfTotal float64 = 0 //床位自费
  422. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  423. var operationCostTotal float64 = 0 //手术费
  424. var operationCostSelfTotal float64 = 0 //手术费
  425. var operationCostPartSelfTotal float64 = 0 //手术费
  426. var otherCostTotal float64 = 0 //其他费用
  427. var otherCostSelfTotal float64 = 0 //其他费用
  428. var otherCostPartSelfTotal float64 = 0 //其他费用
  429. var materialCostTotal float64 = 0 //材料费
  430. var materialCostSelfTotal float64 = 0 //材料费
  431. var materialCostPartSelfTotal float64 = 0 //材料费
  432. var westernMedicineCostTotal float64 = 0 //西药费
  433. var westernMedicineCostSelfTotal float64 = 0 //西药费
  434. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  435. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  436. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  437. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  438. var checkCostTotal float64 = 0 //检查费
  439. var checkCostSelfTotal float64 = 0 //检查费
  440. var checkCostPartSelfTotal float64 = 0 //检查费
  441. var laboratoryCostTotal float64 = 0 //化验费
  442. var laboratoryCostSelfTotal float64 = 0 //化验费
  443. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  444. var treatCostTotal float64 = 0 //治疗费用
  445. var treatCostSelfTotal float64 = 0 //治疗费用
  446. var treatCostPartSelfTotal float64 = 0 //治疗费用
  447. decimal.DivisionPrecision = 2
  448. var bed_fulamt_ownpay_amt float64 = 0
  449. var operation_fulamt_ownpay_amt float64 = 0
  450. var other_fulamt_ownpay_amt float64 = 0
  451. var westernMedicine_fulamt_ownpay_amt float64 = 0
  452. var chineseTraditional_fulamt_ownpay_amt float64 = 0
  453. var check_fulamt_ownpay_amt float64 = 0
  454. var material_fulamt_ownpay_amt float64 = 0
  455. var laboratory_fulamt_ownpay_amt float64 = 0
  456. var treat_fulamt_ownpay_amt float64 = 0
  457. var bed_claa_sunmfee float64 = 0
  458. var bed_clab_amt float64 = 0
  459. var bed_other_amt float64 = 0
  460. var operation_claa_sunmfee float64 = 0
  461. var operation_clab_amt float64 = 0
  462. var operation_other_amt float64 = 0
  463. var other_claa_sunmfee float64 = 0
  464. var other_clab_amt float64 = 0
  465. var other_other_amt float64 = 0
  466. var westernMedicine_claa_sunmfee float64 = 0
  467. var westernMedicine_clab_amt float64 = 0
  468. var westernMedicine_other_amt float64 = 0
  469. var chineseTraditional_claa_sunmfee float64 = 0
  470. var chineseTraditional_clab_amt float64 = 0
  471. var chineseTraditional_other_amt float64 = 0
  472. var check_claa_sunmfee float64 = 0
  473. var check_clab_amt float64 = 0
  474. var check_other_amt float64 = 0
  475. var material_claa_sunmfee float64 = 0
  476. var material_clab_amt float64 = 0
  477. var material_other_amt float64 = 0
  478. var laboratory_claa_sunmfee float64 = 0
  479. var laboratory_clab_amt float64 = 0
  480. var laboratory_other_amt float64 = 0
  481. var treat_claa_sunmfee float64 = 0
  482. var treat_clab_amt float64 = 0
  483. var treat_other_amt float64 = 0
  484. for _, item := range order.HisOrderInfo {
  485. if item.MedChrgitmType == "01" { //床位费
  486. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  487. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  488. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  489. bed_fulamt_ownpay_amt, _ = decimal.NewFromFloat(bed_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  490. if item.ChrgitmLv == "1" {
  491. bed_claa_sunmfee, _ = decimal.NewFromFloat(bed_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  492. }
  493. if item.ChrgitmLv == "2" {
  494. bed_clab_amt, _ = decimal.NewFromFloat(bed_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  495. }
  496. if item.ChrgitmLv == "3" {
  497. bed_other_amt, _ = decimal.NewFromFloat(bed_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  498. }
  499. }
  500. if item.MedChrgitmType == "03" { //检查费
  501. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  502. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  503. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  504. check_fulamt_ownpay_amt, _ = decimal.NewFromFloat(check_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  505. if item.ChrgitmLv == "1" {
  506. check_claa_sunmfee, _ = decimal.NewFromFloat(check_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  507. }
  508. if item.ChrgitmLv == "2" {
  509. check_clab_amt, _ = decimal.NewFromFloat(check_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  510. }
  511. if item.ChrgitmLv == "3" {
  512. check_other_amt, _ = decimal.NewFromFloat(check_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  513. }
  514. }
  515. if item.MedChrgitmType == "04" { //化验费
  516. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  517. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  518. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  519. laboratory_fulamt_ownpay_amt, _ = decimal.NewFromFloat(laboratory_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  520. if item.ChrgitmLv == "1" {
  521. laboratory_claa_sunmfee, _ = decimal.NewFromFloat(laboratory_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  522. }
  523. if item.ChrgitmLv == "2" {
  524. laboratory_clab_amt, _ = decimal.NewFromFloat(laboratory_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  525. }
  526. if item.ChrgitmLv == "3" {
  527. laboratory_other_amt, _ = decimal.NewFromFloat(laboratory_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  528. }
  529. }
  530. if item.MedChrgitmType == "05" { //治疗费
  531. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  532. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  533. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  534. treat_fulamt_ownpay_amt, _ = decimal.NewFromFloat(treat_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  535. if item.ChrgitmLv == "1" {
  536. treat_claa_sunmfee, _ = decimal.NewFromFloat(treat_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  537. }
  538. if item.ChrgitmLv == "2" {
  539. treat_clab_amt, _ = decimal.NewFromFloat(treat_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  540. }
  541. if item.ChrgitmLv == "3" {
  542. treat_other_amt, _ = decimal.NewFromFloat(treat_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  543. }
  544. }
  545. if item.MedChrgitmType == "06" { //手术费
  546. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  547. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  548. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  549. operation_fulamt_ownpay_amt, _ = decimal.NewFromFloat(operation_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  550. if item.ChrgitmLv == "1" {
  551. operation_claa_sunmfee, _ = decimal.NewFromFloat(operation_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  552. }
  553. if item.ChrgitmLv == "2" {
  554. operation_clab_amt, _ = decimal.NewFromFloat(operation_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  555. }
  556. if item.ChrgitmLv == "3" {
  557. operation_other_amt, _ = decimal.NewFromFloat(operation_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  558. }
  559. }
  560. if item.MedChrgitmType == "08" { //材料费
  561. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  562. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  563. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  564. material_fulamt_ownpay_amt, _ = decimal.NewFromFloat(material_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  565. if item.ChrgitmLv == "1" {
  566. material_claa_sunmfee, _ = decimal.NewFromFloat(material_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  567. }
  568. if item.ChrgitmLv == "2" {
  569. material_clab_amt, _ = decimal.NewFromFloat(material_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  570. }
  571. if item.ChrgitmLv == "3" {
  572. material_other_amt, _ = decimal.NewFromFloat(material_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  573. }
  574. }
  575. if item.MedChrgitmType == "09" { //西药费
  576. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  577. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  578. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  579. westernMedicine_fulamt_ownpay_amt, _ = decimal.NewFromFloat(westernMedicine_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  580. if item.ChrgitmLv == "1" {
  581. westernMedicine_claa_sunmfee, _ = decimal.NewFromFloat(westernMedicine_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  582. }
  583. if item.ChrgitmLv == "2" {
  584. westernMedicine_clab_amt, _ = decimal.NewFromFloat(westernMedicine_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  585. }
  586. if item.ChrgitmLv == "3" {
  587. westernMedicine_other_amt, _ = decimal.NewFromFloat(westernMedicine_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  588. }
  589. }
  590. if item.MedChrgitmType == "11" { //中成费
  591. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  592. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  593. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  594. chineseTraditional_fulamt_ownpay_amt, _ = decimal.NewFromFloat(chineseTraditional_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  595. if item.ChrgitmLv == "1" {
  596. chineseTraditional_claa_sunmfee, _ = decimal.NewFromFloat(chineseTraditional_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  597. }
  598. if item.ChrgitmLv == "2" {
  599. chineseTraditional_clab_amt, _ = decimal.NewFromFloat(chineseTraditional_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  600. }
  601. if item.ChrgitmLv == "3" {
  602. chineseTraditional_other_amt, _ = decimal.NewFromFloat(chineseTraditional_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  603. }
  604. }
  605. if item.MedChrgitmType == "14" { //其他费
  606. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  607. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  608. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  609. other_fulamt_ownpay_amt, _ = decimal.NewFromFloat(other_fulamt_ownpay_amt).Add(decimal.NewFromFloat(item.FulamtOwnpayAmt)).Float64()
  610. if item.ChrgitmLv == "1" {
  611. other_claa_sunmfee, _ = decimal.NewFromFloat(other_claa_sunmfee).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  612. }
  613. if item.ChrgitmLv == "2" {
  614. other_clab_amt, _ = decimal.NewFromFloat(other_clab_amt).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  615. }
  616. if item.ChrgitmLv == "3" {
  617. other_other_amt, _ = decimal.NewFromFloat(other_other_amt).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  618. }
  619. }
  620. }
  621. var iteminfoStructs []service.IteminfoStruct
  622. if bedCostTotal != 0 {
  623. iteminfo.MedChrgitm = "01"
  624. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  625. iteminfo.Amt = bedCostTotal
  626. iteminfo.ClaaSumfee = bed_claa_sunmfee
  627. iteminfo.ClabAmt = bed_clab_amt
  628. iteminfo.OthAmt = bed_other_amt
  629. iteminfoStructs = append(iteminfoStructs, iteminfo)
  630. }
  631. if checkCostTotal != 0 {
  632. iteminfo.MedChrgitm = "03"
  633. iteminfo.FulamtOwnpayAmt = check_fulamt_ownpay_amt
  634. iteminfo.Amt = checkCostTotal
  635. iteminfo.ClaaSumfee = check_claa_sunmfee
  636. iteminfo.ClabAmt = check_clab_amt
  637. iteminfo.OthAmt = check_other_amt
  638. iteminfoStructs = append(iteminfoStructs, iteminfo)
  639. }
  640. if laboratoryCostTotal != 0 {
  641. iteminfo.MedChrgitm = "04"
  642. iteminfo.FulamtOwnpayAmt = laboratory_fulamt_ownpay_amt
  643. iteminfo.Amt = laboratoryCostTotal
  644. iteminfo.ClaaSumfee = laboratory_claa_sunmfee
  645. iteminfo.ClabAmt = laboratory_clab_amt
  646. iteminfo.OthAmt = laboratory_other_amt
  647. iteminfoStructs = append(iteminfoStructs, iteminfo)
  648. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  649. }
  650. if treatCostTotal != 0 {
  651. iteminfo.MedChrgitm = "05"
  652. iteminfo.FulamtOwnpayAmt = treat_fulamt_ownpay_amt
  653. iteminfo.Amt = treatCostTotal
  654. iteminfo.ClaaSumfee = treat_claa_sunmfee
  655. iteminfo.ClabAmt = treat_clab_amt
  656. iteminfo.OthAmt = treat_other_amt
  657. iteminfoStructs = append(iteminfoStructs, iteminfo)
  658. // (struct4101.IteminfoStruct, iteminfo)
  659. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  660. }
  661. if operationCostTotal != 0 {
  662. iteminfo.MedChrgitm = "06"
  663. iteminfo.FulamtOwnpayAmt = bed_fulamt_ownpay_amt
  664. iteminfo.Amt = operationCostTotal
  665. iteminfo.ClaaSumfee = operation_claa_sunmfee
  666. iteminfo.ClabAmt = operation_clab_amt
  667. iteminfo.OthAmt = operation_other_amt
  668. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  669. iteminfoStructs = append(iteminfoStructs, iteminfo)
  670. }
  671. if materialCostTotal != 0 {
  672. iteminfo.MedChrgitm = "08"
  673. iteminfo.FulamtOwnpayAmt = material_fulamt_ownpay_amt
  674. iteminfo.Amt = materialCostTotal
  675. iteminfo.ClaaSumfee = material_claa_sunmfee
  676. iteminfo.ClabAmt = material_clab_amt
  677. iteminfo.OthAmt = material_other_amt
  678. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  679. iteminfoStructs = append(iteminfoStructs, iteminfo)
  680. }
  681. if westernMedicineCostTotal != 0 {
  682. iteminfo.MedChrgitm = "09"
  683. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  684. iteminfo.Amt = westernMedicineCostTotal
  685. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  686. iteminfo.ClabAmt = westernMedicine_clab_amt
  687. iteminfo.OthAmt = westernMedicine_other_amt
  688. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  689. iteminfoStructs = append(iteminfoStructs, iteminfo)
  690. }
  691. if chineseTraditionalMedicineCostTotal != 0 {
  692. iteminfo.MedChrgitm = "11"
  693. iteminfo.FulamtOwnpayAmt = westernMedicine_fulamt_ownpay_amt
  694. iteminfo.Amt = westernMedicineCostTotal
  695. iteminfo.ClaaSumfee = westernMedicine_claa_sunmfee
  696. iteminfo.ClabAmt = westernMedicine_clab_amt
  697. iteminfo.OthAmt = westernMedicine_other_amt
  698. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  699. iteminfoStructs = append(iteminfoStructs, iteminfo)
  700. }
  701. if otherCostTotal != 0 {
  702. iteminfo.MedChrgitm = "14"
  703. iteminfo.FulamtOwnpayAmt = other_fulamt_ownpay_amt
  704. iteminfo.Amt = otherCostTotal
  705. iteminfo.ClaaSumfee = other_claa_sunmfee
  706. iteminfo.ClabAmt = other_clab_amt
  707. iteminfo.OthAmt = other_other_amt
  708. //struct4101.IteminfoStruct = append(struct4101.IteminfoStruct, iteminfo)
  709. iteminfoStructs = append(iteminfoStructs, iteminfo)
  710. }
  711. struct4101.IteminfoStruct = iteminfoStructs
  712. struct4101.Ntly = "中国"
  713. struct4101.AdmCaty = "A03.06"
  714. result := service.Gdyb4101(struct4101, miConfig.SecretKey, miConfig.OrgName, curRoles.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  715. fmt.Println(result)
  716. var dat map[string]interface{}
  717. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  718. fmt.Println(dat)
  719. } else {
  720. fmt.Println(err)
  721. }
  722. userJSONBytes, _ := json.Marshal(dat)
  723. var res ResultSeventeen
  724. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  725. utils.ErrorLog("解析失败:%v", err)
  726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  727. return
  728. }
  729. if res.Infcode != 0 {
  730. c.ServeSuccessJSON(map[string]interface{}{
  731. "failed_code": -10,
  732. "msg": res.ErrMsg,
  733. })
  734. return
  735. } else {
  736. hisFundSettleListResult := &models.HisFundSettleListResult{
  737. Number: res.Output.SetlListId,
  738. Status: 1,
  739. Ctime: time.Now().Unix(),
  740. Mtime: time.Now().Unix(),
  741. UserOrgId: c.GetAdminUserInfo().CurrentOrgId,
  742. IsUpload: 1,
  743. OrderId: order_id,
  744. }
  745. service.CreateUploadRecord(hisFundSettleListResult)
  746. c.ServeSuccessJSON(map[string]interface{}{
  747. "msg": "上传成功",
  748. "result": hisFundSettleListResult,
  749. })
  750. return
  751. }
  752. }
  753. //func (c *HisApiController) TestPay() {
  754. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  755. // readCards := DllDef2.MustFindProc("BankTrans")
  756. // inputData := make(map[string]interface{})
  757. // inputData["transId"] = "05"
  758. // inputData["amount"] = "0.01"
  759. // inputData["traceNo"] = "20210227093601325405377"
  760. // inputData["cardNo"] = "F36084348"
  761. // inputData["id"] = "44022919620927046X"
  762. // //jsonStr := `
  763. // // {
  764. // // "transId": "05",
  765. // // "amount":"1.00",
  766. // // "traceNo":"20210227093601325405377",
  767. // // "cardNo":"F36084348",
  768. // // "id":"44022919620927046X"
  769. // //
  770. // // }
  771. // //`
  772. //
  773. // bytes_arr, _ := json.Marshal(inputData)
  774. // str3 := make([]byte, 256)
  775. // ret4, _, err4 := readCards.Call(StrPtr(string(bytes_arr)), (uintptr)(unsafe.Pointer(&str3[0])))
  776. // fmt.Println(":", string(str3))
  777. //
  778. // if err4 != nil {
  779. // fmt.Println("SSCard的运算结果为:", ret4)
  780. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  781. // return
  782. // }
  783. //
  784. //}
  785. //func (c *HisApiController) TestGetBasBaseInfo() {
  786. //
  787. // //result := C.Init(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  788. // //fmt.Println(result)
  789. // //cs1 := C.CString("")
  790. // //cs2 := C.CString("")
  791. // //C.ReadCardBas(cs1, IntPtr(1024), cs2, IntPtr(1024))
  792. // //fmt.Println(cs1)
  793. // //fmt.Println(cs2)
  794. // //C.free(unsafe.Pointer(cs1))
  795. // //C.free(unsafe.Pointer(cs2))
  796. //
  797. // //
  798. //
  799. // DllDef := syscall.MustLoadDLL("SSCard.dll")
  800. // Iinit := DllDef.MustFindProc("Init")
  801. // readCard := DllDef.MustFindProc("ReadCardBas")
  802. // ret, _, err := Iinit.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  803. // if ret != 0 {
  804. // fmt.Println("SSCard的报错原因:", err)
  805. // fmt.Println("SSCard的运算结果为:", ret)
  806. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  807. // return
  808. // }
  809. //
  810. // result := int(ret)
  811. // fmt.Println("SSCard的运算结果为1:", result)
  812. //
  813. // //path := ""
  814. // //bytePath := []byte( "\x00")
  815. // //bytePath2 := []byte( "\x00")
  816. // //ssss
  817. //
  818. // str := make([]byte, 256)
  819. // str1 := make([]byte, 256)
  820. // s2 := []byte(string(str))
  821. // s3 := []byte(string(str1))
  822. // ret2, _, err2 := readCard.Call((uintptr)(unsafe.Pointer(&s2[0])), IntPtr(256), (uintptr)(unsafe.Pointer(&s3[0])), IntPtr(256))
  823. // fmt.Println(" Add(4,5)的结果为:", ret2)
  824. // fmt.Println(" str:", s2)
  825. // fmt.Println(" str1:", s3)
  826. // if err2 != nil {
  827. // fmt.Println("SSCard的运算结果为:", ret2)
  828. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  829. // return
  830. // }
  831. //
  832. // //DllDef := syscall.MustLoadDLL("SSCard.dll")
  833. //
  834. //}
  835. func (c *HisApiController) GetOrgInfo() {
  836. miConfig, _ := service.FindMedicalInsuranceInfo(4)
  837. service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  838. }
  839. func (c *HisApiController) GetHisPatientInfo() {
  840. medical_insurance_card := c.GetString("medical_insurance_card")
  841. id_card_type, _ := c.GetInt64("id_card_type")
  842. id_card := c.GetString("id_card")
  843. adminInfo := c.GetAdminUserInfo()
  844. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  845. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  846. appRole, _ := service.GetAppRole(adminInfo.CurrentOrgId)
  847. IdCardNo := ""
  848. if id_card_type == 1 {
  849. IdCardNo = medical_insurance_card
  850. } else if id_card_type == 2 {
  851. IdCardNo = id_card
  852. }
  853. if config.IsOpen == 1 {
  854. 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
  855. resp, requestErr := http.Get(api)
  856. if requestErr != nil {
  857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  858. return
  859. }
  860. defer resp.Body.Close()
  861. body, ioErr := ioutil.ReadAll(resp.Body)
  862. if ioErr != nil {
  863. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  864. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  865. return
  866. }
  867. var respJSON map[string]interface{}
  868. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  869. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  870. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  871. return
  872. }
  873. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  874. userJSONBytes, _ := json.Marshal(userJSON)
  875. var res ResultTwo
  876. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  877. utils.ErrorLog("解析失败:%v", err)
  878. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  879. return
  880. }
  881. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  882. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  883. infoStr := string(Iinfos)
  884. idetinfoStr := string(Idetinfos)
  885. if res.Infcode == 0 {
  886. his := models.VMHisPatient{
  887. Status: 1,
  888. Ctime: time.Now().Unix(),
  889. Mtime: time.Now().Unix(),
  890. PsnNo: res.Output.Baseinfo.PsnNo,
  891. PsnCertType: res.Output.Baseinfo.PsnCertType,
  892. Certno: res.Output.Baseinfo.Certno,
  893. PsnName: res.Output.Baseinfo.PsnName,
  894. Gend: res.Output.Baseinfo.Gend,
  895. Naty: res.Output.Baseinfo.Naty,
  896. Brdy: res.Output.Baseinfo.Brdy,
  897. Age: res.Output.Baseinfo.Age,
  898. Iinfo: infoStr,
  899. Idetinfo: idetinfoStr,
  900. UserOrgId: adminInfo.CurrentOrgId,
  901. IsReturn: 1,
  902. IdCardType: id_card_type,
  903. }
  904. c.ServeSuccessJSON(map[string]interface{}{
  905. "info": his,
  906. })
  907. } else {
  908. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisFailedException)
  909. return
  910. }
  911. }
  912. }
  913. //func GetBasBaseInfo() (jsonStr string, err error) {
  914. //
  915. // handle := syscall.NewLazyDLL("SSCard.dll")
  916. // add := handle.NewProc("ReadCardBas")
  917. // str := make([]byte, 1024)
  918. // str1 := make([]byte, 1024)
  919. // ret, _, _ := add.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  920. // fmt.Println(ConvertToString(string(str), "gbk", "utf-8"))
  921. //
  922. // fmt.Println(ConvertToString(string(str1), "gbk", "utf-8"))
  923. //
  924. // fmt.Println("> Add(4,5)的结果为:", ret)
  925. // handle.Release()
  926. //
  927. // return "", nil
  928. //
  929. //}
  930. //func GetQRBaseInfo() (jsonStr string, err error) {
  931. // handle := syscall.LoadDLL("SSCard.dll")
  932. // ReadCardBas := handle.FindProc("GetQRBase")
  933. //
  934. // str := make([]byte, 256)
  935. // str1 := make([]byte, 256)
  936. // r, _, _ := ReadCardBas.Call((uintptr)(unsafe.Pointer(&str[0])), IntPtr(1024), (uintptr)(unsafe.Pointer(&str1[0])), IntPtr(1024))
  937. //
  938. // fmt.Println(string(str))
  939. // fmt.Println(r)
  940. // return string(str), nil
  941. //}
  942. //func CardInit() int {
  943. // DllTestDef := syscall.MustLoadDLL("SSCard.dll")
  944. // add := DllTestDef.MustFindProc("Init")
  945. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  946. // if err != nil {
  947. // fmt.Println("SSCard的运算结果为:", ret)
  948. // }
  949. // result := int(ret)
  950. // return result
  951. //}
  952. //func CardInit() int {
  953. // ret, _, err := add.Call(StrPtr("http://igb.hsa.gdgov.cn/gdyb_inf/poc/api/card/initDll"), StrPtr("440200"))
  954. // if err != nil {
  955. // fmt.Println("SSCard的运算结果为:", ret)
  956. // }
  957. // fmt.Println(err)
  958. // result := int(ret)
  959. // return result
  960. //}
  961. func IntPtr(n int) uintptr {
  962. return uintptr(n)
  963. }
  964. func StrPtr(s string) uintptr {
  965. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  966. }
  967. type ResultTwo struct {
  968. ErrMsg string `json:"err_msg"`
  969. InfRefmsgid string `json:"inf_refmsgid"`
  970. Infcode int64 `json:"infcode"`
  971. Output struct {
  972. Baseinfo struct {
  973. Age float64 `json:"age"`
  974. Brdy string `json:"brdy"`
  975. Certno string `json:"certno"`
  976. Gend string `json:"gend"`
  977. Naty string `json:"naty"`
  978. PsnCertType string `json:"psn_cert_type"`
  979. PsnName string `json:"psn_name"`
  980. PsnNo string `json:"psn_no"`
  981. } `json:"baseinfo"`
  982. Idetinfo []interface{} `json:"idetinfo"`
  983. Iinfo []struct {
  984. Balc float64 `json:"balc"`
  985. CvlservFlag string `json:"cvlserv_flag"`
  986. EmpName string `json:"emp_name"`
  987. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  988. Insutype string `json:"insutype"`
  989. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  990. PausInsuDate string `json:"paus_insu_date"`
  991. PsnInsuDate string `json:"psn_insu_date"`
  992. PsnInsuStas string `json:"psn_insu_stas"`
  993. PsnType string `json:"psn_type"`
  994. } `json:"insuinfo"`
  995. } `json:"output"`
  996. RefmsgTime string `json:"refmsg_time"`
  997. RespondTime string `json:"respond_time"`
  998. Signtype interface{} `json:"signtype"`
  999. WarnInfo interface{} `json:"warn_info"`
  1000. }
  1001. type ResultThree struct {
  1002. Cainfo interface{} `json:"cainfo"`
  1003. ErrMsg string `json:"err_msg"`
  1004. InfRefmsgid string `json:"inf_refmsgid"`
  1005. Infcode int64 `json:"infcode"`
  1006. Output struct {
  1007. Data struct {
  1008. IptOtpNo string `json:"ipt_otp_no"`
  1009. MdtrtID string `json:"mdtrt_id"`
  1010. PsnNo string `json:"psn_no"`
  1011. } `json:"data"`
  1012. } `json:"output"`
  1013. RefmsgTime string `json:"refmsg_time"`
  1014. RespondTime string `json:"respond_time"`
  1015. Signtype interface{} `json:"signtype"`
  1016. WarnMsg interface{} `json:"warn_msg"`
  1017. }
  1018. type ResultFour struct {
  1019. Cainfo string `json:"cainfo"`
  1020. ErrMsg string `json:"err_msg"`
  1021. InfRefmsgid string `json:"inf_refmsgid"`
  1022. Infcode int64 `json:"infcode"`
  1023. Output struct {
  1024. Result []struct {
  1025. BasMednFlag string `json:"bas_medn_flag"`
  1026. ChldMedcFlag string `json:"chld_medc_flag"`
  1027. ChrgitmLv string `json:"chrgitm_lv"`
  1028. Cnt float64 `json:"cnt"`
  1029. DetItemFeeSumamt float64 `json:"det_item_fee_sumamt"`
  1030. DrtReimFlag string `json:"drt_reim_flag"`
  1031. FeedetlSn string `json:"feedetl_sn"`
  1032. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1033. HiNegoDrugFlag string `json:"hi_nego_drug_flag"`
  1034. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1035. ListSpItemFlag string `json:"list_sp_item_flag"`
  1036. LmtUsedFlag string `json:"lmt_used_flag"`
  1037. MedChrgitmType string `json:"med_chrgitm_type"`
  1038. Memo string `json:"memo"`
  1039. OverlmtAmt float64 `json:"overlmt_amt"`
  1040. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1041. Pric float64 `json:"pric"`
  1042. PricUplmtAmt float64 `json:"pric_uplmt_amt"`
  1043. SelfpayProp float64 `json:"selfpay_prop"`
  1044. } `json:"result"`
  1045. } `json:"output"`
  1046. RefmsgTime string `json:"refmsg_time"`
  1047. RespondTime string `json:"respond_time"`
  1048. Signtype string `json:"signtype"`
  1049. WarnMsg string `json:"warn_msg"`
  1050. }
  1051. type ResultFive struct {
  1052. Balc float64 `json:"balc"`
  1053. CvlservFlag string `json:"cvlserv_flag"`
  1054. EmpName string `json:"emp_name"`
  1055. InsuplcAdmdvs string `json:"insuplc_admdvs"`
  1056. Insutype string `json:"insutype"`
  1057. PausInsuDansuplcAdmdvs string `json:"paus_insu_dansuplc_admdvs"`
  1058. PausInsuDate string `json:"paus_insu_date"`
  1059. PsnInsuDate string `json:"psn_insu_date"`
  1060. PsnInsuStas string `json:"psn_insu_stas"`
  1061. PsnType string `json:"psn_type"`
  1062. }
  1063. type ResultSix struct {
  1064. Cainfo interface{} `json:"cainfo"`
  1065. ErrMsg string `json:"err_msg"`
  1066. InfRefmsgid string `json:"inf_refmsgid"`
  1067. Infcode int64 `json:"infcode"`
  1068. Output struct {
  1069. } `json:"output"`
  1070. RefmsgTime string `json:"refmsg_time"`
  1071. RespondTime string `json:"respond_time"`
  1072. Signtype interface{} `json:"signtype"`
  1073. WarnMsg interface{} `json:"warn_msg"`
  1074. }
  1075. type ResultSeven struct {
  1076. Cainfo string `json:"cainfo"`
  1077. ErrMsg string `json:"err_msg"`
  1078. InfRefmsgid string `json:"inf_refmsgid"`
  1079. Infcode int64 `json:"infcode"`
  1080. Output struct {
  1081. Setldetail []interface{} `json:"setldetail"`
  1082. Setlinfo struct {
  1083. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1084. AcctPay float64 `json:"acct_pay"`
  1085. ActPayDedc float64 `json:"act_pay_dedc"`
  1086. Age float64 `json:"age"`
  1087. Balc float64 `json:"balc"`
  1088. Brdy string `json:"brdy"`
  1089. Certno string `json:"certno"`
  1090. ClrOptins string `json:"clr_optins"`
  1091. ClrType string `json:"clr_type"`
  1092. ClrWay string `json:"clr_way"`
  1093. CvlservFlag string `json:"cvlserv_flag"`
  1094. CvlservPay float64 `json:"cvlserv_pay"`
  1095. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1096. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1097. Gend string `json:"gend"`
  1098. HifesPay float64 `json:"hifes_pay"`
  1099. HifmiPay float64 `json:"hifmi_pay"`
  1100. HifpPay float64 `json:"hifp_pay"`
  1101. HospPartAmt float64 `json:"hosp_part_amt"`
  1102. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1103. Insutype string `json:"insutype"`
  1104. MafPay float64 `json:"maf_pay"`
  1105. MdtrtCertType string `json:"mdtrt_cert_type"`
  1106. HifobPay float64 `json:"hifob_pay"`
  1107. MdtrtID string `json:"mdtrt_id"`
  1108. MedType string `json:"med_type"`
  1109. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1110. MedinsSetlID string `json:"medins_setl_id"`
  1111. Naty string `json:"naty"`
  1112. OthPay float64 `json:"oth_pay"`
  1113. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1114. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1115. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1116. PsnCashPay float64 `json:"psn_cash_pay"`
  1117. PsnCertType string `json:"psn_cert_type"`
  1118. PsnName string `json:"psn_name"`
  1119. PsnNo string `json:"psn_no"`
  1120. PsnPartAmt float64 `json:"psn_part_amt"`
  1121. PsnType string `json:"psn_type"`
  1122. SetlID string `json:"setl_id"`
  1123. SetlTime string `json:"setl_time"`
  1124. } `json:"setlinfo"`
  1125. } `json:"output"`
  1126. RefmsgTime string `json:"refmsg_time"`
  1127. RespondTime string `json:"respond_time"`
  1128. Signtype interface{} `json:"signtype"`
  1129. WarnMsg interface{} `json:"warn_msg"`
  1130. }
  1131. type ResultEight struct {
  1132. Cainfo string `json:"cainfo"`
  1133. ErrMsg string `json:"err_msg"`
  1134. InfRefmsgid string `json:"inf_refmsgid"`
  1135. Infcode int64 `json:"infcode"`
  1136. Output struct {
  1137. Stmtinfo struct {
  1138. SetlOptins string `json:"setl_optins"`
  1139. StmtRslt string `json:"stmt_rslt"`
  1140. StmtRsltDscr string `json:"stmt_rslt_dscr"`
  1141. } `json:"stmtinfo"`
  1142. } `json:"output"`
  1143. RefmsgTime string `json:"refmsg_time"`
  1144. RespondTime string `json:"respond_time"`
  1145. Signtype interface{} `json:"signtype"`
  1146. WarnMsg interface{} `json:"warn_msg"`
  1147. }
  1148. type ResultNine struct {
  1149. Cainfo string `json:"cainfo"`
  1150. ErrMsg string `json:"err_msg"`
  1151. InfRefmsgid string `json:"inf_refmsgid"`
  1152. Infcode int64 `json:"infcode"`
  1153. Output struct {
  1154. FileQuryNo string `json:"file_qury_no"`
  1155. } `json:"output"`
  1156. RefmsgTime string `json:"refmsg_time"`
  1157. RespondTime string `json:"respond_time"`
  1158. Signtype interface{} `json:"signtype"`
  1159. WarnMsg interface{} `json:"warn_msg"`
  1160. }
  1161. type ResultTen struct {
  1162. Cainfo string `json:"cainfo"`
  1163. ErrMsg string `json:"err_msg"`
  1164. InfRefmsgid string `json:"inf_refmsgid"`
  1165. Infcode int64 `json:"infcode"`
  1166. Output struct {
  1167. DldEndtime string `json:"dld_endtime"`
  1168. FileQuryNo string `json:"file_qury_no"`
  1169. Filename string `json:"filename"`
  1170. } `json:"output"`
  1171. RefmsgTime string `json:"refmsg_time"`
  1172. RespondTime string `json:"respond_time"`
  1173. Signtype interface{} `json:"signtype"`
  1174. WarnMsg interface{} `json:"warn_msg"`
  1175. }
  1176. //type Autogenerated struct {
  1177. // Output struct {
  1178. // Setlinfo struct {
  1179. // SetlTime string `json:"setl_time"`
  1180. // CvlservPay float64 `json:"cvlserv_pay"`
  1181. // Year string `json:"year"`
  1182. // MedType string `json:"med_type"`
  1183. // PsnPay float64 `json:"psn_pay"`
  1184. // OpterID string `json:"opter_id"`
  1185. // Begndate string `json:"begndate"`
  1186. // FlxempeFlag string `json:"flxempe_flag"`
  1187. // HifmiPay float64 `json:"hifmi_pay"`
  1188. // PsnNo string `json:"psn_no"`
  1189. // ActPayDedc float64 `json:"act_pay_dedc"`
  1190. // MedinsSetlID interface{} `json:"medins_setl_id"`
  1191. // AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1192. // ClrWay string `json:"clr_way"`
  1193. // OthPay float64 `json:"oth_pay"`
  1194. // Gend string `json:"gend"`
  1195. // MdtrtID string `json:"mdtrt_id"`
  1196. // AcctPay float64 `json:"acct_pay"`
  1197. // InscpScpAmt float64 `json:"inscp_scp_amt"`
  1198. // Insutype string `json:"insutype"`
  1199. // Invono interface{} `json:"invono"`
  1200. // Enddate string `json:"enddate"`
  1201. // CashPayamt float64 `json:"cash_payamt"`
  1202. // PsnType string `json:"psn_type"`
  1203. // FixmedinsName string `json:"fixmedins_name"`
  1204. // HifpPay float64 `json:"hifp_pay"`
  1205. // NewFlag interface{} `json:"new_flag"`
  1206. // OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1207. // PreselfpayAmt float64 `json:"preselfpay_amt"`
  1208. // PayLoc string `json:"pay_loc"`
  1209. // ClrType string `json:"clr_type"`
  1210. // RefdSetlFlag string `json:"refd_setl_flag"`
  1211. // CvlservFlag string `json:"cvlserv_flag"`
  1212. // EmpName string `json:"emp_name"`
  1213. // Brdy string `json:"brdy"`
  1214. // Naty string `json:"naty"`
  1215. // Certno string `json:"certno"`
  1216. // DiseCode string `json:"dise_code"`
  1217. // FixmedinsCode string `json:"fixmedins_code"`
  1218. // DedcHospLv string `json:"dedc_hosp_lv"`
  1219. // OpterName string `json:"opter_name"`
  1220. // Balc float64 `json:"balc"`
  1221. // FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1222. // PsnCertType string `json:"psn_cert_type"`
  1223. // HifobPay float64 `json:"hifob_pay"`
  1224. // MedfeeSumamt float64 `json:"medfee_sumamt"`
  1225. // HifesPay float64 `json:"hifes_pay"`
  1226. // FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1227. // OptTime string `json:"opt_time"`
  1228. // FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1229. // SetlID string `json:"setl_id"`
  1230. // MafPay float64 `json:"maf_pay"`
  1231. // PsnName string `json:"psn_name"`
  1232. // InsuOptins interface{} `json:"insu_optins"`
  1233. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1234. // ClrOptins string `json:"clr_optins"`
  1235. // PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1236. // DiseName string `json:"dise_name"`
  1237. // LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1238. // Age float64 `json:"age"`
  1239. // DtrtCertType string `json:"dtrt_cert_type"`
  1240. // HospLv string `json:"hosp_lv"`
  1241. // } `json:"setlinfo"`
  1242. // Setldetail []struct {
  1243. // FundPayType string `json:"fund_pay_type"`
  1244. // FundPayamt float64 `json:"fund_payamt"`
  1245. // SetlProcInfo interface{} `json:"setl_proc_info"`
  1246. // CrtPaybLmtAmt interface{} `json:"crt_payb_lmt_amt"`
  1247. // InscpScpAmt interface{} `json:"inscp_scp_amt"`
  1248. // FundPayTypeName interface{} `json:"fund_pay_type_name"`
  1249. // PrefFundPay interface{} `json:"pref_fund_pay"`
  1250. // } `json:"setldetail"`
  1251. // } `json:"output"`
  1252. // Infcode int `json:"infcode"`
  1253. // WarnMsg interface{} `json:"warn_msg"`
  1254. // Cainfo interface{} `json:"cainfo"`
  1255. // ErrMsg interface{} `json:"err_msg"`
  1256. // RefmsgTime string `json:"refmsg_time"`
  1257. // Signtype interface{} `json:"signtype"`
  1258. // RespondTime string `json:"respond_time"`
  1259. // InfRefmsgid string `json:"inf_refmsgid"`
  1260. //}
  1261. type ResultEleven struct {
  1262. Cainfo string `json:"cainfo"`
  1263. ErrMsg string `json:"err_msg"`
  1264. InfRefmsgid string `json:"inf_refmsgid"`
  1265. Infcode int64 `json:"infcode"`
  1266. Output struct {
  1267. Setlinfo struct {
  1268. SetlTime string `json:"setl_time"`
  1269. CvlservPay float64 `json:"cvlserv_pay"`
  1270. Year string `json:"year"`
  1271. MedType string `json:"med_type"`
  1272. PsnPay float64 `json:"psn_pay"`
  1273. OpterID string `json:"opter_id"`
  1274. Begndate string `json:"begndate"`
  1275. FlxempeFlag string `json:"flxempe_flag"`
  1276. HifmiPay float64 `json:"hifmi_pay"`
  1277. PsnNo string `json:"psn_no"`
  1278. ActPayDedc float64 `json:"act_pay_dedc"`
  1279. MedinsSetlID interface{} `json:"medins_setl_id"`
  1280. AcctMulaidPay interface{} `json:"acct_mulaid_pay"`
  1281. ClrWay string `json:"clr_way"`
  1282. OthPay float64 `json:"oth_pay"`
  1283. Gend string `json:"gend"`
  1284. MdtrtID string `json:"mdtrt_id"`
  1285. AcctPay float64 `json:"acct_pay"`
  1286. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1287. Insutype string `json:"insutype"`
  1288. Invono interface{} `json:"invono"`
  1289. Enddate string `json:"enddate"`
  1290. CashPayamt float64 `json:"cash_payamt"`
  1291. PsnType string `json:"psn_type"`
  1292. FixmedinsName string `json:"fixmedins_name"`
  1293. HifpPay float64 `json:"hifp_pay"`
  1294. NewFlag interface{} `json:"new_flag"`
  1295. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1296. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1297. PayLoc string `json:"pay_loc"`
  1298. ClrType string `json:"clr_type"`
  1299. RefdSetlFlag string `json:"refd_setl_flag"`
  1300. CvlservFlag string `json:"cvlserv_flag"`
  1301. EmpName string `json:"emp_name"`
  1302. Brdy string `json:"brdy"`
  1303. Naty string `json:"naty"`
  1304. Certno string `json:"certno"`
  1305. DiseCode string `json:"dise_code"`
  1306. FixmedinsCode string `json:"fixmedins_code"`
  1307. DedcHospLv string `json:"dedc_hosp_lv"`
  1308. OpterName string `json:"opter_name"`
  1309. Balc float64 `json:"balc"`
  1310. FixmedinsPoolarea string `json:"fixmedins_poolarea"`
  1311. PsnCertType string `json:"psn_cert_type"`
  1312. HifobPay float64 `json:"hifob_pay"`
  1313. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1314. HifesPay float64 `json:"hifes_pay"`
  1315. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1316. OptTime string `json:"opt_time"`
  1317. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1318. SetlID string `json:"setl_id"`
  1319. MafPay float64 `json:"maf_pay"`
  1320. PsnName string `json:"psn_name"`
  1321. InsuOptins interface{} `json:"insu_optins"`
  1322. PrefFundPay interface{} `json:"pref_fund_pay"`
  1323. ClrOptins string `json:"clr_optins"`
  1324. PoolPropSelfpay float64 `json:"pool_prop_selfpay"`
  1325. DiseName string `json:"dise_name"`
  1326. LmtpricHospLv string `json:"lmtpric_hosp_lv"`
  1327. Age float64 `json:"age"`
  1328. DtrtCertType string `json:"dtrt_cert_type"`
  1329. HospLv string `json:"hosp_lv"`
  1330. } `json:"setlinfo"`
  1331. } `json:"output"`
  1332. RefmsgTime string `json:"refmsg_time"`
  1333. RespondTime string `json:"respond_time"`
  1334. Signtype interface{} `json:"signtype"`
  1335. WarnMsg interface{} `json:"warn_msg"`
  1336. }
  1337. type ResultTwelve struct {
  1338. Cainfo string `json:"cainfo"`
  1339. ErrMsg string `json:"err_msg"`
  1340. InfRefmsgid string `json:"inf_refmsgid"`
  1341. Infcode int64 `json:"infcode"`
  1342. Output struct {
  1343. MdtrtId string `json:"mdtrt_id"`
  1344. ChrgBchno string `json:"chrg_bchno"`
  1345. PsnNo string `json:"psn_no"`
  1346. } `json:"output"`
  1347. RefmsgTime string `json:"refmsg_time"`
  1348. RespondTime string `json:"respond_time"`
  1349. Signtype interface{} `json:"signtype"`
  1350. WarnMsg interface{} `json:"warn_msg"`
  1351. }
  1352. type ResultThirteen struct {
  1353. ErrMsg string `json:"err_msg"`
  1354. InfRefmsgid string `json:"inf_refmsgid"`
  1355. Infcode int64 `json:"infcode"`
  1356. Output struct {
  1357. Result struct {
  1358. TrtDclaDetlSn string `json:"trt_dcla_detl_sn"`
  1359. } `json:"result"`
  1360. } `json:"output"`
  1361. RefmsgTime string `json:"refmsg_time"`
  1362. RespondTime string `json:"respond_time"`
  1363. Signtype interface{} `json:"signtype"`
  1364. WarnInfo interface{} `json:"warn_info"`
  1365. }
  1366. type ResultFourteen struct {
  1367. ErrMsg string `json:"err_msg"`
  1368. InfRefmsgid string `json:"inf_refmsgid"`
  1369. Infcode int64 `json:"infcode"`
  1370. Output struct {
  1371. } `json:"output"`
  1372. RefmsgTime string `json:"refmsg_time"`
  1373. RespondTime string `json:"respond_time"`
  1374. Signtype interface{} `json:"signtype"`
  1375. WarnInfo interface{} `json:"warn_info"`
  1376. }
  1377. type ResultSixteen struct {
  1378. Cainfo string `json:"cainfo"`
  1379. ErrMsg string `json:"err_msg"`
  1380. InfRefmsgid string `json:"inf_refmsgid"`
  1381. Infcode int64 `json:"infcode"`
  1382. Output struct {
  1383. Setldetail []interface{} `json:"setldetail"`
  1384. Setlinfo struct {
  1385. MdtrtID string `json:"mdtrt_id"`
  1386. SetlID string `json:"setl_id"`
  1387. ClrOptins string `json:"clr_optins"`
  1388. SetlTime string `json:"setl_time"`
  1389. MedfeeSumamt float64 `json:"medfee_sumamt"`
  1390. FulamtOwnpayAmt float64 `json:"fulamt_ownpay_amt"`
  1391. OverlmtSelfpay float64 `json:"overlmt_selfpay"`
  1392. PreselfpayAmt float64 `json:"preselfpay_amt"`
  1393. InscpScpAmt float64 `json:"inscp_scp_amt"`
  1394. ActPayDedc float64 `json:"act_pay_dedc"`
  1395. HifpPay float64 `json:"hifp_pay"`
  1396. PoolPropSe float64 `json:"pool_prop_selfpay"`
  1397. Lfpay float64 `json:"selfpay"`
  1398. CvlservPay float64 `json:"cvlserv_pay"`
  1399. HifesPay float64 `json:"hifes_pay"`
  1400. HifmiPay float64 `json:"hifmi_pay"`
  1401. HifobPay float64 `json:"hifob_pay"`
  1402. MafPay float64 `json:"maf_pay"`
  1403. OthPay float64 `json:"oth_pay"`
  1404. FundPaySumamt float64 `json:"fund_pay_sumamt"`
  1405. PsnPartAmt float64 `json:"psn_part_amt"`
  1406. AcctPay float64 `json:"acct_pay"`
  1407. Balc float64 `json:"balc"`
  1408. AcctMulaidPay float64 `json:"acct_mulaid_pay"`
  1409. HospPartAmt float64 `json:"hosp_part_amt"`
  1410. MedinsSetlID string `json:"medins_setl_id"`
  1411. PdnCashPay string `json:"pdn_cash_pay"`
  1412. } `json:"setlinfo"`
  1413. } `json:"output"`
  1414. RefmsgTime string `json:"refmsg_time"`
  1415. RespondTime string `json:"respond_time"`
  1416. Signtype interface{} `json:"signtype"`
  1417. WarnMsg interface{} `json:"warn_msg"`
  1418. }
  1419. type ResultSeventeen struct {
  1420. ErrMsg string `json:"err_msg"`
  1421. InfRefmsgid string `json:"inf_refmsgid"`
  1422. Infcode int64 `json:"infcode"`
  1423. Output struct {
  1424. SetlListId string `json:"setl_list_id"`
  1425. } `json:"output"`
  1426. RefmsgTime string `json:"refmsg_time"`
  1427. RespondTime string `json:"respond_time"`
  1428. Signtype string `json:"signtype"`
  1429. WarnInfo string `json:"warn_info"`
  1430. }
  1431. type Result90991 struct {
  1432. ErrMsg string `json:"err_msg"`
  1433. InfRefmsgid string `json:"inf_refmsgid"`
  1434. Infcode int64 `json:"infcode"`
  1435. Output struct {
  1436. Result struct {
  1437. PsnNo string `json:"psn_no"`
  1438. CardStat string `json:"card_stat"`
  1439. Certno string `json:"certno"`
  1440. PsnName string `json:"psn_name"`
  1441. CheckStat string `json:"check_stat"`
  1442. } `json:"result"`
  1443. } `json:"output"`
  1444. RefmsgTime string `json:"refmsg_time"`
  1445. RespondTime string `json:"respond_time"`
  1446. Signtype interface{} `json:"signtype"`
  1447. WarnInfo interface{} `json:"warn_info"`
  1448. }
  1449. type Custom struct {
  1450. DetItemFeeSumamt string
  1451. Cut string
  1452. FeedetlSn string
  1453. Price string
  1454. MedListCodg string
  1455. Type int64
  1456. AdviceId int64
  1457. ProjectId int64
  1458. ItemId int64
  1459. }
  1460. //获取个人信息----挂号-----上传就诊信息
  1461. func (c *HisApiController) GetRegisterInfo() {
  1462. id, _ := c.GetInt64("id")
  1463. record_time := c.GetString("record_time")
  1464. settlementValue, _ := c.GetInt64("settlement_value")
  1465. medical_insurance_card := c.GetString("medical_insurance_card")
  1466. name := c.GetString("name")
  1467. id_card_type, _ := c.GetInt64("id_card_type")
  1468. certificates, _ := c.GetInt64("certificates")
  1469. medical_care, _ := c.GetInt64("medical_care")
  1470. birthday := c.GetString("birthday")
  1471. //age, _ := c.GetInt64("age")
  1472. id_card := c.GetString("id_card")
  1473. register_type, _ := c.GetInt64("register")
  1474. doctor, _ := c.GetInt64("doctor")
  1475. department, _ := c.GetInt64("department")
  1476. gender, _ := c.GetInt64("sex")
  1477. //phone := c.GetString("phone")
  1478. registration_fee, _ := c.GetFloat("registration_fee")
  1479. medical_expenses, _ := c.GetFloat("medical_expenses")
  1480. social_type, _ := c.GetInt64("social_type")
  1481. admin_user_id, _ := c.GetInt64("admin_user_id")
  1482. timeLayout := "2006-01-02"
  1483. loc, _ := time.LoadLocation("Local")
  1484. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1485. birthUnix := birthdays.Unix()
  1486. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1487. if err != nil {
  1488. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1489. return
  1490. }
  1491. recordDateTime := theTime.Unix()
  1492. adminInfo := c.GetAdminUserInfo()
  1493. var patient service.Patients
  1494. if id == 0 {
  1495. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1496. } else {
  1497. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, id)
  1498. }
  1499. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1500. if patientPrescription.ID == 0 {
  1501. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  1502. }
  1503. //adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, adminInfo.AdminUser.Id)
  1504. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  1505. //sickConfig, _ := service.FindSickById(sick_type)
  1506. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1507. if patient.ID == 0 {
  1508. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1509. return
  1510. }
  1511. if len(patient.IdCardNo) == 0 {
  1512. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1513. return
  1514. }
  1515. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  1516. roles, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1517. //就诊结算未完成,不能进行二次挂号
  1518. his, _ := service.GetHisPatientInfoTwo(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1519. if len(his) >= 1 {
  1520. order, _ := service.GetNewHisOrderTwo(adminInfo.CurrentOrgId, his[len(his)-1].Number, his[len(his)-1].PatientId, recordDateTime)
  1521. if len(his) >= 1 && order.ID == 0 {
  1522. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisPatientParamWrong)
  1523. return
  1524. }
  1525. }
  1526. if config.IsOpen == 1 {
  1527. //service.Gdyb1201("", miConfig.OrgName, "1122", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, 1, "")
  1528. api := "http://127.0.0.1:9532/" + "gdyb/one?cert_no=" + patient.IdCardNo + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&certificates=" + strconv.FormatInt(certificates, 10)
  1529. resp, requestErr := http.Get(api)
  1530. if requestErr != nil {
  1531. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1532. return
  1533. }
  1534. defer resp.Body.Close()
  1535. body, ioErr := ioutil.ReadAll(resp.Body)
  1536. if ioErr != nil {
  1537. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1538. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1539. return
  1540. }
  1541. var respJSON map[string]interface{}
  1542. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1543. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1544. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1545. return
  1546. }
  1547. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1548. userJSONBytes, _ := json.Marshal(userJSON)
  1549. var res ResultTwo
  1550. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1551. utils.ErrorLog("解析失败:%v", err)
  1552. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1553. return
  1554. }
  1555. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  1556. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  1557. infoStr := string(Iinfos)
  1558. idetinfoStr := string(Idetinfos)
  1559. if res.Infcode == 0 {
  1560. his := models.VMHisPatient{
  1561. Name: name,
  1562. Gender: gender,
  1563. Birthday: birthUnix,
  1564. MedicalTreatmentType: medical_care,
  1565. IdType: certificates,
  1566. IdCardNo: id_card,
  1567. BalanceAccountsType: settlementValue,
  1568. SocialType: social_type,
  1569. MedicalInsuranceNumber: medical_insurance_card,
  1570. RegisterType: register_type,
  1571. RegisterCost: registration_fee,
  1572. TreatmentCost: medical_expenses,
  1573. Status: 1,
  1574. Ctime: time.Now().Unix(),
  1575. Mtime: time.Now().Unix(),
  1576. PsnNo: res.Output.Baseinfo.PsnNo,
  1577. PsnCertType: res.Output.Baseinfo.PsnCertType,
  1578. Certno: res.Output.Baseinfo.Certno,
  1579. PsnName: res.Output.Baseinfo.PsnName,
  1580. Gend: res.Output.Baseinfo.Gend,
  1581. Naty: res.Output.Baseinfo.Naty,
  1582. Brdy: res.Output.Baseinfo.Brdy,
  1583. Age: res.Output.Baseinfo.Age,
  1584. Iinfo: infoStr,
  1585. Idetinfo: idetinfoStr,
  1586. PatientId: patient.ID,
  1587. RecordDate: theTime.Unix(),
  1588. UserOrgId: adminInfo.CurrentOrgId,
  1589. AdminUserId: admin_user_id,
  1590. IsReturn: 1,
  1591. IdCardType: id_card_type,
  1592. Doctor: doctor,
  1593. Departments: department,
  1594. }
  1595. timestamp := time.Now().Unix()
  1596. tempTime := time.Unix(timestamp, 0)
  1597. timeFormat := tempTime.Format("20060102150405")
  1598. chrgBchno := rand.Intn(100000) + 10000
  1599. ipt_otp_no := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1600. //count, _ := service.FindHisRegisterRecord(theTime.Unix(), patient.ID, adminInfo.CurrentOrgId)
  1601. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1602. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  1603. IdCardNo := ""
  1604. if id_card_type == 1 {
  1605. IdCardNo = medical_insurance_card
  1606. } else {
  1607. IdCardNo = patient.IdCardNo
  1608. }
  1609. var insutypes []string
  1610. var insutype string
  1611. var is390 int = 0
  1612. var is310 int = 0
  1613. for _, item := range res.Output.Iinfo {
  1614. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  1615. insutypes = append(insutypes, item.Insutype)
  1616. }
  1617. }
  1618. if len(insutypes) == 1 {
  1619. insutype = insutypes[0]
  1620. } else {
  1621. for _, i := range insutypes {
  1622. if i == "390" {
  1623. is390 = 1
  1624. }
  1625. if i == "310" {
  1626. is310 = 1
  1627. }
  1628. }
  1629. }
  1630. if is390 == 1 {
  1631. insutype = "390"
  1632. }
  1633. if is310 == 1 {
  1634. insutype = "310"
  1635. }
  1636. if len(insutypes) == 0 {
  1637. insutype = "310"
  1638. }
  1639. //insutype = "390"
  1640. //if count == 1 {
  1641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1642. // return
  1643. //}
  1644. api := "http://127.0.0.1:9532/" + "gdyb/two?cert_no=" + IdCardNo + "&insutype=" +
  1645. insutype + "&psn_no=" + res.Output.Baseinfo.PsnNo +
  1646. "&org_name=" + miConfig.OrgName + "&doctor=" + patientPrescription.Doctor + "&ipt_otp_no=" + ipt_otp_no +
  1647. "&dept=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&dept_code=" + department.Number + "&doctor_id=" + doctor_id + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&id_card_type=" + strconv.FormatInt(int64(id_card_type), 10)
  1648. resp, requestErr := http.Get(api)
  1649. if requestErr != nil {
  1650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1651. return
  1652. }
  1653. defer resp.Body.Close()
  1654. body, ioErr := ioutil.ReadAll(resp.Body)
  1655. if ioErr != nil {
  1656. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1658. return
  1659. }
  1660. var respJSON map[string]interface{}
  1661. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  1662. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1663. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1664. return
  1665. }
  1666. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1667. userJSONBytes, _ := json.Marshal(respJSON)
  1668. var res ResultThree
  1669. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1670. utils.ErrorLog("解析失败:%v", err)
  1671. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1672. return
  1673. }
  1674. if res.Infcode != 0 {
  1675. adminUser := c.GetAdminUserInfo()
  1676. errlog := &models.HisOrderError{
  1677. UserOrgId: adminUser.CurrentOrgId,
  1678. Ctime: time.Now().Unix(),
  1679. Mtime: time.Now().Unix(),
  1680. ErrMsg: res.ErrMsg,
  1681. Status: 1,
  1682. PatientId: id,
  1683. RecordTime: recordDateTime,
  1684. Stage: 2,
  1685. }
  1686. service.CreateErrMsgLog(errlog)
  1687. c.ServeSuccessJSON(map[string]interface{}{
  1688. "failed_code": -10,
  1689. "msg": res.ErrMsg,
  1690. })
  1691. return
  1692. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterTwoException)
  1693. //return
  1694. }
  1695. his.Number = res.Output.Data.MdtrtID
  1696. his.PsnNo = res.Output.Data.PsnNo
  1697. his.IptOtpNo = res.Output.Data.IptOtpNo
  1698. his.IdCardNo = patient.IdCardNo
  1699. his.PhoneNumber = patient.Phone
  1700. his.UserOrgId = adminInfo.CurrentOrgId
  1701. his.Ctime = time.Now().Unix()
  1702. his.Mtime = time.Now().Unix()
  1703. his.Status = 1
  1704. service.UpdateHisPatientStatus(&his)
  1705. lists, _ := service.GetHisPatientInfoList(adminInfo.CurrentOrgId, patient.ID, recordDateTime)
  1706. if len(lists) == 1 {
  1707. service.UpdateHisPrescriptionHisID(his.ID, patient.ID, recordDateTime, adminInfo.CurrentOrgId)
  1708. }
  1709. c.ServeSuccessJSON(map[string]interface{}{
  1710. "his_info": his,
  1711. })
  1712. } else {
  1713. adminUser := c.GetAdminUserInfo()
  1714. errlog := &models.HisOrderError{
  1715. UserOrgId: adminUser.CurrentOrgId,
  1716. Ctime: time.Now().Unix(),
  1717. Mtime: time.Now().Unix(),
  1718. ErrMsg: res.ErrMsg,
  1719. Status: 1,
  1720. PatientId: id,
  1721. RecordTime: recordDateTime,
  1722. Stage: 1,
  1723. }
  1724. service.CreateErrMsgLog(errlog)
  1725. c.ServeSuccessJSON(map[string]interface{}{
  1726. "failed_code": -10,
  1727. "msg": res.ErrMsg,
  1728. })
  1729. return
  1730. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  1731. }
  1732. }
  1733. }
  1734. //上传明细----预结算----确认订单
  1735. func (c *HisApiController) GetUploadInfo() {
  1736. id, _ := c.GetInt64("id")
  1737. record_time := c.GetString("record_time")
  1738. his_patient_id, _ := c.GetInt64("his_patient_id")
  1739. order_id, _ := c.GetInt64("order_id")
  1740. pay_way, _ := c.GetInt64("pay_way")
  1741. pay_price, _ := c.GetFloat("pay_price")
  1742. pay_card_no := c.GetString("pay_card_no")
  1743. discount_price, _ := c.GetFloat("discount_price")
  1744. preferential_price, _ := c.GetFloat("preferential_price")
  1745. reality_price, _ := c.GetFloat("reality_price")
  1746. found_price, _ := c.GetFloat("found_price")
  1747. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1748. private_price, _ := c.GetFloat("private_price")
  1749. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1750. admin_user_id, _ := c.GetInt64("admin_user_id")
  1751. fapiao_code := c.GetString("fapiao_code")
  1752. fapiao_number := c.GetString("fapiao_number")
  1753. diagnosis_id := c.GetString("diagnosis")
  1754. sick_type, _ := c.GetInt64("sick_type")
  1755. reg_type, _ := c.GetInt64("p_type")
  1756. timeLayout := "2006-01-02"
  1757. loc, _ := time.LoadLocation("Local")
  1758. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1759. if err != nil {
  1760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1761. return
  1762. }
  1763. recordDateTime := theTime.Unix()
  1764. adminUser := c.GetAdminUserInfo()
  1765. var tempOrder models.HisOrder
  1766. tempOrder, _ = service.GetHisOrderByID(order_id)
  1767. var prescriptions []*models.HisPrescription
  1768. var start_time int64
  1769. var end_time int64
  1770. //if adminUser.CurrentOrgId == 10106{
  1771. // if len(fapiao_code) == 0{
  1772. // fapiao_code = "144072080589"
  1773. // }
  1774. // if len(fapiao_number) == 0{
  1775. // order, _ := service.GetLastHisOrder(adminUser.CurrentOrgId)
  1776. // if order.ID == 0{
  1777. // fapiao_number = "00001520"
  1778. // }else{
  1779. // //fapiao_code = "00001520"
  1780. // fpNumber, _ := strconv.Atoi(order.FaPiaoNumber)
  1781. // var zero string
  1782. // if fpNumber >= 1000{
  1783. // zero = "0000" + strconv.Itoa(fpNumber)
  1784. // }else if fpNumber >= 10000{
  1785. // zero = "000" + strconv.Itoa(fpNumber)
  1786. // } else if fpNumber >= 100000{
  1787. // zero = "00" + strconv.Itoa(fpNumber)
  1788. // } else if fpNumber >= 1000000{
  1789. // zero = "0" + strconv.Itoa(fpNumber)
  1790. // }else {
  1791. // zero = strconv.Itoa(fpNumber)
  1792. // }
  1793. // fapiao_number = zero
  1794. // }
  1795. // }
  1796. //}
  1797. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1798. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1799. var patientPrescription models.HisPrescriptionInfo
  1800. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  1801. if patientPrescription.ID == 0 {
  1802. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  1803. }
  1804. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1805. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  1806. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1807. diagnosis_ids := strings.Split(diagnosis_id, ",")
  1808. var config []*models.HisXtDiagnoseConfig
  1809. for _, item := range diagnosis_ids {
  1810. id, _ := strconv.ParseInt(item, 10, 64)
  1811. diagnosisConfig, _ := service.FindDiagnoseById(id)
  1812. config = append(config, diagnosisConfig)
  1813. }
  1814. sickConfig, _ := service.FindSickById(sick_type)
  1815. if tempOrder.ID == 0 {
  1816. tempOrder, _ = service.GetTodayHisOrder(adminUser.CurrentOrgId, id, recordDateTime)
  1817. }
  1818. if tempOrder.ID == 0 {
  1819. var result string
  1820. if miConfig.InsuplcAdmdvs == "440781" { //
  1821. result = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1822. } else {
  1823. result = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  1824. }
  1825. var respJSON2 map[string]interface{}
  1826. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  1827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1829. return
  1830. }
  1831. userJSONBytes2, _ := json.Marshal(respJSON2)
  1832. var res2 ResultSix
  1833. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  1834. utils.ErrorLog("解析失败:%v", err)
  1835. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1836. return
  1837. }
  1838. if res2.Infcode != 0 {
  1839. adminUser := c.GetAdminUserInfo()
  1840. errlog := &models.HisOrderError{
  1841. UserOrgId: adminUser.CurrentOrgId,
  1842. Ctime: time.Now().Unix(),
  1843. Mtime: time.Now().Unix(),
  1844. ErrMsg: res2.ErrMsg,
  1845. Status: 1,
  1846. PatientId: id,
  1847. RecordTime: recordDateTime,
  1848. Stage: 3,
  1849. }
  1850. service.CreateErrMsgLog(errlog)
  1851. c.ServeSuccessJSON(map[string]interface{}{
  1852. "failed_code": -10,
  1853. "msg": res2.ErrMsg,
  1854. })
  1855. return
  1856. } else {
  1857. his.Diagnosis = diagnosis_id
  1858. his.SickType = sickConfig.ID
  1859. his.PType = fmt.Sprintf("%d", reg_type)
  1860. service.UpdateHisPatientThree(&his)
  1861. data := make(map[string]interface{})
  1862. if settle_accounts_type == 1 { //日结
  1863. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  1864. data["pre"] = prescriptions
  1865. } else { //月结
  1866. start_time_str := c.GetString("start_time")
  1867. end_time_str := c.GetString("end_time")
  1868. timeLayout := "2006-01-02"
  1869. loc, _ := time.LoadLocation("Local")
  1870. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1871. if err != nil {
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1873. return
  1874. }
  1875. recordStartTime := theStartTime.Unix()
  1876. start_time = recordStartTime
  1877. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1878. if err != nil {
  1879. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1880. return
  1881. }
  1882. recordEndTime := theEndTime.Unix()
  1883. end_time = recordEndTime
  1884. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  1885. data["pre"] = prescriptions
  1886. }
  1887. timestamp := time.Now().Unix()
  1888. tempTime := time.Unix(timestamp, 0)
  1889. timeFormat := tempTime.Format("20060102150405")
  1890. chrgBchno := rand.Intn(100000) + 10000
  1891. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  1892. strconv.FormatInt(his.PatientId, 10)
  1893. client := &http.Client{}
  1894. data["psn_no"] = his.PsnNo
  1895. data["mdtrt_id"] = his.Number
  1896. data["chrg_bchno"] = chrg_bchno
  1897. data["org_name"] = miConfig.OrgName
  1898. data["doctor"] = roles.UserName
  1899. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  1900. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  1901. data["fixmedins_code"] = miConfig.Code
  1902. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  1903. data["dept_code"] = "15"
  1904. } else {
  1905. data["dept_code"] = department.Number
  1906. }
  1907. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  1908. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  1909. data["secret_key"] = miConfig.SecretKey
  1910. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  1911. var ids []int64
  1912. for _, item := range prescriptions {
  1913. ids = append(ids, item.ID)
  1914. }
  1915. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1916. if config.IsOpen == 1 { //对接了医保,走医保流程
  1917. bytesData, _ := json.Marshal(data)
  1918. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  1919. resp, _ := client.Do(req)
  1920. defer resp.Body.Close()
  1921. body, ioErr := ioutil.ReadAll(resp.Body)
  1922. if ioErr != nil {
  1923. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  1924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1925. return
  1926. }
  1927. var respJSON map[string]interface{}
  1928. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  1929. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  1930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1931. return
  1932. }
  1933. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  1934. userJSONBytes, _ := json.Marshal(respJSON)
  1935. var res ResultFour
  1936. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1937. utils.ErrorLog("解析失败:%v", err)
  1938. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1939. return
  1940. }
  1941. if res.Infcode == 0 {
  1942. order := &models.HisOrder{
  1943. UserOrgId: adminUser.CurrentOrgId,
  1944. HisPatientId: his.ID,
  1945. PatientId: his.PatientId,
  1946. SettleAccountsDate: recordDateTime,
  1947. Ctime: time.Now().Unix(),
  1948. Mtime: time.Now().Unix(),
  1949. Status: 0,
  1950. Number: chrg_bchno,
  1951. Infcode: res.Infcode,
  1952. WarnMsg: res.WarnMsg,
  1953. Cainfo: res.Cainfo,
  1954. ErrMsg: res.ErrMsg,
  1955. RespondTime: res.RefmsgTime,
  1956. InfRefmsgid: res.InfRefmsgid,
  1957. OrderStatus: 1,
  1958. PayWay: pay_way,
  1959. PayPrice: pay_price,
  1960. PayCardNo: pay_card_no,
  1961. DiscountPrice: discount_price,
  1962. PreferentialPrice: preferential_price,
  1963. RealityPrice: reality_price,
  1964. FoundPrice: found_price,
  1965. MedicalInsurancePrice: medical_insurance_price,
  1966. PrivatePrice: private_price,
  1967. IsMedicineInsurance: 1,
  1968. SettleType: settle_accounts_type,
  1969. SettleStartTime: start_time,
  1970. SettleEndTime: end_time,
  1971. Creator: roles.AdminUserId,
  1972. Modify: roles.AdminUserId,
  1973. FaPiaoNumber: fapiao_number,
  1974. FaPiaoCode: fapiao_code,
  1975. PType: 2,
  1976. Diagnosis: diagnosis_id,
  1977. }
  1978. err = service.CreateOrder(order)
  1979. if err != nil {
  1980. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1981. return
  1982. }
  1983. for _, item := range res.Output.Result {
  1984. temp := strings.Split(item.FeedetlSn, "-")
  1985. var advice_id int64 = 0
  1986. var project_id int64 = 0
  1987. var types int64 = 0
  1988. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1989. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1990. if temp[1] == "1" {
  1991. advice_id = id
  1992. project_id = 0
  1993. } else if temp[1] == "2" {
  1994. advice_id = 0
  1995. project_id = id
  1996. }
  1997. info := &models.HisOrderInfo{
  1998. OrderNumber: order.Number,
  1999. FeedetlSn: item.FeedetlSn,
  2000. UploadDate: time.Now().Unix(),
  2001. AdviceId: advice_id,
  2002. DetItemFeeSumamt: item.DetItemFeeSumamt,
  2003. Cnt: item.Cnt,
  2004. Pric: float64(item.Pric),
  2005. PatientId: his.PatientId,
  2006. PricUplmtAmt: item.PricUplmtAmt,
  2007. SelfpayProp: item.SelfpayProp,
  2008. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2009. OverlmtAmt: item.OverlmtAmt,
  2010. PreselfpayAmt: item.PreselfpayAmt,
  2011. BasMednFlag: item.BasMednFlag,
  2012. MedChrgitmType: item.MedChrgitmType,
  2013. HiNegoDrugFlag: item.HiNegoDrugFlag,
  2014. Status: 1,
  2015. Memo: item.Memo,
  2016. Mtime: time.Now().Unix(),
  2017. InscpScpAmt: item.InscpScpAmt,
  2018. DrtReimFlag: item.DrtReimFlag,
  2019. Ctime: time.Now().Unix(),
  2020. ListSpItemFlag: item.ListSpItemFlag,
  2021. ChldMedcFlag: item.ChldMedcFlag,
  2022. LmtUsedFlag: item.LmtUsedFlag,
  2023. ChrgitmLv: item.ChrgitmLv,
  2024. UserOrgId: adminUser.CurrentOrgId,
  2025. HisPatientId: his.ID,
  2026. OrderId: order.ID,
  2027. ProjectId: project_id,
  2028. Type: types,
  2029. }
  2030. service.CreateOrderInfo(info)
  2031. }
  2032. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2033. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  2034. var total float64
  2035. for _, item := range prescriptions {
  2036. if item.Type == 1 { //药品
  2037. for _, subItem := range item.HisDoctorAdviceInfo {
  2038. total = total + (subItem.Price * subItem.PrescribingNumber)
  2039. }
  2040. }
  2041. if item.Type == 2 { //项目
  2042. for _, subItem := range item.HisPrescriptionProject {
  2043. total = total + (subItem.Price * float64(subItem.Count))
  2044. }
  2045. }
  2046. }
  2047. for _, item := range prescriptions {
  2048. for _, subItem := range item.HisAdditionalCharge {
  2049. total = total + (subItem.Price * float64(subItem.Count))
  2050. }
  2051. }
  2052. allTotal := fmt.Sprintf("%.2f", total)
  2053. if res.Infcode == 0 {
  2054. var rf []*ResultFive
  2055. json.Unmarshal([]byte(his.Iinfo), &rf)
  2056. chrg_bchno := chrg_bchno
  2057. cert_no := his.Certno
  2058. var insutypes []string
  2059. var insutype string
  2060. var is390 int = 0
  2061. var is310 int = 0
  2062. for _, item := range rf {
  2063. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2064. insutypes = append(insutypes, item.Insutype)
  2065. }
  2066. }
  2067. if len(insutypes) == 1 {
  2068. insutype = insutypes[0]
  2069. } else {
  2070. for _, i := range insutypes {
  2071. if i == "390" {
  2072. is390 = 1
  2073. }
  2074. if i == "310" {
  2075. is310 = 1
  2076. }
  2077. }
  2078. }
  2079. if is390 == 1 {
  2080. insutype = "390"
  2081. }
  2082. if is310 == 1 {
  2083. insutype = "310"
  2084. }
  2085. if len(insutypes) == 0 {
  2086. insutype = "310"
  2087. }
  2088. //insutype = "390"
  2089. if his.IdCardType == 1 {
  2090. cert_no = his.MedicalInsuranceNumber
  2091. } else {
  2092. cert_no = his.Certno
  2093. }
  2094. result, 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)
  2095. var dat map[string]interface{}
  2096. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2097. fmt.Println(dat)
  2098. } else {
  2099. fmt.Println(err)
  2100. }
  2101. userJSONBytes, _ := json.Marshal(dat)
  2102. var res ResultSeven
  2103. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2104. utils.ErrorLog("解析失败:%v", err)
  2105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2106. return
  2107. }
  2108. if res.Infcode != 0 {
  2109. errlog := &models.HisOrderError{
  2110. UserOrgId: adminUser.CurrentOrgId,
  2111. Ctime: time.Now().Unix(),
  2112. Mtime: time.Now().Unix(),
  2113. Number: chrg_bchno,
  2114. ErrMsg: res.ErrMsg,
  2115. Status: 1,
  2116. PatientId: id,
  2117. RecordTime: recordDateTime,
  2118. Stage: 6,
  2119. }
  2120. service.CreateErrMsgLog(errlog)
  2121. c.ServeSuccessJSON(map[string]interface{}{
  2122. "failed_code": -10,
  2123. "msg": res.ErrMsg,
  2124. })
  2125. return
  2126. } else {
  2127. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2128. order.OrderStatus = 2
  2129. order.Status = 1
  2130. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2131. order.SetlId = res.Output.Setlinfo.SetlID
  2132. order.PsnNo = res.Output.Setlinfo.PsnNo
  2133. order.PsnName = res.Output.Setlinfo.PsnName
  2134. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2135. order.Certno = res.Output.Setlinfo.Certno
  2136. order.Gend = res.Output.Setlinfo.Gend
  2137. order.Naty = res.Output.Setlinfo.Naty
  2138. order.Age = res.Output.Setlinfo.Age
  2139. order.Insutype = res.Output.Setlinfo.Insutype
  2140. order.PsnType = res.Output.Setlinfo.PsnType
  2141. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2142. order.SetlTime = res.Output.Setlinfo.SetlTime
  2143. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2144. order.MedType = res.Output.Setlinfo.MedType
  2145. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2146. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2147. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2148. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2149. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2150. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2151. order.HifpPay = res.Output.Setlinfo.HifpPay
  2152. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2153. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2154. order.HifesPay = res.Output.Setlinfo.HifesPay
  2155. order.HifobPay = res.Output.Setlinfo.HifobPay
  2156. order.MafPay = res.Output.Setlinfo.MafPay
  2157. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2158. order.OthPay = res.Output.Setlinfo.OthPay
  2159. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2160. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2161. order.AcctPay = res.Output.Setlinfo.AcctPay
  2162. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2163. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2164. order.Balc = res.Output.Setlinfo.Balc
  2165. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2166. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2167. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2168. order.ClrWay = res.Output.Setlinfo.ClrWay
  2169. order.Creator = order.Creator
  2170. order.Modify = roles.AdminUserId
  2171. order.RequestLog = src_resquest
  2172. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2173. detailStr := string(setlDetail)
  2174. order.SetlDetail = detailStr
  2175. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2176. err = service.UpDateOrder(order)
  2177. if err == nil {
  2178. c.ServeSuccessJSON(map[string]interface{}{
  2179. "msg": "结算成功",
  2180. })
  2181. } else {
  2182. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2183. return
  2184. }
  2185. }
  2186. } else {
  2187. adminUser := c.GetAdminUserInfo()
  2188. errlog := &models.HisOrderError{
  2189. UserOrgId: adminUser.CurrentOrgId,
  2190. Ctime: time.Now().Unix(),
  2191. Mtime: time.Now().Unix(),
  2192. ErrMsg: res.ErrMsg,
  2193. Status: 1,
  2194. PatientId: id,
  2195. RecordTime: recordDateTime,
  2196. Stage: 4,
  2197. }
  2198. service.CreateErrMsgLog(errlog)
  2199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2200. return
  2201. }
  2202. } else {
  2203. adminUser := c.GetAdminUserInfo()
  2204. errlog := &models.HisOrderError{
  2205. UserOrgId: adminUser.CurrentOrgId,
  2206. Ctime: time.Now().Unix(),
  2207. Mtime: time.Now().Unix(),
  2208. ErrMsg: res.ErrMsg,
  2209. Status: 1,
  2210. PatientId: id,
  2211. RecordTime: recordDateTime,
  2212. Stage: 4,
  2213. }
  2214. service.CreateErrMsgLog(errlog)
  2215. c.ServeSuccessJSON(map[string]interface{}{
  2216. "failed_code": -10,
  2217. "msg": res.ErrMsg,
  2218. })
  2219. return
  2220. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2221. //return
  2222. }
  2223. }
  2224. }
  2225. } else if tempOrder.ID > 0 {
  2226. if tempOrder.IsPre == 1 {
  2227. allTotal := fmt.Sprintf("%.2f", tempOrder.MedfeeSumamt)
  2228. var rf []*ResultFive
  2229. json.Unmarshal([]byte(his.Iinfo), &rf)
  2230. chrg_bchno := tempOrder.Number
  2231. cert_no := his.Certno
  2232. var insutypes []string
  2233. var insutype string
  2234. var is390 int = 0
  2235. var is310 int = 0
  2236. for _, item := range rf {
  2237. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  2238. insutypes = append(insutypes, item.Insutype)
  2239. }
  2240. }
  2241. if len(insutypes) == 1 {
  2242. insutype = insutypes[0]
  2243. } else {
  2244. for _, i := range insutypes {
  2245. if i == "390" {
  2246. is390 = 1
  2247. }
  2248. if i == "310" {
  2249. is310 = 1
  2250. }
  2251. }
  2252. }
  2253. if is390 == 1 {
  2254. insutype = "390"
  2255. }
  2256. if is310 == 1 {
  2257. insutype = "310"
  2258. }
  2259. if len(insutypes) == 0 {
  2260. insutype = "310"
  2261. }
  2262. //insutype = "390"
  2263. if his.IdCardType == 1 {
  2264. cert_no = his.MedicalInsuranceNumber
  2265. } else {
  2266. cert_no = his.Certno
  2267. }
  2268. result, 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, tempOrder.FulamtOwnpayAmt, tempOrder.OverlmtSelfPay, tempOrder.PreselfpayAmt, tempOrder.InscpScpAmt, his.IdType)
  2269. var dat map[string]interface{}
  2270. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2271. fmt.Println(dat)
  2272. } else {
  2273. fmt.Println(err)
  2274. }
  2275. userJSONBytes, _ := json.Marshal(dat)
  2276. var res ResultSeven
  2277. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2278. utils.ErrorLog("解析失败:%v", err)
  2279. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2280. return
  2281. }
  2282. if res.Infcode != 0 {
  2283. errlog := &models.HisOrderError{
  2284. UserOrgId: adminUser.CurrentOrgId,
  2285. Ctime: time.Now().Unix(),
  2286. Mtime: time.Now().Unix(),
  2287. Number: chrg_bchno,
  2288. ErrMsg: res.ErrMsg,
  2289. Status: 1,
  2290. PatientId: id,
  2291. RecordTime: recordDateTime,
  2292. Stage: 6,
  2293. }
  2294. service.CreateErrMsgLog(errlog)
  2295. c.ServeSuccessJSON(map[string]interface{}{
  2296. "failed_code": -10,
  2297. "msg": res.ErrMsg,
  2298. })
  2299. return
  2300. } else {
  2301. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2302. order.OrderStatus = 2
  2303. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2304. order.SetlId = res.Output.Setlinfo.SetlID
  2305. order.PsnNo = res.Output.Setlinfo.PsnNo
  2306. order.PsnName = res.Output.Setlinfo.PsnName
  2307. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2308. order.Certno = res.Output.Setlinfo.Certno
  2309. order.Gend = res.Output.Setlinfo.Gend
  2310. order.Naty = res.Output.Setlinfo.Naty
  2311. order.Age = res.Output.Setlinfo.Age
  2312. order.Insutype = res.Output.Setlinfo.Insutype
  2313. order.PsnType = res.Output.Setlinfo.PsnType
  2314. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2315. order.SetlTime = res.Output.Setlinfo.SetlTime
  2316. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2317. order.MedType = res.Output.Setlinfo.MedType
  2318. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2319. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2320. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2321. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2322. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2323. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2324. order.HifpPay = res.Output.Setlinfo.HifpPay
  2325. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2326. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2327. order.HifesPay = res.Output.Setlinfo.HifesPay
  2328. order.HifobPay = res.Output.Setlinfo.HifobPay
  2329. order.MafPay = res.Output.Setlinfo.MafPay
  2330. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  2331. order.OthPay = res.Output.Setlinfo.OthPay
  2332. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2333. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2334. order.AcctPay = res.Output.Setlinfo.AcctPay
  2335. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2336. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2337. order.Balc = res.Output.Setlinfo.Balc
  2338. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2339. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2340. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2341. order.ClrWay = res.Output.Setlinfo.ClrWay
  2342. order.Creator = order.Creator
  2343. order.Modify = roles.AdminUserId
  2344. order.RequestLog = src_resquest
  2345. order.Diagnosis = diagnosis_id
  2346. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2347. detailStr := string(setlDetail)
  2348. order.SetlDetail = detailStr
  2349. err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2350. err = service.UpDateOrder(order)
  2351. if err == nil {
  2352. c.ServeSuccessJSON(map[string]interface{}{
  2353. "msg": "结算成功",
  2354. })
  2355. } else {
  2356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2357. return
  2358. }
  2359. }
  2360. }
  2361. }
  2362. }
  2363. //func (c *HisApiController) GetPreUploadInfo() {
  2364. // id, _ := c.GetInt64("id")
  2365. // record_time := c.GetString("record_time")
  2366. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2367. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2368. //
  2369. // timeLayout := "2006-01-02"
  2370. // loc, _ := time.LoadLocation("Local")
  2371. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2372. // if err != nil {
  2373. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2374. // return
  2375. // }
  2376. // recordDateTime := theTime.Unix()
  2377. // adminUser := c.GetAdminUserInfo()
  2378. //
  2379. // var prescriptions []*models.HisPrescription
  2380. //
  2381. // var start_time int64
  2382. // var end_time int64
  2383. //
  2384. // data := make(map[string]interface{})
  2385. // if settle_accounts_type == 1 { //日结
  2386. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  2387. // data["pre"] = prescriptions
  2388. //
  2389. // } else { //月结
  2390. // start_time_str := c.GetString("start_time")
  2391. // end_time_str := c.GetString("end_time")
  2392. // timeLayout := "2006-01-02"
  2393. // loc, _ := time.LoadLocation("Local")
  2394. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2395. // if err != nil {
  2396. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2397. // return
  2398. // }
  2399. // recordStartTime := theStartTime.Unix()
  2400. // start_time = recordStartTime
  2401. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2402. // if err != nil {
  2403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2404. // return
  2405. // }
  2406. // recordEndTime := theEndTime.Unix()
  2407. // end_time = recordEndTime
  2408. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  2409. // data["pre"] = prescriptions
  2410. //
  2411. // }
  2412. //
  2413. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2414. //
  2415. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2416. // timestamp := time.Now().Unix()
  2417. // tempTime := time.Unix(timestamp, 0)
  2418. // timeFormat := tempTime.Format("20060102150405")
  2419. // chrgBchno := rand.Intn(100000) + 10000
  2420. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2421. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2422. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2423. // department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2424. // strconv.FormatInt(his.PatientId, 10)
  2425. // client := &http.Client{}
  2426. // data["psn_no"] = his.PsnNo
  2427. // data["mdtrt_id"] = his.Number
  2428. // data["chrg_bchno"] = chrg_bchno
  2429. // data["org_name"] = miConfig.OrgName
  2430. // data["doctor"] = roles.UserName
  2431. // data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  2432. // data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  2433. // data["fixmedins_code"] = miConfig.Code
  2434. // data["dept_code"] = department.Number
  2435. // data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  2436. // data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  2437. // data["secret_key"] = miConfig.SecretKey
  2438. // var ids []int64
  2439. //
  2440. // for _, item := range prescriptions {
  2441. // ids = append(ids, item.ID)
  2442. // }
  2443. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2444. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2445. // bytesData, _ := json.Marshal(data)
  2446. // req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  2447. // resp, _ := client.Do(req)
  2448. // defer resp.Body.Close()
  2449. // body, ioErr := ioutil.ReadAll(resp.Body)
  2450. // if ioErr != nil {
  2451. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2453. // return
  2454. // }
  2455. // var respJSON map[string]interface{}
  2456. // if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  2457. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2458. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2459. // return
  2460. // }
  2461. //
  2462. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2463. // userJSONBytes, _ := json.Marshal(respJSON)
  2464. // var res ResultFour
  2465. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2466. // utils.ErrorLog("解析失败:%v", err)
  2467. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2468. // return
  2469. // }
  2470. //
  2471. // if res.Infcode == 0 {
  2472. // order := &models.HisOrder{
  2473. // UserOrgId: adminUser.CurrentOrgId,
  2474. // HisPatientId: his.ID,
  2475. // PatientId: his.PatientId,
  2476. // SettleAccountsDate: recordDateTime,
  2477. // Ctime: time.Now().Unix(),
  2478. // Mtime: time.Now().Unix(),
  2479. // Status: 1,
  2480. // Number: chrg_bchno,
  2481. // Infcode: res.Infcode,
  2482. // WarnMsg: res.WarnMsg,
  2483. // Cainfo: res.Cainfo,
  2484. // ErrMsg: res.ErrMsg,
  2485. // RespondTime: res.RefmsgTime,
  2486. // InfRefmsgid: res.InfRefmsgid,
  2487. // OrderStatus: 1,
  2488. // IsMedicineInsurance: 1,
  2489. // SettleType: settle_accounts_type,
  2490. // SettleStartTime: start_time,
  2491. // SettleEndTime: end_time,
  2492. // Creator: roles.ID,
  2493. // Modify: roles.ID,
  2494. // PType: 2,
  2495. // }
  2496. // err = service.CreateOrder(order)
  2497. // if err != nil {
  2498. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2499. // return
  2500. // }
  2501. //
  2502. // for _, item := range res.Output.Result {
  2503. // temp := strings.Split(item.FeedetlSn, "-")
  2504. // var advice_id int64 = 0
  2505. // var project_id int64 = 0
  2506. // var types int64 = 0
  2507. //
  2508. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2509. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2510. //
  2511. // if temp[1] == "1" {
  2512. // advice_id = id
  2513. // project_id = 0
  2514. // } else if temp[1] == "2" {
  2515. // advice_id = 0
  2516. // project_id = id
  2517. // }
  2518. //
  2519. // info := &models.HisOrderInfo{
  2520. // OrderNumber: order.Number,
  2521. // FeedetlSn: item.FeedetlSn,
  2522. // UploadDate: time.Now().Unix(),
  2523. // AdviceId: advice_id,
  2524. // DetItemFeeSumamt: item.DetItemFeeSumamt,
  2525. // Cnt: item.Cnt,
  2526. // Pric: float64(item.Pric),
  2527. // PatientId: his.PatientId,
  2528. // PricUplmtAmt: item.PricUplmtAmt,
  2529. // SelfpayProp: item.SelfpayProp,
  2530. // FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  2531. // OverlmtAmt: item.OverlmtAmt,
  2532. // PreselfpayAmt: item.PreselfpayAmt,
  2533. // BasMednFlag: item.BasMednFlag,
  2534. // MedChrgitmType: item.MedChrgitmType,
  2535. // HiNegoDrugFlag: item.HiNegoDrugFlag,
  2536. // Status: 1,
  2537. // Memo: item.Memo,
  2538. // Mtime: time.Now().Unix(),
  2539. // InscpScpAmt: item.InscpScpAmt,
  2540. // DrtReimFlag: item.DrtReimFlag,
  2541. // Ctime: time.Now().Unix(),
  2542. // ListSpItemFlag: item.ListSpItemFlag,
  2543. // ChldMedcFlag: item.ChldMedcFlag,
  2544. // LmtUsedFlag: item.LmtUsedFlag,
  2545. // ChrgitmLv: item.ChrgitmLv,
  2546. // UserOrgId: adminUser.CurrentOrgId,
  2547. // HisPatientId: his.ID,
  2548. // OrderId: order.ID,
  2549. // ProjectId: project_id,
  2550. // Type: types,
  2551. // }
  2552. // service.CreateOrderInfo(info)
  2553. //
  2554. // }
  2555. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2556. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patientPrescription.PatientId, chrg_bchno, recordDateTime)
  2557. //
  2558. // var total float64
  2559. // for _, item := range prescriptions {
  2560. // if item.Type == 1 { //药品
  2561. // for _, subItem := range item.HisDoctorAdviceInfo {
  2562. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2563. // }
  2564. // }
  2565. // if item.Type == 2 { //项目
  2566. // for _, subItem := range item.HisPrescriptionProject {
  2567. // total = total + (subItem.Price * float64(subItem.Count))
  2568. // }
  2569. // }
  2570. // }
  2571. //
  2572. // for _, item := range prescriptions {
  2573. // for _, subItem := range item.HisAdditionalCharge {
  2574. // total = total + (subItem.Price * float64(subItem.Count))
  2575. // }
  2576. // }
  2577. //
  2578. // allTotal := fmt.Sprintf("%.2f", total)
  2579. // if res.Infcode == 0 {
  2580. // var rf []*ResultFive
  2581. // json.Unmarshal([]byte(his.Iinfo), &rf)
  2582. // psn_no := his.PsnNo
  2583. // mdtrt_id := his.Number
  2584. // chrg_bchno := chrg_bchno
  2585. // cert_no := his.Certno
  2586. // insutype := rf[0].Insutype
  2587. //
  2588. // if his.IdCardType == 1 {
  2589. // cert_no = his.MedicalInsuranceNumber
  2590. //
  2591. // } else {
  2592. //
  2593. // cert_no = his.Certno
  2594. //
  2595. // }
  2596. //
  2597. // api := "http://127.0.0.1:9532/" + "gdyb/seven?cert_no=" + cert_no + "&insutype=" +
  2598. // insutype + "&psn_no=" + psn_no + "&chrg_bchno=" + chrg_bchno + "&mdtrt_id=" + mdtrt_id +
  2599. // "&total=" + allTotal + "&org_name=" + miConfig.OrgName + "&doctor=" + roles.UserName + "&fixmedins_code=" + miConfig.Code + "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" +
  2600. // miConfig.SecretKey + "&med_type=" + strconv.FormatInt(patientPrescription.RegisterType, 10) + "&id_card_type=" + strconv.FormatInt(int64(his.IdCardType), 10)
  2601. // resp, requestErr := http.Get(api)
  2602. // if requestErr != nil {
  2603. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2604. // return
  2605. // }
  2606. // defer resp.Body.Close()
  2607. // body, ioErr := ioutil.ReadAll(resp.Body)
  2608. // if ioErr != nil {
  2609. // utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  2610. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2611. // return
  2612. // }
  2613. // var respJSON map[string]interface{}
  2614. // if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  2615. // utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2616. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2617. // return
  2618. // }
  2619. // fmt.Println(respJSON)
  2620. // respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  2621. // userJSONBytes, _ := json.Marshal(respJSON)
  2622. // var res ResultSeven
  2623. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2624. // utils.ErrorLog("解析失败:%v", err)
  2625. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2626. // return
  2627. // }
  2628. // if res.Infcode != 0 {
  2629. // errlog := &models.HisOrderError{
  2630. // UserOrgId: adminUser.CurrentOrgId,
  2631. // Ctime: time.Now().Unix(),
  2632. // Mtime: time.Now().Unix(),
  2633. // Number: chrg_bchno,
  2634. // ErrMsg: res.ErrMsg,
  2635. // Status: 1,
  2636. // PatientId: id,
  2637. // RecordTime: recordDateTime,
  2638. // Stage: 7,
  2639. // }
  2640. // service.CreateErrMsgLog(errlog)
  2641. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2642. // return
  2643. // } else {
  2644. // order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  2645. // order.OrderStatus = 1
  2646. // order.MdtrtId = res.Output.Setlinfo.MdtrtID
  2647. // order.SetlId = res.Output.Setlinfo.SetlID
  2648. // order.PsnNo = res.Output.Setlinfo.PsnNo
  2649. // order.PsnName = res.Output.Setlinfo.PsnName
  2650. // order.PsnCertType = res.Output.Setlinfo.PsnCertType
  2651. // order.Certno = res.Output.Setlinfo.Certno
  2652. // order.Gend = res.Output.Setlinfo.Gend
  2653. // order.Naty = res.Output.Setlinfo.Naty
  2654. // order.Age = res.Output.Setlinfo.Age
  2655. // order.Insutype = res.Output.Setlinfo.Insutype
  2656. // order.PsnType = res.Output.Setlinfo.PsnType
  2657. // order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  2658. // order.SetlTime = res.Output.Setlinfo.SetlTime
  2659. // order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  2660. // order.MedType = res.Output.Setlinfo.MedType
  2661. // order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  2662. // order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  2663. // order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  2664. // order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  2665. // order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  2666. // order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  2667. // order.HifpPay = res.Output.Setlinfo.HifpPay
  2668. // order.CvlservPay = res.Output.Setlinfo.CvlservPay
  2669. // order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  2670. // order.HifesPay = res.Output.Setlinfo.HifesPay
  2671. // order.HifobPay = res.Output.Setlinfo.HifobPay
  2672. // order.MafPay = res.Output.Setlinfo.MafPay
  2673. // order.OthPay = res.Output.Setlinfo.OthPay
  2674. // order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  2675. // order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  2676. // order.AcctPay = res.Output.Setlinfo.AcctPay
  2677. // order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  2678. // order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  2679. // order.Balc = res.Output.Setlinfo.Balc
  2680. // order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  2681. // order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  2682. // order.ClrOptins = res.Output.Setlinfo.ClrOptins
  2683. // order.ClrWay = res.Output.Setlinfo.ClrWay
  2684. // order.Creator = order.Creator
  2685. // order.Modify = roles.ID
  2686. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  2687. // detailStr := string(setlDetail)
  2688. // order.SetlDetail = detailStr
  2689. // //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2690. // err = service.UpDateOrder(order)
  2691. // if err == nil {
  2692. // c.ServeSuccessJSON(map[string]interface{}{
  2693. // "msg": "预结算成功",
  2694. // })
  2695. // } else {
  2696. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2697. // return
  2698. // }
  2699. // }
  2700. // } else {
  2701. // adminUser := c.GetAdminUserInfo()
  2702. // errlog := &models.HisOrderError{
  2703. // UserOrgId: adminUser.CurrentOrgId,
  2704. // Ctime: time.Now().Unix(),
  2705. // Mtime: time.Now().Unix(),
  2706. // ErrMsg: res.ErrMsg,
  2707. // Status: 1,
  2708. // PatientId: id,
  2709. // RecordTime: recordDateTime,
  2710. // Stage: 4,
  2711. // }
  2712. // service.CreateErrMsgLog(errlog)
  2713. //
  2714. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  2715. // return
  2716. // }
  2717. // } else {
  2718. // adminUser := c.GetAdminUserInfo()
  2719. // errlog := &models.HisOrderError{
  2720. // UserOrgId: adminUser.CurrentOrgId,
  2721. // Ctime: time.Now().Unix(),
  2722. // Mtime: time.Now().Unix(),
  2723. // ErrMsg: res.ErrMsg,
  2724. // Status: 1,
  2725. // PatientId: id,
  2726. // RecordTime: recordDateTime,
  2727. // Stage: 4,
  2728. // }
  2729. // service.CreateErrMsgLog(errlog)
  2730. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCalOrderException)
  2731. // return
  2732. // }
  2733. //
  2734. // } else {
  2735. // var total float64
  2736. // for _, item := range prescriptions {
  2737. // if item.Type == 1 { //药品
  2738. // for _, subItem := range item.HisDoctorAdviceInfo {
  2739. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2740. // }
  2741. // }
  2742. // if item.Type == 2 { //项目
  2743. // for _, subItem := range item.HisPrescriptionProject {
  2744. // total = total + (subItem.Price * float64(subItem.Count))
  2745. // }
  2746. // }
  2747. //
  2748. // for _, subItem := range item.HisAdditionalCharge {
  2749. // total = total + (subItem.Price * float64(subItem.Count))
  2750. // }
  2751. // }
  2752. //
  2753. // allTotal := fmt.Sprintf("%.2f", total)
  2754. // totals, _ := strconv.ParseFloat(allTotal, 64)
  2755. // order := &models.HisOrder{
  2756. // UserOrgId: adminUser.CurrentOrgId,
  2757. // HisPatientId: his.ID,
  2758. // PatientId: id,
  2759. // SettleAccountsDate: recordDateTime,
  2760. // Ctime: time.Now().Unix(),
  2761. // Mtime: time.Now().Unix(),
  2762. // Status: 1,
  2763. // OrderStatus: 2,
  2764. // Number: chrg_bchno,
  2765. // MedfeeSumamt: totals,
  2766. // }
  2767. // err = service.CreateOrder(order)
  2768. // if err != nil {
  2769. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2770. // return
  2771. // }
  2772. //
  2773. // var customs []*Custom
  2774. // for _, item := range prescriptions {
  2775. //
  2776. // if item.Type == 1 { //药品
  2777. // for _, subItem := range item.HisDoctorAdviceInfo {
  2778. // cus := &Custom{
  2779. // AdviceId: subItem.ID,
  2780. // ProjectId: 0,
  2781. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber),
  2782. // Cut: fmt.Sprintf("%.2f", subItem.PrescribingNumber),
  2783. // FeedetlSn: subItem.FeedetlSn,
  2784. // Price: fmt.Sprintf("%.2f", subItem.Price),
  2785. // MedListCodg: subItem.MedListCodg,
  2786. // Type: 1,
  2787. // }
  2788. // customs = append(customs, cus)
  2789. // }
  2790. // }
  2791. //
  2792. // if item.Type == 2 { //项目
  2793. // for _, subItem := range item.HisPrescriptionProject {
  2794. //
  2795. // cus := &Custom{
  2796. // AdviceId: 0,
  2797. // ProjectId: subItem.ID,
  2798. // DetItemFeeSumamt: fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)),
  2799. // Cut: fmt.Sprintf("%.2f", float64(subItem.Count)),
  2800. // FeedetlSn: subItem.FeedetlSn,
  2801. // Price: fmt.Sprintf("%.2f", float64(subItem.Price)),
  2802. // MedListCodg: subItem.MedListCodg,
  2803. // Type: 2,
  2804. // }
  2805. //
  2806. // customs = append(customs, cus)
  2807. // }
  2808. // }
  2809. //
  2810. // for _, item := range item.HisAdditionalCharge {
  2811. // cus := &Custom{
  2812. // ItemId: item.ID,
  2813. // AdviceId: 0,
  2814. // ProjectId: 0,
  2815. // DetItemFeeSumamt: fmt.Sprintf("%.2f", item.Price),
  2816. // Cut: fmt.Sprintf("%.2f", float64(item.Count)),
  2817. // FeedetlSn: item.FeedetlSn,
  2818. // Price: fmt.Sprintf("%.2f", float64(item.Price)),
  2819. // MedListCodg: item.XtHisAddtionConfig.Code,
  2820. // Type: 3,
  2821. // }
  2822. //
  2823. // customs = append(customs, cus)
  2824. // }
  2825. //
  2826. // }
  2827. //
  2828. // for _, item := range customs {
  2829. // var advice_id int64 = 0
  2830. // var project_id int64 = 0
  2831. // var item_id int64 = 0
  2832. //
  2833. // var types int64 = 0
  2834. //
  2835. // if item.Type == 1 {
  2836. // advice_id = item.AdviceId
  2837. // project_id = 0
  2838. // item_id = 0
  2839. // } else if item.Type == 2 {
  2840. // advice_id = 0
  2841. // item_id = 0
  2842. //
  2843. // project_id = item.ProjectId
  2844. // } else if item.Type == 3 {
  2845. // advice_id = 0
  2846. // item_id = item.ItemId
  2847. // project_id = 0
  2848. // }
  2849. //
  2850. // detItemFeeSumamt, _ := strconv.ParseFloat(item.DetItemFeeSumamt, 32)
  2851. // cut, _ := strconv.ParseFloat(item.Cut, 32)
  2852. // pric, _ := strconv.ParseFloat(item.Price, 32)
  2853. //
  2854. // info := &models.HisOrderInfo{
  2855. // OrderNumber: order.Number,
  2856. // UploadDate: time.Now().Unix(),
  2857. // AdviceId: advice_id,
  2858. // DetItemFeeSumamt: detItemFeeSumamt,
  2859. // Cnt: cut,
  2860. // Pric: pric,
  2861. // PatientId: id,
  2862. // Status: 1,
  2863. // Mtime: time.Now().Unix(),
  2864. // Ctime: time.Now().Unix(),
  2865. // UserOrgId: adminUser.CurrentOrgId,
  2866. // HisPatientId: his.ID,
  2867. // OrderId: order.ID,
  2868. // ProjectId: project_id,
  2869. // Type: types,
  2870. // ItemId: item_id,
  2871. // }
  2872. // service.CreateOrderInfo(info)
  2873. // }
  2874. // //err := service.UpDateAddtionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2875. // err = service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2876. // err = service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, id, chrg_bchno, recordDateTime)
  2877. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  2878. // if err == nil {
  2879. // c.ServeSuccessJSON(map[string]interface{}{
  2880. // "msg": "结算成功",
  2881. // })
  2882. // } else {
  2883. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  2884. // return
  2885. // }
  2886. // }
  2887. //}
  2888. //上传明细-预结算-
  2889. func (c *HisApiController) GetPreUploadInfo() {
  2890. id, _ := c.GetInt64("id")
  2891. record_time := c.GetString("record_time")
  2892. his_patient_id, _ := c.GetInt64("his_patient_id")
  2893. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2894. admin_user_id, _ := c.GetInt64("admin_user_id")
  2895. diagnosis_id := c.GetString("diagnosis")
  2896. sick_type, _ := c.GetInt64("sick_type")
  2897. reg_type, _ := c.GetInt64("p_type")
  2898. timeLayout := "2006-01-02"
  2899. loc, _ := time.LoadLocation("Local")
  2900. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2901. if err != nil {
  2902. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2903. return
  2904. }
  2905. recordDateTime := theTime.Unix()
  2906. adminUser := c.GetAdminUserInfo()
  2907. diagnosis_ids := strings.Split(diagnosis_id, ",")
  2908. var config []*models.HisXtDiagnoseConfig
  2909. for _, item := range diagnosis_ids {
  2910. id, _ := strconv.ParseInt(item, 10, 64)
  2911. diagnosisConfig, _ := service.FindDiagnoseById(id)
  2912. config = append(config, diagnosisConfig)
  2913. }
  2914. //diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  2915. sickConfig, _ := service.FindSickById(sick_type)
  2916. var prescriptions []*models.HisPrescription
  2917. var start_time int64
  2918. var end_time int64
  2919. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2920. fmt.Println(his_patient_id)
  2921. his, _ := service.GetNewHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2922. timestamp := time.Now().Unix()
  2923. tempTime := time.Unix(timestamp, 0)
  2924. timeFormat := tempTime.Format("20060102150405")
  2925. chrgBchno := rand.Intn(100000) + 10000
  2926. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(his.PatientId, 10)
  2927. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2928. var patientPrescription models.HisPrescriptionInfo
  2929. patientPrescription, _ = service.FindHisPatientPrescriptionInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  2930. if patientPrescription.ID == 0 {
  2931. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  2932. }
  2933. //miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2934. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2935. doctor_info, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2936. strconv.FormatInt(his.PatientId, 10)
  2937. var result string
  2938. if miConfig.InsuplcAdmdvs == "440781" { //
  2939. result = service.Gdyb2203A(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2940. } else {
  2941. result = service.Gdyb2203(his.PsnNo, his.Number, doctor_info.UserName, department.Name, miConfig.OrgName, strconv.FormatInt(reg_type, 10), doctor_info.AdminUserId, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sickConfig.CountryCode, sickConfig.ClassName, roles.UserName, config)
  2942. }
  2943. var respJSON2 map[string]interface{}
  2944. if err := json.Unmarshal([]byte(string(result)), &respJSON2); err != nil {
  2945. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  2946. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2947. return
  2948. }
  2949. userJSONBytes2, _ := json.Marshal(respJSON2)
  2950. var res2 ResultSix
  2951. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  2952. utils.ErrorLog("解析失败:%v", err)
  2953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2954. return
  2955. }
  2956. if res2.Infcode != 0 {
  2957. adminUser := c.GetAdminUserInfo()
  2958. errlog := &models.HisOrderError{
  2959. UserOrgId: adminUser.CurrentOrgId,
  2960. Ctime: time.Now().Unix(),
  2961. Mtime: time.Now().Unix(),
  2962. ErrMsg: res2.ErrMsg,
  2963. Status: 1,
  2964. PatientId: id,
  2965. RecordTime: recordDateTime,
  2966. Stage: 3,
  2967. }
  2968. service.CreateErrMsgLog(errlog)
  2969. c.ServeSuccessJSON(map[string]interface{}{
  2970. "failed_code": -10,
  2971. "msg": res2.ErrMsg,
  2972. })
  2973. return
  2974. } else {
  2975. his.Diagnosis = diagnosis_id
  2976. his.SickType = sickConfig.ID
  2977. his.PType = fmt.Sprintf("%d", reg_type)
  2978. service.UpdateHisPatientThree(&his)
  2979. data := make(map[string]interface{})
  2980. if settle_accounts_type == 1 { //日结
  2981. prescriptions, _ = service.GetNewHisPrescriptionTwo(adminUser.CurrentOrgId, his_patient_id, recordDateTime, reg_type)
  2982. data["pre"] = prescriptions
  2983. } else { //月结
  2984. start_time_str := c.GetString("start_time")
  2985. end_time_str := c.GetString("end_time")
  2986. timeLayout := "2006-01-02"
  2987. loc, _ := time.LoadLocation("Local")
  2988. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2989. if err != nil {
  2990. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2991. return
  2992. }
  2993. recordStartTime := theStartTime.Unix()
  2994. start_time = recordStartTime
  2995. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2996. if err != nil {
  2997. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2998. return
  2999. }
  3000. recordEndTime := theEndTime.Unix()
  3001. end_time = recordEndTime
  3002. prescriptions, _ = service.GetMonthHisPrescriptionTwo(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime, reg_type)
  3003. data["pre"] = prescriptions
  3004. }
  3005. client := &http.Client{}
  3006. data["psn_no"] = his.PsnNo
  3007. data["mdtrt_id"] = his.Number
  3008. data["chrg_bchno"] = chrg_bchno
  3009. data["org_name"] = miConfig.OrgName
  3010. data["doctor"] = roles.UserName
  3011. data["doctor_id"] = strconv.FormatInt(roles.AdminUserId, 10)
  3012. data["dept"] = strconv.FormatInt(patientPrescription.Departments, 10)
  3013. data["fixmedins_code"] = miConfig.Code
  3014. data["balance_accounts_type"] = strconv.FormatInt(his.BalanceAccountsType, 10)
  3015. if (department.ID == 0 && adminUser.CurrentOrgId == 9919) || (department.ID == 0 && adminUser.CurrentOrgId == 10106) {
  3016. data["dept_code"] = "15"
  3017. } else {
  3018. data["dept_code"] = department.Number
  3019. }
  3020. data["insuplc_admdvs"] = miConfig.InsuplcAdmdvs
  3021. data["mdtrtarea_admvs"] = miConfig.MdtrtareaAdmvs
  3022. data["secret_key"] = miConfig.SecretKey
  3023. var ids []int64
  3024. for _, item := range prescriptions {
  3025. ids = append(ids, item.ID)
  3026. }
  3027. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3028. if config.IsOpen == 1 { //对接了医保,走医保流程
  3029. bytesData, _ := json.Marshal(data)
  3030. req, _ := http.NewRequest("POST", "http://127.0.0.1:9532/"+"gdyb/five", bytes.NewReader(bytesData))
  3031. resp, _ := client.Do(req)
  3032. defer resp.Body.Close()
  3033. body, ioErr := ioutil.ReadAll(resp.Body)
  3034. if ioErr != nil {
  3035. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3036. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3037. return
  3038. }
  3039. var respJSON map[string]interface{}
  3040. if err := json.Unmarshal([]byte(body), &respJSON); err != nil {
  3041. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3042. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3043. return
  3044. }
  3045. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3046. userJSONBytes, _ := json.Marshal(respJSON)
  3047. var res ResultFour
  3048. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3049. utils.ErrorLog("解析失败:%v", err)
  3050. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3051. return
  3052. }
  3053. if res.Infcode == 0 {
  3054. order := &models.HisOrder{
  3055. UserOrgId: adminUser.CurrentOrgId,
  3056. HisPatientId: his.ID,
  3057. PatientId: his.PatientId,
  3058. SettleAccountsDate: recordDateTime,
  3059. Ctime: time.Now().Unix(),
  3060. Mtime: time.Now().Unix(),
  3061. Status: 0,
  3062. Number: chrg_bchno,
  3063. Infcode: res.Infcode,
  3064. WarnMsg: res.WarnMsg,
  3065. Cainfo: res.Cainfo,
  3066. ErrMsg: res.ErrMsg,
  3067. RespondTime: res.RefmsgTime,
  3068. InfRefmsgid: res.InfRefmsgid,
  3069. OrderStatus: 1,
  3070. IsMedicineInsurance: 1,
  3071. SettleType: settle_accounts_type,
  3072. SettleStartTime: start_time,
  3073. SettleEndTime: end_time,
  3074. Creator: roles.AdminUserId,
  3075. Modify: roles.AdminUserId,
  3076. PType: 2,
  3077. Diagnosis: diagnosis_id,
  3078. }
  3079. err = service.CreateOrder(order)
  3080. if err != nil {
  3081. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  3082. return
  3083. }
  3084. for _, item := range res.Output.Result {
  3085. temp := strings.Split(item.FeedetlSn, "-")
  3086. var advice_id int64 = 0
  3087. var project_id int64 = 0
  3088. var types int64 = 0
  3089. id, _ := strconv.ParseInt(temp[2], 10, 64)
  3090. types, _ = strconv.ParseInt(temp[1], 10, 64)
  3091. if temp[1] == "1" {
  3092. advice_id = id
  3093. project_id = 0
  3094. } else if temp[1] == "2" {
  3095. advice_id = 0
  3096. project_id = id
  3097. }
  3098. info := &models.HisOrderInfo{
  3099. OrderNumber: order.Number,
  3100. FeedetlSn: item.FeedetlSn,
  3101. UploadDate: time.Now().Unix(),
  3102. AdviceId: advice_id,
  3103. DetItemFeeSumamt: item.DetItemFeeSumamt,
  3104. Cnt: item.Cnt,
  3105. Pric: float64(item.Pric),
  3106. PatientId: his.PatientId,
  3107. PricUplmtAmt: item.PricUplmtAmt,
  3108. SelfpayProp: item.SelfpayProp,
  3109. FulamtOwnpayAmt: item.FulamtOwnpayAmt,
  3110. OverlmtAmt: item.OverlmtAmt,
  3111. PreselfpayAmt: item.PreselfpayAmt,
  3112. BasMednFlag: item.BasMednFlag,
  3113. MedChrgitmType: item.MedChrgitmType,
  3114. HiNegoDrugFlag: item.HiNegoDrugFlag,
  3115. Status: 1,
  3116. Memo: item.Memo,
  3117. Mtime: time.Now().Unix(),
  3118. InscpScpAmt: item.InscpScpAmt,
  3119. DrtReimFlag: item.DrtReimFlag,
  3120. Ctime: time.Now().Unix(),
  3121. ListSpItemFlag: item.ListSpItemFlag,
  3122. ChldMedcFlag: item.ChldMedcFlag,
  3123. LmtUsedFlag: item.LmtUsedFlag,
  3124. ChrgitmLv: item.ChrgitmLv,
  3125. UserOrgId: adminUser.CurrentOrgId,
  3126. HisPatientId: his.ID,
  3127. OrderId: order.ID,
  3128. ProjectId: project_id,
  3129. Type: types,
  3130. }
  3131. service.CreateOrderInfo(info)
  3132. }
  3133. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  3134. service.UpDateHisPrescriptionInfoNumber(adminUser.CurrentOrgId, his_patient_id, chrg_bchno, recordDateTime)
  3135. var total float64
  3136. for _, item := range prescriptions {
  3137. if item.Type == 1 { //药品
  3138. for _, subItem := range item.HisDoctorAdviceInfo {
  3139. total = total + (subItem.Price * subItem.PrescribingNumber)
  3140. }
  3141. }
  3142. if item.Type == 2 { //项目
  3143. for _, subItem := range item.HisPrescriptionProject {
  3144. total = total + (subItem.Price * float64(subItem.Count))
  3145. }
  3146. }
  3147. }
  3148. for _, item := range prescriptions {
  3149. for _, subItem := range item.HisAdditionalCharge {
  3150. total = total + (subItem.Price * float64(subItem.Count))
  3151. }
  3152. }
  3153. allTotal := fmt.Sprintf("%.2f", total)
  3154. if res.Infcode == 0 {
  3155. var rf []*ResultFive
  3156. json.Unmarshal([]byte(his.Iinfo), &rf)
  3157. chrg_bchno := chrg_bchno
  3158. cert_no := his.Certno
  3159. var insutypes []string
  3160. var insutype string
  3161. var is390 int = 0
  3162. var is310 int = 0
  3163. for _, item := range rf {
  3164. if (item.Insutype == "390" && item.PsnInsuStas == "1") || (item.Insutype == "310" && item.PsnInsuStas == "1") {
  3165. insutypes = append(insutypes, item.Insutype)
  3166. }
  3167. }
  3168. if len(insutypes) == 1 {
  3169. insutype = insutypes[0]
  3170. } else {
  3171. for _, i := range insutypes {
  3172. if i == "390" {
  3173. is390 = 1
  3174. }
  3175. if i == "310" {
  3176. is310 = 1
  3177. }
  3178. }
  3179. }
  3180. if is390 == 1 {
  3181. insutype = "390"
  3182. }
  3183. if is310 == 1 {
  3184. insutype = "310"
  3185. }
  3186. if len(insutypes) == 0 {
  3187. insutype = "310"
  3188. }
  3189. //insutype = "390"
  3190. if his.IdCardType == 1 {
  3191. cert_no = his.MedicalInsuranceNumber
  3192. } else {
  3193. cert_no = his.Certno
  3194. }
  3195. result := service.Gdyb2206(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)
  3196. var dat map[string]interface{}
  3197. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3198. fmt.Println(dat)
  3199. } else {
  3200. fmt.Println(err)
  3201. }
  3202. userJSONBytes, _ := json.Marshal(dat)
  3203. var res ResultSeven
  3204. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3205. utils.ErrorLog("解析失败:%v", err)
  3206. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3207. return
  3208. }
  3209. if res.Infcode != 0 {
  3210. errlog := &models.HisOrderError{
  3211. UserOrgId: adminUser.CurrentOrgId,
  3212. Ctime: time.Now().Unix(),
  3213. Mtime: time.Now().Unix(),
  3214. Number: chrg_bchno,
  3215. ErrMsg: res.ErrMsg,
  3216. Status: 1,
  3217. PatientId: id,
  3218. RecordTime: recordDateTime,
  3219. Stage: 20,
  3220. }
  3221. service.CreateErrMsgLog(errlog)
  3222. c.ServeSuccessJSON(map[string]interface{}{
  3223. "failed_code": -10,
  3224. "msg": res.ErrMsg,
  3225. })
  3226. return
  3227. } else {
  3228. order, _ := service.GetHisOrderTwo(adminUser.CurrentOrgId, chrg_bchno, id)
  3229. order.OrderStatus = 1
  3230. order.IsPre = 1
  3231. order.Status = 1
  3232. order.MdtrtId = res.Output.Setlinfo.MdtrtID
  3233. order.SetlId = res.Output.Setlinfo.SetlID
  3234. order.PsnNo = res.Output.Setlinfo.PsnNo
  3235. order.PsnName = res.Output.Setlinfo.PsnName
  3236. order.PsnCertType = res.Output.Setlinfo.PsnCertType
  3237. order.Certno = res.Output.Setlinfo.Certno
  3238. order.Gend = res.Output.Setlinfo.Gend
  3239. order.Naty = res.Output.Setlinfo.Naty
  3240. order.Age = res.Output.Setlinfo.Age
  3241. order.Insutype = res.Output.Setlinfo.Insutype
  3242. order.PsnType = res.Output.Setlinfo.PsnType
  3243. order.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3244. order.SetlTime = res.Output.Setlinfo.SetlTime
  3245. order.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3246. order.MedType = res.Output.Setlinfo.MedType
  3247. order.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3248. order.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3249. order.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3250. order.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3251. order.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3252. order.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3253. order.HifpPay = res.Output.Setlinfo.HifpPay
  3254. order.CvlservPay = res.Output.Setlinfo.CvlservPay
  3255. order.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3256. order.HifesPay = res.Output.Setlinfo.HifesPay
  3257. order.HifobPay = res.Output.Setlinfo.HifobPay
  3258. order.MafPay = res.Output.Setlinfo.MafPay
  3259. order.HifmiPay = res.Output.Setlinfo.HifmiPay
  3260. order.OthPay = res.Output.Setlinfo.OthPay
  3261. order.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3262. order.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3263. order.AcctPay = res.Output.Setlinfo.AcctPay
  3264. order.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3265. order.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3266. order.Balc = res.Output.Setlinfo.Balc
  3267. order.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3268. order.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3269. order.ClrOptins = res.Output.Setlinfo.ClrOptins
  3270. order.ClrWay = res.Output.Setlinfo.ClrWay
  3271. order.Creator = order.Creator
  3272. order.Modify = roles.AdminUserId
  3273. setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3274. detailStr := string(setlDetail)
  3275. order.SetlDetail = detailStr
  3276. //err := service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3277. err = service.UpDateOrder(order)
  3278. if err == nil {
  3279. c.ServeSuccessJSON(map[string]interface{}{
  3280. "msg": "预结算成功",
  3281. })
  3282. } else {
  3283. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3284. return
  3285. }
  3286. }
  3287. } else {
  3288. adminUser := c.GetAdminUserInfo()
  3289. errlog := &models.HisOrderError{
  3290. UserOrgId: adminUser.CurrentOrgId,
  3291. Ctime: time.Now().Unix(),
  3292. Mtime: time.Now().Unix(),
  3293. ErrMsg: res.ErrMsg,
  3294. Status: 1,
  3295. PatientId: id,
  3296. RecordTime: recordDateTime,
  3297. Stage: 4,
  3298. }
  3299. service.CreateErrMsgLog(errlog)
  3300. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3301. return
  3302. }
  3303. } else {
  3304. adminUser := c.GetAdminUserInfo()
  3305. errlog := &models.HisOrderError{
  3306. UserOrgId: adminUser.CurrentOrgId,
  3307. Ctime: time.Now().Unix(),
  3308. Mtime: time.Now().Unix(),
  3309. ErrMsg: res.ErrMsg,
  3310. Status: 1,
  3311. PatientId: id,
  3312. RecordTime: recordDateTime,
  3313. Stage: 4,
  3314. }
  3315. service.CreateErrMsgLog(errlog)
  3316. c.ServeSuccessJSON(map[string]interface{}{
  3317. "failed_code": -10,
  3318. "msg": res.ErrMsg,
  3319. })
  3320. return
  3321. }
  3322. }
  3323. }
  3324. }
  3325. //func (c *HisApiController) GetSettleInfo() {
  3326. // id, _ := c.GetInt64("id")
  3327. // order_id, _ := c.GetInt64("order_id")
  3328. //
  3329. // record_time := c.GetString("record_time")
  3330. // pay_way, _ := c.GetInt64("pay_way")
  3331. // pay_price, _ := c.GetFloat("pay_price")
  3332. // pay_card_no := c.GetString("pay_card_no")
  3333. // discount_price, _ := c.GetFloat("discount_price")
  3334. // preferential_price, _ := c.GetFloat("preferential_price")
  3335. // reality_price, _ := c.GetFloat("reality_price")
  3336. // found_price, _ := c.GetFloat("found_price")
  3337. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  3338. // private_price, _ := c.GetFloat("private_price")
  3339. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  3340. // admin_user_id, _ := c.GetInt64("admin_user_id")
  3341. //
  3342. // timeLayout := "2006-01-02"
  3343. // loc, _ := time.LoadLocation("Local")
  3344. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3345. // if err != nil {
  3346. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3347. // return
  3348. // }
  3349. // recordDateTime := theTime.Unix()
  3350. // adminUser := c.GetAdminUserInfo()
  3351. //
  3352. // var prescriptions []*models.HisPrescription
  3353. //
  3354. // data := make(map[string]interface{})
  3355. // if settle_accounts_type == 1 { //日结
  3356. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, id, recordDateTime)
  3357. // data["pre"] = prescriptions
  3358. //
  3359. // } else { //月结
  3360. // start_time_str := c.GetString("start_time")
  3361. // end_time_str := c.GetString("end_time")
  3362. // timeLayout := "2006-01-02"
  3363. // loc, _ := time.LoadLocation("Local")
  3364. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  3365. // if err != nil {
  3366. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3367. // return
  3368. // }
  3369. // recordStartTime := theStartTime.Unix()
  3370. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  3371. // if err != nil {
  3372. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3373. // return
  3374. // }
  3375. // recordEndTime := theEndTime.Unix()
  3376. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, id, recordStartTime, recordEndTime)
  3377. // data["pre"] = prescriptions
  3378. //
  3379. // }
  3380. //
  3381. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3382. //
  3383. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3384. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3385. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, id, recordDateTime)
  3386. // strconv.FormatInt(his.PatientId, 10)
  3387. //
  3388. // order_src, _ := service.GetHisOrderByID(order_id)
  3389. //
  3390. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3391. // if config.IsOpen == 1 { //对接了医保,走医保流程
  3392. //
  3393. // var total float64
  3394. // for _, item := range prescriptions {
  3395. // if item.Type == 1 { //药品
  3396. // for _, subItem := range item.HisDoctorAdviceInfo {
  3397. // total = total + (subItem.Price * subItem.PrescribingNumber)
  3398. // }
  3399. // }
  3400. // if item.Type == 2 { //项目
  3401. // for _, subItem := range item.HisPrescriptionProject {
  3402. // total = total + (subItem.Price * float64(subItem.Count))
  3403. // }
  3404. // }
  3405. // }
  3406. //
  3407. // for _, item := range prescriptions {
  3408. // for _, subItem := range item.HisAdditionalCharge {
  3409. // total = total + (subItem.Price * float64(subItem.Count))
  3410. // }
  3411. // }
  3412. //
  3413. // allTotal := fmt.Sprintf("%.2f", total)
  3414. // var rf []*ResultFive
  3415. // json.Unmarshal([]byte(his.Iinfo), &rf)
  3416. // psn_no := order_src.PsnNo
  3417. // mdtrt_id := order_src.MdtrtId
  3418. // chrg_bchno := order_src.Number
  3419. // cert_no := order_src.Certno
  3420. // insutype := rf[0].Insutype
  3421. //
  3422. // if his.IdCardType == 1 {
  3423. // cert_no = his.MedicalInsuranceNumber
  3424. // } else {
  3425. // cert_no = his.Certno
  3426. // }
  3427. //
  3428. // 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)
  3429. // var dat map[string]interface{}
  3430. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3431. // fmt.Println(dat)
  3432. // } else {
  3433. // fmt.Println(err)
  3434. // }
  3435. //
  3436. // userJSONBytes, _ := json.Marshal(dat)
  3437. //
  3438. //
  3439. //
  3440. // var res ResultSeven
  3441. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3442. // utils.ErrorLog("解析失败:%v", err)
  3443. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3444. // return
  3445. // }
  3446. // if res.Infcode == -1 {
  3447. // errlog := &models.HisOrderError{
  3448. // UserOrgId: adminUser.CurrentOrgId,
  3449. // Ctime: time.Now().Unix(),
  3450. // Mtime: time.Now().Unix(),
  3451. // Number: chrg_bchno,
  3452. // ErrMsg: res.ErrMsg,
  3453. // Status: 1,
  3454. // PatientId: id,
  3455. // RecordTime: recordDateTime,
  3456. // Stage: 6,
  3457. // }
  3458. // service.CreateErrMsgLog(errlog)
  3459. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  3460. // return
  3461. // } else {
  3462. // order_src.OrderStatus = 2
  3463. // order_src.PayWay = pay_way
  3464. // order_src.PayPrice = pay_price
  3465. // order_src.PayCardNo = pay_card_no
  3466. // order_src.DiscountPrice = discount_price
  3467. // order_src.PreferentialPrice = preferential_price
  3468. // order_src.RealityPrice = reality_price
  3469. // order_src.FoundPrice = found_price
  3470. // order_src.MedicalInsurancePrice = medical_insurance_price
  3471. // order_src.PrivatePrice = private_price
  3472. // order_src.MdtrtId = res.Output.Setlinfo.MdtrtID
  3473. // order_src.SetlId = res.Output.Setlinfo.SetlID
  3474. // order_src.PsnNo = res.Output.Setlinfo.PsnNo
  3475. // order_src.PsnName = res.Output.Setlinfo.PsnName
  3476. // order_src.PsnCertType = res.Output.Setlinfo.PsnCertType
  3477. // order_src.Certno = res.Output.Setlinfo.Certno
  3478. // order_src.Gend = res.Output.Setlinfo.Gend
  3479. // order_src.Naty = res.Output.Setlinfo.Naty
  3480. // order_src.Age = res.Output.Setlinfo.Age
  3481. // order_src.Insutype = res.Output.Setlinfo.Insutype
  3482. // order_src.PsnType = res.Output.Setlinfo.PsnType
  3483. // order_src.CvlservFlag = res.Output.Setlinfo.CvlservFlag
  3484. // order_src.SetlTime = res.Output.Setlinfo.SetlTime
  3485. // order_src.MdtrtCertType = res.Output.Setlinfo.MdtrtCertType
  3486. // order_src.MedType = res.Output.Setlinfo.MedType
  3487. // order_src.MedfeeSumamt = res.Output.Setlinfo.MedfeeSumamt
  3488. // order_src.FulamtOwnpayAmt = res.Output.Setlinfo.FulamtOwnpayAmt
  3489. // order_src.OverlmtSelfPay = res.Output.Setlinfo.OverlmtSelfpay
  3490. // order_src.PreselfpayAmt = res.Output.Setlinfo.PreselfpayAmt
  3491. // order_src.InscpScpAmt = res.Output.Setlinfo.InscpScpAmt
  3492. // order_src.ActPayDedc = res.Output.Setlinfo.ActPayDedc
  3493. // order_src.HifpPay = res.Output.Setlinfo.HifpPay
  3494. // order_src.CvlservPay = res.Output.Setlinfo.CvlservPay
  3495. // order_src.PoolPropSelfpay = res.Output.Setlinfo.PoolPropSelfpay
  3496. // order_src.HifesPay = res.Output.Setlinfo.HifesPay
  3497. // order_src.HifobPay = res.Output.Setlinfo.HifobPay
  3498. // order_src.MafPay = res.Output.Setlinfo.MafPay
  3499. // order_src.OthPay = res.Output.Setlinfo.OthPay
  3500. // order_src.FundPaySumamt = res.Output.Setlinfo.FundPaySumamt
  3501. // order_src.PsnPartAmt = res.Output.Setlinfo.PsnPartAmt
  3502. // order_src.AcctPay = res.Output.Setlinfo.AcctPay
  3503. // order_src.PsnCashPay = res.Output.Setlinfo.PsnCashPay
  3504. // order_src.HospPartAmt = res.Output.Setlinfo.HospPartAmt
  3505. // order_src.Balc = res.Output.Setlinfo.Balc
  3506. // order_src.AcctMulaidPay = res.Output.Setlinfo.AcctMulaidPay
  3507. // order_src.MedinsSetlId = res.Output.Setlinfo.MedinsSetlID
  3508. // order_src.ClrOptins = res.Output.Setlinfo.ClrOptins
  3509. // order_src.ClrWay = res.Output.Setlinfo.ClrWay
  3510. // order_src.Creator = order_src.Creator
  3511. // order_src.Modify = roles.ID
  3512. // order_src.RequestLog = src_resquest
  3513. // setlDetail, _ := json.Marshal(res.Output.Setldetail)
  3514. // detailStr := string(setlDetail)
  3515. // order_src.SetlDetail = detailStr
  3516. // err = service.UpdataOrderStatusTwo(chrg_bchno, adminUser.CurrentOrgId)
  3517. // err = service.UpDateOrder(order_src)
  3518. //
  3519. // if err == nil {
  3520. // c.ServeSuccessJSON(map[string]interface{}{
  3521. // "msg": "结算成功",
  3522. // })
  3523. // } else {
  3524. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeAmountAccountException)
  3525. // return
  3526. // }
  3527. // }
  3528. // }
  3529. //}
  3530. //退款
  3531. func (c *HisApiController) Refund() {
  3532. order_id, _ := c.GetInt64("order_id")
  3533. admin_user_id, _ := c.GetInt64("admin_user_id")
  3534. //record_time := c.GetString("record_time")
  3535. //patient_id, _ := c.GetInt64("patient_id")
  3536. //timeLayout := "2006-01-02"
  3537. //loc, _ := time.LoadLocation("Local")
  3538. adminUser := c.GetAdminUserInfo()
  3539. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3540. //if err != nil {
  3541. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3542. // return
  3543. //}
  3544. //recordDateTime := theTime.Unix()
  3545. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3546. var order models.HisOrder
  3547. order, _ = service.GetHisOrderByID(order_id)
  3548. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3549. if order.ID == 0 {
  3550. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3551. return
  3552. //order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3553. }
  3554. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3555. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3556. if config.IsOpen == 1 { //对接了医保,走医保流程
  3557. result, src_resquest := service.Gdyb2208(order.PsnNo, order.MdtrtId, order.SetlId, miConfig.OrgName, roles.UserName, miConfig.SecretKey, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs)
  3558. var dat map[string]interface{}
  3559. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3560. fmt.Println(dat)
  3561. } else {
  3562. fmt.Println(err)
  3563. }
  3564. userJSONBytes, _ := json.Marshal(dat)
  3565. var res ResultSixteen
  3566. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3567. utils.ErrorLog("解析失败:%v", err)
  3568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3569. return
  3570. }
  3571. if res.Infcode == 0 {
  3572. result := service.Gdyb2205(order.PsnNo, order.MdtrtId, order.Number, miConfig.OrgName, roles.UserName, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, miConfig.Code)
  3573. var dat map[string]interface{}
  3574. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3575. fmt.Println(dat)
  3576. } else {
  3577. fmt.Println(err)
  3578. }
  3579. userJSONBytes, _ := json.Marshal(dat)
  3580. var res2 ResultSix
  3581. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  3582. utils.ErrorLog("解析失败:%v", err)
  3583. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3584. return
  3585. }
  3586. if res2.Infcode == 0 {
  3587. err := service.UpdataOrderStatus(order_id, order.Number, adminUser.CurrentOrgId, src_resquest, result)
  3588. if err == nil {
  3589. c.ServeSuccessJSON(map[string]interface{}{
  3590. "msg": "退费成功",
  3591. })
  3592. } else {
  3593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3594. return
  3595. }
  3596. } else {
  3597. c.ServeSuccessJSON(map[string]interface{}{
  3598. "code": -10,
  3599. "msg": res2.ErrMsg,
  3600. })
  3601. }
  3602. } else {
  3603. c.ServeSuccessJSON(map[string]interface{}{
  3604. "code": -10,
  3605. "msg": res.ErrMsg,
  3606. })
  3607. }
  3608. }
  3609. }
  3610. func (c *HisApiController) RefundNumber() {
  3611. record_time := c.GetString("record_time")
  3612. //patient_id, _ := c.GetInt64("patient_id")
  3613. admin_user_id, _ := c.GetInt64("admin_user_id")
  3614. his_patient_id, _ := c.GetInt64("id")
  3615. timeLayout := "2006-01-02"
  3616. loc, _ := time.LoadLocation("Local")
  3617. adminUser := c.GetAdminUserInfo()
  3618. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3619. fmt.Println(err)
  3620. if err != nil {
  3621. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3622. return
  3623. }
  3624. recordDateTime := theTime.Unix()
  3625. //his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3626. his, _ := service.GetHisPatientRecord(adminUser.CurrentOrgId, his_patient_id)
  3627. //patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3628. //order, _ := service.GetHisOrderByID(order_id)
  3629. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3630. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3631. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3632. if config.IsOpen == 1 { //对接了医保,走医保流程
  3633. api3 := "http://127.0.0.1:9532/" + "gdyb/three?psn_no=" + his.PsnNo +
  3634. "&mdtrt_id=" + his.Number + "&ipt_otp_no=" + his.IptOtpNo + "&doctor=" + roles.UserName + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3635. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3636. resp3, requestErr3 := http.Get(api3)
  3637. if requestErr3 != nil {
  3638. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3639. return
  3640. }
  3641. body3, ioErr3 := ioutil.ReadAll(resp3.Body)
  3642. if ioErr3 != nil {
  3643. utils.ErrorLog("接口返回数据读取失败: %v", ioErr3)
  3644. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3645. return
  3646. }
  3647. var respJSON3 map[string]interface{}
  3648. if err := json.Unmarshal([]byte(string(body3)), &respJSON3); err != nil {
  3649. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3650. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3651. return
  3652. }
  3653. respJSON3 = respJSON3["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3654. userJSONBytes3, _ := json.Marshal(respJSON3)
  3655. var res2 ResultSix
  3656. if err := json.Unmarshal(userJSONBytes3, &res2); err != nil {
  3657. utils.ErrorLog("解析失败:%v", err)
  3658. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3659. return
  3660. }
  3661. if res2.Infcode == 0 {
  3662. if err == nil {
  3663. c.ServeSuccessJSON(map[string]interface{}{
  3664. "msg": "退号成功",
  3665. })
  3666. service.UpdataRegStatusTwo(his_patient_id, recordDateTime, adminUser.CurrentOrgId)
  3667. } else {
  3668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3669. return
  3670. }
  3671. } else {
  3672. c.ServeSuccessJSON(map[string]interface{}{
  3673. "code": -10,
  3674. "msg": res2.ErrMsg,
  3675. })
  3676. }
  3677. } else {
  3678. //err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId)
  3679. //if err == nil {
  3680. // c.ServeSuccessJSON(map[string]interface{}{
  3681. // "msg": "退费成功",
  3682. // })
  3683. //} else {
  3684. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3685. // return
  3686. //}
  3687. }
  3688. }
  3689. func (c *HisApiController) RefundDetail() {
  3690. order_id, _ := c.GetInt64("order_id")
  3691. his_patient_id, _ := c.GetInt64("his_patient_id")
  3692. number := c.GetString("number")
  3693. record_time := c.GetString("record_time")
  3694. patient_id, _ := c.GetInt64("patient_id")
  3695. timeLayout := "2006-01-02"
  3696. loc, _ := time.LoadLocation("Local")
  3697. adminUser := c.GetAdminUserInfo()
  3698. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  3699. fmt.Println(err)
  3700. if err != nil {
  3701. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3702. return
  3703. }
  3704. recordDateTime := theTime.Unix()
  3705. his, _ := service.GetNewVMHisPatientInfo(adminUser.CurrentOrgId, his_patient_id, recordDateTime)
  3706. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  3707. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3708. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3709. var order models.HisOrder
  3710. order, _ = service.GetHisOrderByID(order_id)
  3711. if order.ID == 0 {
  3712. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  3713. }
  3714. if config.IsOpen == 1 { //对接了医保,走医保流程
  3715. api2 := "http://127.0.0.1:9532/" + "gdyb/six?psn_no=" + his.PsnNo +
  3716. "&mdtrt_id=" + his.Number + "&chrg_bchno=" + order.Number + "&doctor=" + patientPrescription.Doctor + "&org_name=" + miConfig.OrgName + "&fixmedins_code=" + miConfig.Code +
  3717. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey
  3718. resp2, requestErr2 := http.Get(api2)
  3719. if requestErr2 != nil {
  3720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3721. return
  3722. }
  3723. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  3724. if ioErr2 != nil {
  3725. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  3726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3727. return
  3728. }
  3729. var respJSON2 map[string]interface{}
  3730. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  3731. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3732. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3733. return
  3734. }
  3735. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3736. if err == nil {
  3737. c.ServeSuccessJSON(map[string]interface{}{
  3738. "msg": "退费成功",
  3739. })
  3740. } else {
  3741. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3742. return
  3743. }
  3744. } else {
  3745. err := service.UpdataOrderStatus(order_id, number, adminUser.CurrentOrgId, "", "")
  3746. if err == nil {
  3747. c.ServeSuccessJSON(map[string]interface{}{
  3748. "msg": "退费成功",
  3749. })
  3750. } else {
  3751. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3752. return
  3753. }
  3754. }
  3755. }
  3756. //对账
  3757. func (c *HisApiController) GetCheckAccount() {
  3758. start_time := c.GetString("start_time")
  3759. end_time := c.GetString("end_time")
  3760. insutype := c.GetString("insutype")
  3761. clr_type := c.GetString("clr_type")
  3762. admin_user_id, _ := c.GetInt64("admin_user_id")
  3763. adminUser := c.GetAdminUserInfo()
  3764. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3765. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3766. timeLayout := "2006-01-02"
  3767. loc, _ := time.LoadLocation("Local")
  3768. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3769. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3770. orders, _ := service.GetOrderByTime(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3771. //orders_two, _ := service.GetOrderByTimeThree(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId, insutype, clr_type)
  3772. fixmedins_setl_cnt := int64(len(orders))
  3773. //
  3774. ////撤销的算2条数据为一笔
  3775. //for _, item := range orders_two {
  3776. // if item.OrderStatus == 3 {
  3777. // fixmedins_setl_cnt = fixmedins_setl_cnt + 1
  3778. // }
  3779. //}
  3780. var medfee_sumamt float64
  3781. var acct_pay float64
  3782. var fund_pay_sumamt float64
  3783. for _, item := range orders {
  3784. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  3785. acct_pay = acct_pay + item.AcctPay
  3786. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  3787. }
  3788. var user_name string
  3789. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  3790. if role.ID == 0 {
  3791. user_name = "xxx"
  3792. } else {
  3793. user_name = role.UserName
  3794. }
  3795. if config.IsOpen == 1 {
  3796. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3797. "insutype=" + insutype +
  3798. "&clr_type=" + clr_type +
  3799. "&setl_optins=" + "定点医保中心" +
  3800. "&stmt_begndate=" + start_time +
  3801. "&stm_enddate=" + end_time +
  3802. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  3803. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  3804. "&acct_pay=" + fmt.Sprintf("%.2f", acct_pay) +
  3805. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  3806. "&fixmedins_code=" + miConfig.Code +
  3807. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3808. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3809. "&secret_key=" + miConfig.SecretKey +
  3810. "&org_name=" + miConfig.OrgName +
  3811. "&doctor=" + user_name
  3812. fmt.Println(api)
  3813. resp, requestErr := http.Get(api)
  3814. if requestErr != nil {
  3815. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3816. return
  3817. }
  3818. body, ioErr := ioutil.ReadAll(resp.Body)
  3819. fmt.Println(body)
  3820. if ioErr != nil {
  3821. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3822. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3823. return
  3824. }
  3825. var respJSON map[string]interface{}
  3826. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3827. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3829. return
  3830. }
  3831. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3832. userJSONBytes, _ := json.Marshal(respJSON)
  3833. var res ResultEight
  3834. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3835. utils.ErrorLog("解析失败:%v", err)
  3836. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3837. return
  3838. }
  3839. if res.Infcode == 0 {
  3840. if res.Output.Stmtinfo.StmtRslt == "0" {
  3841. micc := &models.MedicalInsuranceCostCompare{
  3842. StartTime: startime.Unix(),
  3843. EndTime: endtime.Unix(),
  3844. Insutype: insutype,
  3845. CheckType: 1,
  3846. Num: fixmedins_setl_cnt,
  3847. Mtime: time.Now().Unix(),
  3848. Status: 1,
  3849. UserOrgId: adminUser.CurrentOrgId,
  3850. CostTotal: medfee_sumamt,
  3851. FuncTotal: fund_pay_sumamt,
  3852. PsnPay: acct_pay,
  3853. Creator: admin_user_id,
  3854. Ctime: time.Now().Unix(),
  3855. }
  3856. err := service.CreateMedicalInsuranceCostCompareRecord(micc)
  3857. if err == nil {
  3858. c.ServeSuccessJSON(map[string]interface{}{
  3859. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3860. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3861. })
  3862. } else {
  3863. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3864. }
  3865. } else {
  3866. c.ServeSuccessJSON(map[string]interface{}{
  3867. "stmt_rslt": res.Output.Stmtinfo.StmtRslt,
  3868. "stmt_rslt_dscr": res.Output.Stmtinfo.StmtRsltDscr,
  3869. })
  3870. }
  3871. } else {
  3872. c.ServeSuccessJSON(map[string]interface{}{
  3873. "code": -10,
  3874. "msg": res.ErrMsg,
  3875. })
  3876. }
  3877. }
  3878. }
  3879. func (c *HisApiController) Check310() {
  3880. adminUser := c.GetAdminUserInfo()
  3881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3882. var user_name string
  3883. user_name = "xxx"
  3884. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3885. "insutype=" + "310" +
  3886. "&clr_type=" + "11" +
  3887. "&setl_optins=" + "定点医保中心" +
  3888. "&stmt_begndate=" + "2021-03-01" +
  3889. "&stm_enddate=" + "2021-03-31" +
  3890. "&medfee_sumamt=" + "11521" +
  3891. "&fund_pay_sumamt=" + "10166.66" +
  3892. "&acct_pay=" + "0" +
  3893. "&fixmedins_setl_cnt=" + "7" +
  3894. "&fixmedins_code=" + miConfig.Code +
  3895. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3896. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3897. "&secret_key=" + miConfig.SecretKey +
  3898. "&org_name=" + miConfig.OrgName +
  3899. "&doctor=" + user_name
  3900. fmt.Println(api)
  3901. resp, requestErr := http.Get(api)
  3902. if requestErr != nil {
  3903. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3904. return
  3905. }
  3906. body, ioErr := ioutil.ReadAll(resp.Body)
  3907. fmt.Println(body)
  3908. if ioErr != nil {
  3909. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3910. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3911. return
  3912. }
  3913. var respJSON map[string]interface{}
  3914. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3915. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3917. return
  3918. }
  3919. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3920. userJSONBytes, _ := json.Marshal(respJSON)
  3921. var res ResultEight
  3922. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3923. utils.ErrorLog("解析失败:%v", err)
  3924. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3925. return
  3926. }
  3927. }
  3928. func (c *HisApiController) Check390() {
  3929. adminUser := c.GetAdminUserInfo()
  3930. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3931. var user_name string
  3932. user_name = "张俊杰"
  3933. api := "http://127.0.0.1:9532/" + "gdyb/ten?" +
  3934. "insutype=" + "390" +
  3935. "&clr_type=" + "11" +
  3936. "&setl_optins=" + "定点医保中心" +
  3937. "&stmt_begndate=" + "2021-03-01" +
  3938. "&stm_enddate=" + "2021-03-31" +
  3939. "&medfee_sumamt=" + "209318.43" +
  3940. "&fund_pay_sumamt=" + "188029.12" +
  3941. "&acct_pay=" + "0" +
  3942. "&fixmedins_setl_cnt=" + "48" +
  3943. "&fixmedins_code=" + miConfig.Code +
  3944. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  3945. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  3946. "&secret_key=" + miConfig.SecretKey +
  3947. "&org_name=" + miConfig.OrgName +
  3948. "&doctor=" + user_name
  3949. fmt.Println(api)
  3950. resp, requestErr := http.Get(api)
  3951. if requestErr != nil {
  3952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3953. return
  3954. }
  3955. body, ioErr := ioutil.ReadAll(resp.Body)
  3956. fmt.Println(body)
  3957. if ioErr != nil {
  3958. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  3959. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3960. return
  3961. }
  3962. var respJSON map[string]interface{}
  3963. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  3964. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  3965. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3966. return
  3967. }
  3968. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  3969. userJSONBytes, _ := json.Marshal(respJSON)
  3970. var res ResultEight
  3971. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3972. utils.ErrorLog("解析失败:%v", err)
  3973. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3974. return
  3975. }
  3976. }
  3977. //对账明细
  3978. func (c *HisApiController) GetCheckDetailAccount() {
  3979. start_time := c.GetString("start_time")
  3980. end_time := c.GetString("end_time")
  3981. admin_user_id, _ := c.GetInt64("admin_user_id")
  3982. adminUser := c.GetAdminUserInfo()
  3983. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  3984. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  3985. timeLayout := "2006-01-02"
  3986. loc, _ := time.LoadLocation("Local")
  3987. startime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3988. endtime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  3989. orders, _ := service.GetOrderByTimeTwo(startime.Unix(), endtime.Unix(), adminUser.CurrentOrgId)
  3990. Mkdir(miConfig.OrgName)
  3991. file := strconv.FormatInt(adminUser.CurrentOrgId, 10) + strconv.FormatInt(time.Now().Unix(), 10)
  3992. file_name := file + ".txt"
  3993. zip_name := file + ".zip"
  3994. zip_path := miConfig.OrgName + "/" + zip_name
  3995. file_path := miConfig.OrgName + "/" + file_name
  3996. decimal.DivisionPrecision = 2
  3997. var medfee_sumamt float64
  3998. var psn_cash_pay float64
  3999. var fund_pay_sumamt float64
  4000. fixmedins_setl_cnt := int64(len(orders))
  4001. for _, item := range orders {
  4002. medfee_sumamt = medfee_sumamt + item.MedfeeSumamt
  4003. psn_cash_pay = psn_cash_pay + item.PsnCashPay
  4004. fund_pay_sumamt = fund_pay_sumamt + item.FundPaySumamt
  4005. }
  4006. f, err := os.Create(miConfig.OrgName + "/" + file_name)
  4007. defer f.Close()
  4008. if err != nil {
  4009. fmt.Println(err.Error())
  4010. } else {
  4011. for _, item := range orders {
  4012. var refd_setl_flag string
  4013. if item.OrderStatus == 2 {
  4014. refd_setl_flag = "0"
  4015. var str string
  4016. str = item.SetlId + " " +
  4017. item.MdtrtId + " " +
  4018. item.PsnNo + " " +
  4019. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  4020. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  4021. fmt.Sprintf("%.2f", item.AcctPay) + " " + refd_setl_flag + "\r\n"
  4022. _, err = f.Write([]byte(str))
  4023. }
  4024. if item.OrderStatus == 3 {
  4025. var str string
  4026. str = item.SetlId + " " +
  4027. item.MdtrtId + " " +
  4028. item.PsnNo + " " +
  4029. fmt.Sprintf("%.2f", item.MedfeeSumamt) + " " +
  4030. fmt.Sprintf("%.2f", item.FundPaySumamt) + " " +
  4031. fmt.Sprintf("%.2f", item.AcctPay) + " " + "1" + "\r\n"
  4032. _, err = f.Write([]byte(str))
  4033. var str2 string
  4034. str2 = item.SetlId + " " +
  4035. item.MdtrtId + " " +
  4036. item.PsnNo + " " +
  4037. fmt.Sprintf("%.2f", 0-item.MedfeeSumamt) + " " +
  4038. fmt.Sprintf("%.2f", 0-item.FundPaySumamt) + " " +
  4039. fmt.Sprintf("%.2f", 0-item.AcctPay) + " " + "1" + "\r\n"
  4040. _, err = f.Write([]byte(str2))
  4041. }
  4042. }
  4043. }
  4044. Zip(file_path, zip_path)
  4045. fmt.Println(ReadFile(zip_path))
  4046. fmt.Println(string(ReadFile(zip_path)))
  4047. if config.IsOpen == 1 {
  4048. var user_name string
  4049. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4050. if role.ID == 0 {
  4051. user_name = "管理员"
  4052. } else {
  4053. user_name = role.UserName
  4054. }
  4055. baseParams := models.BaseParams{
  4056. SecretKey: miConfig.SecretKey,
  4057. FixmedinsCode: miConfig.Code,
  4058. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4059. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4060. OrgName: miConfig.OrgName,
  4061. Doctor: user_name,
  4062. }
  4063. result := service.Gdyb9101(baseParams, zip_name, ReadFile(zip_path))
  4064. var dat map[string]interface{}
  4065. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4066. fmt.Println(dat)
  4067. } else {
  4068. fmt.Println(err)
  4069. }
  4070. userJSONBytes, _ := json.Marshal(dat)
  4071. var res ResultNine
  4072. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4073. utils.ErrorLog("解析失败:%v", err)
  4074. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4075. return
  4076. }
  4077. if res.Infcode == 0 {
  4078. fileNo := res.Output.FileQuryNo
  4079. api := "http://127.0.0.1:9532/" + "gdyb/twelve?" +
  4080. "file_qury_no=" + fileNo +
  4081. "&setl_optins=" + "定点医保中心" +
  4082. "&stmt_begndate=" + start_time +
  4083. "&stm_enddate=" + end_time +
  4084. "&medfee_sumamt=" + fmt.Sprintf("%.2f", medfee_sumamt) +
  4085. "&fund_pay_sumamt=" + fmt.Sprintf("%.2f", fund_pay_sumamt) +
  4086. "&cash_payamt=" + fmt.Sprintf("%.2f", psn_cash_pay) +
  4087. "&fixmedins_setl_cnt=" + strconv.FormatInt(fixmedins_setl_cnt, 10) +
  4088. "&fixmedins_code=" + miConfig.Code +
  4089. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs +
  4090. "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs +
  4091. "&secret_key=" + miConfig.SecretKey +
  4092. "&org_name=" + miConfig.OrgName +
  4093. "&doctor=" + user_name
  4094. resp, requestErr := http.Get(api)
  4095. if requestErr != nil {
  4096. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4097. return
  4098. }
  4099. body, ioErr := ioutil.ReadAll(resp.Body)
  4100. if ioErr != nil {
  4101. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4102. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4103. return
  4104. }
  4105. var respJSON map[string]interface{}
  4106. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4107. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4108. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4109. return
  4110. }
  4111. respJSON = respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4112. userJSONBytes, _ := json.Marshal(respJSON)
  4113. var res ResultTen
  4114. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4115. utils.ErrorLog("解析失败:%v", err)
  4116. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4117. return
  4118. }
  4119. if res.Infcode == 0 {
  4120. service.Gdyb9102(baseParams, zip_name, fileNo)
  4121. micc := &models.MedicalInsuranceCostCompare{
  4122. StartTime: startime.Unix(),
  4123. EndTime: endtime.Unix(),
  4124. Insutype: "0",
  4125. CheckType: 2,
  4126. Num: fixmedins_setl_cnt,
  4127. Mtime: time.Now().Unix(),
  4128. Status: 1,
  4129. UserOrgId: adminUser.CurrentOrgId,
  4130. CostTotal: medfee_sumamt,
  4131. FuncTotal: fund_pay_sumamt,
  4132. PsnPay: psn_cash_pay,
  4133. Creator: admin_user_id,
  4134. Ctime: time.Now().Unix(),
  4135. }
  4136. service.CreateMedicalInsuranceCostCompareRecord(micc)
  4137. c.ServeSuccessJSON(map[string]interface{}{
  4138. "msg": "明细对账成功",
  4139. })
  4140. }
  4141. } else {
  4142. }
  4143. }
  4144. }
  4145. func (c *HisApiController) GetSettleAccounts() {
  4146. //id, _ := c.GetInt64("id")
  4147. //record_time := c.GetString("record_time")
  4148. order_id, _ := c.GetInt64("order_id")
  4149. admin_user_id, _ := c.GetInt64("admin_user_id")
  4150. //timeLayout := "2006-01-02"
  4151. //loc, _ := time.LoadLocation("Local")
  4152. //
  4153. //theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4154. //if err != nil {
  4155. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4156. // return
  4157. //}
  4158. //recordDateTime := theTime.Unix()
  4159. adminUser := c.GetAdminUserInfo()
  4160. order, _ := service.GetHisOrderByID(order_id)
  4161. his, _ := service.GetHisPatientByNumber(order.MdtrtId)
  4162. orderInfos, _ := service.GetHisOrderInfoByNumber(order.Number)
  4163. orderInfos_two, _ := service.GetHisOrderInfoByNumberTwo(order.Number)
  4164. orderInfos = append(orderInfos, orderInfos_two...)
  4165. //diagnosisConfig, _ := service.FindDiagnoseById(his.Diagnosis)
  4166. diagnosis_ids := strings.Split(his.Diagnosis, ",")
  4167. //var config []*models.HisXtDiagnoseConfig
  4168. var name string
  4169. for _, item := range diagnosis_ids {
  4170. id, _ := strconv.ParseInt(item, 10, 64)
  4171. diagnosisConfig, _ := service.FindDiagnoseById(id)
  4172. if len(name) == 0 {
  4173. name = diagnosisConfig.ClassName
  4174. } else {
  4175. name = name + "," + diagnosisConfig.ClassName
  4176. }
  4177. }
  4178. var bedCostTotal float64 = 0 //床位总费
  4179. var bedCostSelfTotal float64 = 0 //床位自费
  4180. var bedCostPartSelfTotal float64 = 0 //床位部分项目自费
  4181. var operationCostTotal float64 = 0 //手术费
  4182. var operationCostSelfTotal float64 = 0 //手术费
  4183. var operationCostPartSelfTotal float64 = 0 //手术费
  4184. var otherCostTotal float64 = 0 //其他费用
  4185. var otherCostSelfTotal float64 = 0 //其他费用
  4186. var otherCostPartSelfTotal float64 = 0 //其他费用
  4187. var materialCostTotal float64 = 0 //材料费
  4188. var materialCostSelfTotal float64 = 0 //材料费
  4189. var materialCostPartSelfTotal float64 = 0 //材料费
  4190. var westernMedicineCostTotal float64 = 0 //西药费
  4191. var westernMedicineCostSelfTotal float64 = 0 //西药费
  4192. var westernMedicineCostPartSelfTotal float64 = 0 //西药费
  4193. var chineseTraditionalMedicineCostTotal float64 = 0 //中成药
  4194. var chineseTraditionalMedicineCostSelfTotal float64 = 0 //中成药
  4195. var chineseTraditionalMedicineCostPartSelfTotal float64 = 0 //中成药
  4196. var checkCostTotal float64 = 0 //检查费
  4197. var checkCostSelfTotal float64 = 0 //检查费
  4198. var checkCostPartSelfTotal float64 = 0 //检查费
  4199. var laboratoryCostTotal float64 = 0 //化验费
  4200. var laboratoryCostSelfTotal float64 = 0 //化验费
  4201. var laboratoryCostPartSelfTotal float64 = 0 //化验费
  4202. var treatCostTotal float64 = 0 //治疗费用
  4203. var treatCostSelfTotal float64 = 0 //治疗费用
  4204. var treatCostPartSelfTotal float64 = 0 //治疗费用
  4205. decimal.DivisionPrecision = 2
  4206. for _, item := range orderInfos {
  4207. if item.MedChrgitmType == "01" { //床位费
  4208. bedCostTotal, _ = decimal.NewFromFloat(bedCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4209. bedCostSelfTotal, _ = decimal.NewFromFloat(bedCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4210. bedCostPartSelfTotal, _ = decimal.NewFromFloat(bedCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4211. }
  4212. if item.MedChrgitmType == "03" { //检查费
  4213. checkCostTotal, _ = decimal.NewFromFloat(checkCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4214. checkCostSelfTotal, _ = decimal.NewFromFloat(checkCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4215. checkCostPartSelfTotal, _ = decimal.NewFromFloat(checkCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4216. }
  4217. if item.MedChrgitmType == "04" { //化验费
  4218. laboratoryCostTotal, _ = decimal.NewFromFloat(laboratoryCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4219. laboratoryCostSelfTotal, _ = decimal.NewFromFloat(laboratoryCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4220. laboratoryCostPartSelfTotal, _ = decimal.NewFromFloat(laboratoryCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4221. }
  4222. if item.MedChrgitmType == "05" { //治疗费
  4223. treatCostTotal, _ = decimal.NewFromFloat(treatCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4224. treatCostSelfTotal, _ = decimal.NewFromFloat(treatCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4225. treatCostPartSelfTotal, _ = decimal.NewFromFloat(treatCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4226. }
  4227. if item.MedChrgitmType == "06" { //手术费
  4228. operationCostTotal, _ = decimal.NewFromFloat(operationCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4229. operationCostSelfTotal, _ = decimal.NewFromFloat(operationCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4230. operationCostPartSelfTotal, _ = decimal.NewFromFloat(operationCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4231. }
  4232. if item.MedChrgitmType == "08" { //材料费
  4233. materialCostTotal, _ = decimal.NewFromFloat(materialCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4234. materialCostSelfTotal, _ = decimal.NewFromFloat(materialCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4235. materialCostPartSelfTotal, _ = decimal.NewFromFloat(materialCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4236. }
  4237. if item.MedChrgitmType == "09" { //西药费
  4238. westernMedicineCostTotal, _ = decimal.NewFromFloat(westernMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4239. westernMedicineCostSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4240. westernMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(westernMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4241. }
  4242. if item.MedChrgitmType == "11" { //中成费
  4243. chineseTraditionalMedicineCostTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4244. chineseTraditionalMedicineCostSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4245. chineseTraditionalMedicineCostPartSelfTotal, _ = decimal.NewFromFloat(chineseTraditionalMedicineCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4246. }
  4247. if item.MedChrgitmType == "14" { //其他费
  4248. otherCostTotal, _ = decimal.NewFromFloat(otherCostTotal).Add(decimal.NewFromFloat(item.DetItemFeeSumamt)).Float64()
  4249. otherCostSelfTotal, _ = decimal.NewFromFloat(otherCostSelfTotal).Add(decimal.NewFromFloat(item.OverlmtAmt)).Float64()
  4250. otherCostPartSelfTotal, _ = decimal.NewFromFloat(otherCostPartSelfTotal).Add(decimal.NewFromFloat(item.PreselfpayAmt)).Float64()
  4251. }
  4252. }
  4253. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4254. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4255. var user_name string
  4256. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4257. if role.ID == 0 {
  4258. user_name = "管理员"
  4259. } else {
  4260. user_name = role.UserName
  4261. }
  4262. baseParams := models.BaseParams{
  4263. SecretKey: miConfig.SecretKey,
  4264. FixmedinsCode: miConfig.Code,
  4265. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4266. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4267. OrgName: miConfig.OrgName,
  4268. Doctor: user_name,
  4269. }
  4270. businessParams := models.BusinessParams{
  4271. PsnNo: order.PsnNo,
  4272. MdtrtId: order.MdtrtId,
  4273. SetlId: order.SetlId,
  4274. }
  4275. if config.IsOpen == 1 {
  4276. result := service.Gdyb5203(baseParams, businessParams)
  4277. var dat map[string]interface{}
  4278. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4279. fmt.Println(dat)
  4280. } else {
  4281. fmt.Println(err)
  4282. }
  4283. userJSONBytes, _ := json.Marshal(dat)
  4284. var res ResultEleven
  4285. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4286. utils.ErrorLog("解析失败:%v", err)
  4287. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4288. return
  4289. }
  4290. printor_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4291. charge_admin, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, order.Creator)
  4292. if res.Infcode == 0 {
  4293. c.ServeSuccessJSON(map[string]interface{}{
  4294. "diagnosis": name,
  4295. "order_infos": orderInfos,
  4296. "number": order.MdtrtId,
  4297. "date": order.SettleAccountsDate,
  4298. "charge_admin": charge_admin,
  4299. "printor_admin": printor_admin,
  4300. "info": res.Output.Setlinfo,
  4301. "bedCostTotal": bedCostTotal,
  4302. "bedCostSelfTotal": bedCostSelfTotal,
  4303. "bedCostPartSelfTotal": bedCostPartSelfTotal,
  4304. "operationCostTotal": operationCostTotal,
  4305. "operationCostSelfTotal": operationCostSelfTotal,
  4306. "operationCostPartSelfTotal": operationCostPartSelfTotal,
  4307. "otherCostTotal": otherCostTotal,
  4308. "otherCostSelfTotal": otherCostSelfTotal,
  4309. "otherCostPartSelfTotal": otherCostPartSelfTotal,
  4310. "materialCostTotal": materialCostTotal,
  4311. "materialCostSelfTotal": materialCostSelfTotal,
  4312. "materialCostPartSelfTotal": materialCostPartSelfTotal,
  4313. "westernMedicineCostTotal": westernMedicineCostTotal,
  4314. "westernMedicineCostSelfTotal": westernMedicineCostSelfTotal,
  4315. "westernMedicineCostPartSelfTotal": westernMedicineCostPartSelfTotal,
  4316. "chineseTraditionalMedicineCostTotal": chineseTraditionalMedicineCostTotal,
  4317. "chineseTraditionalMedicineCostSelfTotal": chineseTraditionalMedicineCostSelfTotal,
  4318. "chineseTraditionalMedicineCostPartSelfTotal": chineseTraditionalMedicineCostPartSelfTotal,
  4319. "checkCostTotal": checkCostTotal,
  4320. "checkCostSelfTotal": checkCostSelfTotal,
  4321. "checkCostPartSelfTotal": checkCostPartSelfTotal,
  4322. "laboratoryCostTotal": laboratoryCostTotal,
  4323. "laboratoryCostSelfTotal": laboratoryCostSelfTotal,
  4324. "laboratoryCostPartSelfTotal": laboratoryCostPartSelfTotal,
  4325. "treatCostTotal": treatCostTotal,
  4326. "treatCostSelfTotal": treatCostSelfTotal,
  4327. "treatCostPartSelfTotal": treatCostPartSelfTotal,
  4328. })
  4329. }
  4330. }
  4331. }
  4332. func (c *HisApiController) CheckTreatment() {
  4333. patient_id, _ := c.GetInt64("patient_id", 0)
  4334. record_time := c.GetString("record_time")
  4335. insutype := c.GetString("insutype")
  4336. timeLayout := "2006-01-02"
  4337. loc, _ := time.LoadLocation("Local")
  4338. adminUser := c.GetAdminUserInfo()
  4339. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4340. fmt.Println(err)
  4341. if err != nil {
  4342. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4343. return
  4344. }
  4345. recordDateTime := theTime.Unix()
  4346. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4347. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  4348. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4349. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4350. var user_name string
  4351. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, adminUser.AdminUser.Id)
  4352. if role.ID == 0 {
  4353. user_name = "xxx"
  4354. } else {
  4355. user_name = role.UserName
  4356. }
  4357. baseParams := models.BaseParams{
  4358. SecretKey: miConfig.SecretKey,
  4359. FixmedinsCode: miConfig.Code,
  4360. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4361. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4362. OrgName: miConfig.OrgName,
  4363. Doctor: user_name,
  4364. }
  4365. if config.IsOpen == 1 {
  4366. result := service.Gdyb2001(baseParams, his.PsnNo, insutype, strconv.FormatInt(patientPrescription.RegisterType, 10))
  4367. var dat map[string]interface{}
  4368. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4369. fmt.Println(dat)
  4370. } else {
  4371. fmt.Println(err)
  4372. }
  4373. }
  4374. }
  4375. func (c *HisApiController) PutRecord() {
  4376. id, _ := c.GetInt64("id")
  4377. record_time := c.GetString("record_time")
  4378. timeLayout := "2006-01-02"
  4379. loc, _ := time.LoadLocation("Local")
  4380. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4381. if err != nil {
  4382. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4383. return
  4384. }
  4385. recordDateTime := theTime.Unix()
  4386. adminInfo := c.GetAdminUserInfo()
  4387. patient, _ := service.GetPatientByID(adminInfo.CurrentOrgId, id)
  4388. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4389. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4390. fmt.Println(miConfig.SecretKey)
  4391. if patient == nil {
  4392. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4393. return
  4394. }
  4395. if len(patient.IdCardNo) == 0 {
  4396. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  4397. return
  4398. }
  4399. config, _ := service.GetMedicalInsuranceConfig(adminInfo.CurrentOrgId)
  4400. if config.IsOpen == 1 {
  4401. 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
  4402. resp, requestErr := http.Get(api)
  4403. if requestErr != nil {
  4404. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4405. return
  4406. }
  4407. defer resp.Body.Close()
  4408. body, ioErr := ioutil.ReadAll(resp.Body)
  4409. if ioErr != nil {
  4410. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4412. return
  4413. }
  4414. var respJSON map[string]interface{}
  4415. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4416. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4417. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4418. return
  4419. }
  4420. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4421. userJSONBytes, _ := json.Marshal(userJSON)
  4422. var res ResultTwo
  4423. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4424. utils.ErrorLog("解析失败:%v", err)
  4425. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4426. return
  4427. }
  4428. Iinfos, _ := json.Marshal(res.Output.Iinfo)
  4429. Idetinfos, _ := json.Marshal(res.Output.Idetinfo)
  4430. infoStr := string(Iinfos)
  4431. idetinfoStr := string(Idetinfos)
  4432. if res.Infcode == 0 {
  4433. his := models.VMHisPatient{
  4434. Status: 1,
  4435. Ctime: time.Now().Unix(),
  4436. Mtime: time.Now().Unix(),
  4437. PsnNo: res.Output.Baseinfo.PsnNo,
  4438. PsnCertType: res.Output.Baseinfo.PsnCertType,
  4439. Certno: res.Output.Baseinfo.Certno,
  4440. PsnName: res.Output.Baseinfo.PsnName,
  4441. Gend: res.Output.Baseinfo.Gend,
  4442. Naty: res.Output.Baseinfo.Naty,
  4443. Brdy: res.Output.Baseinfo.Brdy,
  4444. Age: res.Output.Baseinfo.Age,
  4445. Iinfo: infoStr,
  4446. Idetinfo: idetinfoStr,
  4447. PatientId: patient.ID,
  4448. RecordDate: theTime.Unix(),
  4449. UserOrgId: adminInfo.CurrentOrgId,
  4450. AdminUserId: adminInfo.AdminUser.Id,
  4451. IsReturn: 1,
  4452. }
  4453. doctor_id := strconv.FormatInt(patientPrescription.DoctorId, 10)
  4454. 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")
  4455. 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")
  4456. var dat map[string]interface{}
  4457. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4458. fmt.Println(dat)
  4459. } else {
  4460. fmt.Println(err)
  4461. }
  4462. var dat2 map[string]interface{}
  4463. if err := json.Unmarshal([]byte(result2), &dat2); err == nil {
  4464. fmt.Println(dat2)
  4465. } else {
  4466. fmt.Println(err)
  4467. }
  4468. } else {
  4469. adminUser := c.GetAdminUserInfo()
  4470. errlog := &models.HisOrderError{
  4471. UserOrgId: adminUser.CurrentOrgId,
  4472. Ctime: time.Now().Unix(),
  4473. Mtime: time.Now().Unix(),
  4474. ErrMsg: res.ErrMsg,
  4475. Status: 1,
  4476. PatientId: id,
  4477. RecordTime: recordDateTime,
  4478. Stage: 1,
  4479. }
  4480. service.CreateErrMsgLog(errlog)
  4481. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGdybOneException)
  4482. return
  4483. }
  4484. }
  4485. }
  4486. func (c *HisApiController) GetUploadDiag() {
  4487. id, _ := c.GetInt64("id")
  4488. record_time := c.GetString("record_time")
  4489. diagnosis_id, _ := c.GetInt64("diagnosis")
  4490. sick_type, _ := c.GetInt64("sick_type")
  4491. reg_type, _ := c.GetInt64("reg_type")
  4492. timeLayout := "2006-01-02"
  4493. loc, _ := time.LoadLocation("Local")
  4494. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  4495. if err != nil {
  4496. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4497. return
  4498. }
  4499. var patientPrescription models.HisPrescriptionInfo
  4500. recordDateTime := theTime.Unix()
  4501. adminInfo := c.GetAdminUserInfo()
  4502. patientPrescription, _ = service.FindPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4503. if patientPrescription.ID == 0 {
  4504. patientPrescription, _ = service.FindLastPatientPrescriptionInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4505. }
  4506. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  4507. diagnosisConfig, _ := service.FindDiagnoseById(diagnosis_id)
  4508. his, _ := service.GetVMHisPatientInfo(adminInfo.CurrentOrgId, id, recordDateTime)
  4509. sickConfig, _ := service.FindSickById(sick_type)
  4510. department, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  4511. api2 := "http://127.0.0.1:9532/" + "gdyb/four?psn_no=" + his.PsnNo +
  4512. "&mdtrt_id=" + his.Number + "&doctor=" + patientPrescription.Doctor + "&department=" + department.Name +
  4513. "&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 +
  4514. "&insuplc_admdvs=" + miConfig.InsuplcAdmdvs + "&mdtrtarea_admvs=" + miConfig.MdtrtareaAdmvs + "&secret_key=" + miConfig.SecretKey + "&sick_code=" + sickConfig.CountryCode + "&sick_name=" + sickConfig.ClassName
  4515. resp2, requestErr2 := http.Get(api2)
  4516. if requestErr2 != nil {
  4517. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4518. return
  4519. }
  4520. body2, ioErr2 := ioutil.ReadAll(resp2.Body)
  4521. if ioErr2 != nil {
  4522. utils.ErrorLog("接口返回数据读取失败: %v", ioErr2)
  4523. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4524. return
  4525. }
  4526. var respJSON2 map[string]interface{}
  4527. if err := json.Unmarshal([]byte(string(body2)), &respJSON2); err != nil {
  4528. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4529. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4530. return
  4531. }
  4532. respJSON2 = respJSON2["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4533. userJSONBytes2, _ := json.Marshal(respJSON2)
  4534. var res2 ResultSix
  4535. if err := json.Unmarshal(userJSONBytes2, &res2); err != nil {
  4536. utils.ErrorLog("解析失败:%v", err)
  4537. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4538. return
  4539. }
  4540. if res2.Infcode != 0 {
  4541. adminUser := c.GetAdminUserInfo()
  4542. errlog := &models.HisOrderError{
  4543. UserOrgId: adminUser.CurrentOrgId,
  4544. Ctime: time.Now().Unix(),
  4545. Mtime: time.Now().Unix(),
  4546. ErrMsg: res2.ErrMsg,
  4547. Status: 1,
  4548. PatientId: id,
  4549. RecordTime: recordDateTime,
  4550. Stage: 3,
  4551. }
  4552. service.CreateErrMsgLog(errlog)
  4553. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterThreeException)
  4554. return
  4555. }
  4556. c.ServeSuccessJSON(map[string]interface{}{
  4557. "msg": "上传成功",
  4558. })
  4559. }
  4560. type QueryResult struct {
  4561. ID int64
  4562. Name string
  4563. Code string
  4564. List_type_code string
  4565. }
  4566. func (c *HisApiController) GetCheckCode() {
  4567. ids_str := c.GetString("ids")
  4568. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4569. ids_arr := strings.Split(ids_str, ",")
  4570. var queryResult []QueryResult
  4571. ids := make([]int64, 0)
  4572. for _, item := range ids_arr {
  4573. id, _ := strconv.ParseInt(item, 10, 64)
  4574. ids = append(ids, id)
  4575. }
  4576. if record_type == 1 {
  4577. drugs, _ := service.GetBatchDrugList(ids)
  4578. for _, item := range drugs {
  4579. result := QueryResult{
  4580. ID: item.ID,
  4581. Name: item.DrugName,
  4582. Code: item.MedicalInsuranceNumber,
  4583. List_type_code: "101",
  4584. }
  4585. queryResult = append(queryResult, result)
  4586. }
  4587. } else if record_type == 2 {
  4588. goods, _ := service.GetBatchGoodInformationList(ids)
  4589. for _, item := range goods {
  4590. result := QueryResult{
  4591. ID: item.ID,
  4592. Name: item.GoodName,
  4593. Code: item.MedicalInsuranceNumber,
  4594. List_type_code: "301",
  4595. }
  4596. queryResult = append(queryResult, result)
  4597. }
  4598. } else if record_type == 3 {
  4599. projects, _ := service.GetBathchMyPorjecgList(ids)
  4600. for _, item := range projects {
  4601. result := QueryResult{
  4602. ID: item.ID,
  4603. Name: item.ProjectName,
  4604. Code: item.MedicalCode,
  4605. List_type_code: "201",
  4606. }
  4607. queryResult = append(queryResult, result)
  4608. }
  4609. }
  4610. admin_user_id, _ := c.GetInt64("admin_user_id")
  4611. adminUser := c.GetAdminUserInfo()
  4612. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4613. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4614. var user_name string
  4615. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4616. if role.ID == 0 {
  4617. user_name = "xxx"
  4618. } else {
  4619. user_name = role.UserName
  4620. }
  4621. baseParams := &models.BaseParams{
  4622. SecretKey: miConfig.SecretKey,
  4623. FixmedinsCode: miConfig.Code,
  4624. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4625. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4626. OrgName: miConfig.OrgName,
  4627. Doctor: user_name,
  4628. }
  4629. if config.IsOpen == 1 {
  4630. for _, item := range queryResult {
  4631. var result string
  4632. if record_type == 1 {
  4633. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4634. } else if record_type == 2 {
  4635. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4636. } else if record_type == 3 {
  4637. result = service.Gdyb3301(baseParams, item.Name, item.Code, item.List_type_code, "2021-04-26", "", item.List_type_code)
  4638. }
  4639. var dat map[string]interface{}
  4640. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4641. fmt.Println(dat)
  4642. } else {
  4643. fmt.Println(err)
  4644. }
  4645. userJSONBytes, _ := json.Marshal(dat)
  4646. var res ResultSix
  4647. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4648. utils.ErrorLog("解析失败:%v", err)
  4649. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4650. return
  4651. }
  4652. if res.Infcode == 0 {
  4653. if record_type == 1 {
  4654. service.UpdateBaseDrugById(item.ID)
  4655. } else if record_type == 2 {
  4656. service.UpdateGoodInformaitonByDetail(item.ID)
  4657. } else if record_type == 3 {
  4658. service.UpdateProjectById(item.ID)
  4659. }
  4660. c.ServeSuccessJSON(map[string]interface{}{
  4661. "failed_code": 0,
  4662. "msg": "目录对照成功",
  4663. })
  4664. } else {
  4665. c.ServeSuccessJSON(map[string]interface{}{
  4666. "failed_code": -10,
  4667. "msg": res.ErrMsg,
  4668. })
  4669. }
  4670. }
  4671. }
  4672. }
  4673. func (c *HisApiController) UnCheckCode() {
  4674. ids_str := c.GetString("ids")
  4675. record_type, _ := c.GetInt64("record_type") //1.药品 2.耗材 3.项目
  4676. admin_user_id, _ := c.GetInt64("admin_user_id")
  4677. ids_arr := strings.Split(ids_str, ",")
  4678. var queryResult []QueryResult
  4679. ids := make([]int64, 0)
  4680. for _, item := range ids_arr {
  4681. id, _ := strconv.ParseInt(item, 10, 64)
  4682. ids = append(ids, id)
  4683. }
  4684. if record_type == 1 {
  4685. drugs, _ := service.GetBatchDrugList(ids)
  4686. for _, item := range drugs {
  4687. result := QueryResult{
  4688. ID: item.ID,
  4689. Name: item.DrugName,
  4690. Code: item.MedicalInsuranceNumber,
  4691. List_type_code: "101",
  4692. }
  4693. queryResult = append(queryResult, result)
  4694. }
  4695. } else if record_type == 2 {
  4696. goods, _ := service.GetBatchGoodInformationList(ids)
  4697. for _, item := range goods {
  4698. result := QueryResult{
  4699. ID: item.ID,
  4700. Name: item.GoodName,
  4701. Code: item.MedicalInsuranceNumber,
  4702. List_type_code: "301",
  4703. }
  4704. queryResult = append(queryResult, result)
  4705. }
  4706. } else if record_type == 3 {
  4707. projects, _ := service.GetBathchMyPorjecgList(ids)
  4708. for _, item := range projects {
  4709. result := QueryResult{
  4710. ID: item.ID,
  4711. Name: item.ProjectName,
  4712. Code: item.MedicalCode,
  4713. List_type_code: "201",
  4714. }
  4715. queryResult = append(queryResult, result)
  4716. }
  4717. }
  4718. adminUser := c.GetAdminUserInfo()
  4719. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4720. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4721. var user_name string
  4722. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4723. if role.ID == 0 {
  4724. user_name = "xxx"
  4725. } else {
  4726. user_name = role.UserName
  4727. }
  4728. baseParams := &models.BaseParams{
  4729. SecretKey: miConfig.SecretKey,
  4730. FixmedinsCode: miConfig.Code,
  4731. InsuplcAdmdvs: miConfig.InsuplcAdmdvs,
  4732. MdtrtareaAdmvs: miConfig.MdtrtareaAdmvs,
  4733. OrgName: miConfig.OrgName,
  4734. Doctor: user_name,
  4735. }
  4736. if config.IsOpen == 1 {
  4737. for _, item := range queryResult {
  4738. var result string
  4739. if record_type == 1 {
  4740. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4741. } else if record_type == 2 {
  4742. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4743. } else if record_type == 3 {
  4744. result = service.Gdyb3302(baseParams, item.Name, item.Code, item.List_type_code)
  4745. }
  4746. var dat2 map[string]interface{}
  4747. if err := json.Unmarshal([]byte(result), &dat2); err == nil {
  4748. fmt.Println(dat2)
  4749. } else {
  4750. fmt.Println(err)
  4751. }
  4752. userJSONBytes, _ := json.Marshal(dat2)
  4753. var res ResultSix
  4754. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4755. utils.ErrorLog("解析失败:%v", err)
  4756. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4757. return
  4758. }
  4759. if res.Infcode == 0 {
  4760. if record_type == 1 {
  4761. service.UpdateDrugByIdDetail(item.ID)
  4762. } else if record_type == 2 {
  4763. service.UpdateGoodInfoById(item.ID)
  4764. } else if record_type == 3 {
  4765. service.UpdateMyProjectById(item.ID)
  4766. }
  4767. c.ServeSuccessJSON(map[string]interface{}{
  4768. "failed_code": 0,
  4769. "msg": "撤销目录对照成功",
  4770. })
  4771. } else {
  4772. c.ServeSuccessJSON(map[string]interface{}{
  4773. "failed_code": -10,
  4774. "msg": res.ErrMsg,
  4775. })
  4776. }
  4777. }
  4778. }
  4779. }
  4780. func (c *HisApiController) GetPatientInfo() {
  4781. id_card_no := c.GetString("id_card_no")
  4782. admin_user_id, _ := c.GetInt64("admin_user_id")
  4783. patient, _ := service.GetPatientByIDCard(id_card_no, c.GetAdminUserInfo().CurrentOrgId)
  4784. if patient.ID == 0 {
  4785. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  4786. return
  4787. }
  4788. role, _ := service.GetAdminUserInfoByID(c.GetAdminUserInfo().CurrentOrgId, admin_user_id)
  4789. miConfig, _ := service.FindMedicalInsuranceInfo(c.GetAdminUserInfo().CurrentOrgId)
  4790. config, _ := service.GetMedicalInsuranceConfig(c.GetAdminUserInfo().CurrentOrgId)
  4791. if config.IsOpen == 1 {
  4792. result := service.Gdyb1101A(id_card_no, miConfig.OrgName, role.UserName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  4793. var dat map[string]interface{}
  4794. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4795. fmt.Println(dat)
  4796. } else {
  4797. fmt.Println(err)
  4798. }
  4799. userJSONBytes, _ := json.Marshal(dat)
  4800. var res ResultTwo
  4801. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4802. utils.ErrorLog("解析失败:%v", err)
  4803. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4804. return
  4805. }
  4806. if res.Infcode != 0 {
  4807. c.ServeSuccessJSON(map[string]interface{}{
  4808. "failed_code": -10,
  4809. "msg": res.ErrMsg,
  4810. })
  4811. } else {
  4812. c.ServeSuccessJSON(map[string]interface{}{
  4813. "failed_code": 0,
  4814. "info": res,
  4815. })
  4816. }
  4817. }
  4818. }
  4819. func (c *HisApiController) PsnPutOnRecord() {
  4820. record_type, _ := c.GetInt64("type")
  4821. patient_id, _ := c.GetInt64("patient_id")
  4822. admin_user_id, _ := c.GetInt64("admin_user_id")
  4823. start_time := c.GetString("start_time")
  4824. end_time := c.GetString("end_time")
  4825. adminUser := c.GetAdminUserInfo()
  4826. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4827. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4828. var patients []*models.Patients
  4829. if record_type == 1 { //全部备案
  4830. patient, _ := service.GetAllPatient(adminUser.CurrentOrgId)
  4831. patients = append(patients, patient...)
  4832. } else { //单个备案
  4833. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4834. patients = append(patients, patient)
  4835. }
  4836. var user_name string
  4837. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4838. if role.ID == 0 {
  4839. user_name = "xxx"
  4840. } else {
  4841. user_name = role.UserName
  4842. }
  4843. if config.IsOpen == 1 {
  4844. for _, item := range patients {
  4845. 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
  4846. resp, requestErr := http.Get(api)
  4847. if requestErr != nil {
  4848. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4849. return
  4850. }
  4851. defer resp.Body.Close()
  4852. body, ioErr := ioutil.ReadAll(resp.Body)
  4853. if ioErr != nil {
  4854. utils.ErrorLog("接口返回数据读取失败: %v", ioErr)
  4855. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4856. return
  4857. }
  4858. var respJSON map[string]interface{}
  4859. if err := json.Unmarshal([]byte(string(body)), &respJSON); err != nil {
  4860. utils.ErrorLog("接口返回数据解析JSON失败: %v", err)
  4861. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4862. return
  4863. }
  4864. userJSON := respJSON["data"].(map[string]interface{})["pre"].(map[string]interface{})
  4865. userJSONBytes, _ := json.Marshal(userJSON)
  4866. var res ResultTwo
  4867. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4868. utils.ErrorLog("解析失败:%v", err)
  4869. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4870. return
  4871. }
  4872. if res.Infcode == 0 {
  4873. result := service.Gdyb2505(res.Output.Baseinfo.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, start_time, end_time)
  4874. var dat map[string]interface{}
  4875. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4876. fmt.Println(dat)
  4877. } else {
  4878. fmt.Println(err)
  4879. }
  4880. userJSONBytes, _ := json.Marshal(dat)
  4881. var res2 ResultThirteen
  4882. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4883. utils.ErrorLog("解析失败:%v", err)
  4884. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4885. return
  4886. }
  4887. if res2.Infcode == 0 {
  4888. psnResult := &models.GdybPsnRecord{
  4889. UserOrgId: adminUser.CurrentOrgId,
  4890. PatientId: item.ID,
  4891. PsnNo: res.Output.Baseinfo.PsnNo,
  4892. Ctime: time.Now().Unix(),
  4893. Mtime: time.Now().Unix(),
  4894. Status: 1,
  4895. IsCancel: 1,
  4896. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4897. }
  4898. service.CreatePsnRecord(psnResult)
  4899. } else {
  4900. c.ServeSuccessJSON(map[string]interface{}{
  4901. "failed_code": -10,
  4902. "msg": res2.ErrMsg,
  4903. })
  4904. return
  4905. }
  4906. }
  4907. }
  4908. }
  4909. }
  4910. func (c *HisApiController) PsnUnPutOnRecord() {
  4911. id, _ := c.GetInt64("id")
  4912. //record_type, _ := c.GetInt64("type")
  4913. admin_user_id, _ := c.GetInt64("admin_user_id")
  4914. adminUser := c.GetAdminUserInfo()
  4915. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4916. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4917. var user_name string
  4918. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  4919. if role.ID == 0 {
  4920. user_name = "xxx"
  4921. } else {
  4922. user_name = role.UserName
  4923. }
  4924. psn_record, _ := service.GetPsnRecordById(id)
  4925. if psn_record.ID == 0 {
  4926. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  4927. return
  4928. }
  4929. if config.IsOpen == 1 {
  4930. result := service.Gdyb2506(psn_record.PsnNo, user_name, miConfig.OrgName, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  4931. var dat map[string]interface{}
  4932. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4933. fmt.Println(dat)
  4934. } else {
  4935. fmt.Println(err)
  4936. }
  4937. userJSONBytes, _ := json.Marshal(dat)
  4938. var res ResultFourteen
  4939. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4940. utils.ErrorLog("解析失败:%v", err)
  4941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4942. return
  4943. }
  4944. if res.Infcode == 0 {
  4945. psn_record.IsCancel = 2
  4946. service.CreatePsnRecord(&psn_record)
  4947. } else {
  4948. c.ServeSuccessJSON(map[string]interface{}{
  4949. "failed_code": -10,
  4950. "msg": res.ErrMsg,
  4951. })
  4952. return
  4953. }
  4954. }
  4955. }
  4956. func (c *HisApiController) PsnPutNCDSOnRecord() {
  4957. patient_id, _ := c.GetInt64("patient_id")
  4958. insutype := c.GetString("insutype")
  4959. psn_no := c.GetString("psn_no")
  4960. doctor_id, _ := c.GetInt64("doctor_id")
  4961. sick_id, _ := c.GetInt64("sick_id")
  4962. department_id, _ := c.GetInt64("department_id")
  4963. adminUser := c.GetAdminUserInfo()
  4964. patient, _ := service.GetPatientByID(adminUser.CurrentOrgId, patient_id)
  4965. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  4966. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  4967. sick, _ := service.FindSickById(sick_id)
  4968. doctor, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, doctor_id)
  4969. if config.IsOpen == 1 {
  4970. result := service.Gdyb2503(psn_no, insutype, miConfig.OrgName, doctor.UserName, miConfig.Code, strconv.FormatInt(doctor.ID, 10), miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, sick.ClassName, sick.CountryCode)
  4971. var dat map[string]interface{}
  4972. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4973. fmt.Println(dat)
  4974. } else {
  4975. fmt.Println(err)
  4976. }
  4977. userJSONBytes, _ := json.Marshal(dat)
  4978. var res2 ResultThirteen
  4979. if err := json.Unmarshal(userJSONBytes, &res2); err != nil {
  4980. utils.ErrorLog("解析失败:%v", err)
  4981. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4982. return
  4983. }
  4984. if res2.Infcode == 0 {
  4985. psnResult := &models.GdybPsnNcdsRecord{
  4986. UserOrgId: adminUser.CurrentOrgId,
  4987. PatientId: patient.ID,
  4988. PsnNo: psn_no,
  4989. DoctorId: doctor.AdminUserId,
  4990. DepartmentId: department_id,
  4991. SickType: sick_id,
  4992. Insutype: insutype,
  4993. Ctime: time.Now().Unix(),
  4994. Mtime: time.Now().Unix(),
  4995. Status: 1,
  4996. IsCancel: 1,
  4997. TrtDclaDetlSn: res2.Output.Result.TrtDclaDetlSn,
  4998. }
  4999. service.CreatePsnNCDSRecord(psnResult)
  5000. c.ServeSuccessJSON(map[string]interface{}{
  5001. "failed_code": 0,
  5002. "msg": "备案成功",
  5003. "result": psnResult,
  5004. })
  5005. } else {
  5006. c.ServeSuccessJSON(map[string]interface{}{
  5007. "failed_code": -10,
  5008. "msg": res2.ErrMsg,
  5009. })
  5010. return
  5011. }
  5012. }
  5013. }
  5014. func (c *HisApiController) PsnPutUnNCDSOnRecord() {
  5015. id, _ := c.GetInt64("id")
  5016. admin_user_id, _ := c.GetInt64("admin_user_id")
  5017. adminUser := c.GetAdminUserInfo()
  5018. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5019. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  5020. var user_name string
  5021. role, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  5022. if role.ID == 0 {
  5023. user_name = "xxx"
  5024. } else {
  5025. user_name = role.UserName
  5026. }
  5027. psn_record, _ := service.GetPsnNCDSRecordById(id)
  5028. if psn_record.ID == 0 {
  5029. c.ServeFailJSONWithSGJErrorCode(enums.ErrorPsnRecordNoExistWrong)
  5030. return
  5031. }
  5032. if config.IsOpen == 1 {
  5033. result := service.Gdyb2504(psn_record.PsnNo, miConfig.OrgName, user_name, miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey, psn_record.TrtDclaDetlSn)
  5034. var dat map[string]interface{}
  5035. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  5036. fmt.Println(dat)
  5037. } else {
  5038. fmt.Println(err)
  5039. }
  5040. userJSONBytes, _ := json.Marshal(dat)
  5041. var res ResultFourteen
  5042. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  5043. utils.ErrorLog("解析失败:%v", err)
  5044. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  5045. return
  5046. }
  5047. if res.Infcode == 0 {
  5048. psn_record.IsCancel = 2
  5049. service.CreatePsnNCDSRecord(&psn_record)
  5050. c.ServeSuccessJSON(map[string]interface{}{
  5051. "failed_code": 0,
  5052. "msg": "撤销备案成功",
  5053. })
  5054. } else {
  5055. c.ServeSuccessJSON(map[string]interface{}{
  5056. "failed_code": -10,
  5057. "msg": res.ErrMsg,
  5058. })
  5059. return
  5060. }
  5061. }
  5062. }
  5063. func (c *HisApiController) TestTest() {
  5064. patient, _ := service.GetHisPatientInfo(4, 456, 1619712000)
  5065. fmt.Println(patient.Iinfo)
  5066. }
  5067. type CustomData struct {
  5068. MsgId string
  5069. PsnNo string
  5070. Info string
  5071. }
  5072. func (c *HisApiController) ReversalData() {
  5073. var customData []*CustomData
  5074. custom := &CustomData{
  5075. MsgId: "H44022900158202103301714472004",
  5076. PsnNo: "44020000001101329945",
  5077. Info: "2207",
  5078. }
  5079. customData = append(customData, custom)
  5080. custom1 := &CustomData{
  5081. MsgId: "H4402290015820210330172057803",
  5082. PsnNo: "44020000001101161813",
  5083. Info: "2207",
  5084. }
  5085. customData = append(customData, custom1)
  5086. custom2 := &CustomData{
  5087. MsgId: "H44022900158202103301705198813",
  5088. PsnNo: "44190000133097375417",
  5089. Info: "2207",
  5090. }
  5091. customData = append(customData, custom2)
  5092. custom3 := &CustomData{
  5093. MsgId: "H44022900158202103301715524756",
  5094. PsnNo: "44020000001100187221",
  5095. Info: "2207",
  5096. }
  5097. customData = append(customData, custom3)
  5098. custom4 := &CustomData{
  5099. MsgId: "H44022900158202103301730376224",
  5100. PsnNo: "44020000001101959155",
  5101. Info: "2207",
  5102. }
  5103. customData = append(customData, custom4)
  5104. custom5 := &CustomData{
  5105. MsgId: "H44022900158202103301748008725",
  5106. PsnNo: "44020000001104246641",
  5107. Info: "2207",
  5108. }
  5109. customData = append(customData, custom5)
  5110. custom6 := &CustomData{
  5111. MsgId: "H44022900158202103301718096755",
  5112. PsnNo: "44020000001102211860",
  5113. Info: "2207",
  5114. }
  5115. customData = append(customData, custom6)
  5116. custom7 := &CustomData{
  5117. MsgId: "H44022900158202103301736551640",
  5118. PsnNo: "44020000001102687718",
  5119. Info: "2207",
  5120. }
  5121. customData = append(customData, custom7)
  5122. custom8 := &CustomData{
  5123. MsgId: "H44022900158202103301743097676",
  5124. PsnNo: "44020000001102127785",
  5125. Info: "2207",
  5126. }
  5127. customData = append(customData, custom8)
  5128. custom9 := &CustomData{
  5129. MsgId: "H44022900158202103301712304203",
  5130. PsnNo: "44020000001101518097",
  5131. Info: "2207",
  5132. }
  5133. customData = append(customData, custom9)
  5134. custom10 := &CustomData{
  5135. MsgId: "H44022900158202103301738448785",
  5136. PsnNo: "44020000001100500813",
  5137. Info: "2207",
  5138. }
  5139. customData = append(customData, custom10)
  5140. custom11 := &CustomData{
  5141. MsgId: "H44022900158202103301732455843",
  5142. PsnNo: "44020000001102690557",
  5143. Info: "2207",
  5144. }
  5145. customData = append(customData, custom11)
  5146. custom12 := &CustomData{
  5147. MsgId: "H44022900158202103301745421708",
  5148. PsnNo: "44020000001102211928",
  5149. Info: "2207",
  5150. }
  5151. customData = append(customData, custom12)
  5152. custom1212 := &CustomData{
  5153. MsgId: "H440229001582021033017351627",
  5154. PsnNo: "44020000001102481733",
  5155. Info: "2207",
  5156. }
  5157. customData = append(customData, custom1212)
  5158. custom13 := &CustomData{
  5159. MsgId: "H44022900158202103301740327951",
  5160. PsnNo: "44020000001103174866",
  5161. Info: "2207",
  5162. }
  5163. customData = append(customData, custom13)
  5164. custom14 := &CustomData{
  5165. MsgId: "H4402290015820210330174922668",
  5166. PsnNo: "44020000001102927272",
  5167. Info: "2207",
  5168. }
  5169. customData = append(customData, custom14)
  5170. custom15 := &CustomData{
  5171. MsgId: "H44022900158202103301752362273",
  5172. PsnNo: "44020000001102942890",
  5173. Info: "2207",
  5174. }
  5175. customData = append(customData, custom15)
  5176. custom16 := &CustomData{
  5177. MsgId: "H44022900158202103301751082917",
  5178. PsnNo: "44020000001101662162",
  5179. Info: "2207",
  5180. }
  5181. customData = append(customData, custom16)
  5182. custom17 := &CustomData{
  5183. MsgId: "H44022900158202103301754147728",
  5184. PsnNo: "44020000000229014511",
  5185. Info: "2207",
  5186. }
  5187. customData = append(customData, custom17)
  5188. adminUser := c.GetAdminUserInfo()
  5189. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5190. for _, item := range customData {
  5191. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5192. fmt.Println(result)
  5193. }
  5194. }
  5195. func (c *HisApiController) ReversalOtherData() {
  5196. var customData []*CustomData
  5197. custom := &CustomData{
  5198. MsgId: "H44022900158202103301714472004",
  5199. PsnNo: "44020000001101329945",
  5200. Info: "2208",
  5201. }
  5202. customData = append(customData, custom)
  5203. custom1 := &CustomData{
  5204. MsgId: "H4402290015820210330172057803",
  5205. PsnNo: "44020000001101161813",
  5206. Info: "2208",
  5207. }
  5208. customData = append(customData, custom1)
  5209. custom2 := &CustomData{
  5210. MsgId: "H44022900158202103301705198813",
  5211. PsnNo: "44190000133097375417",
  5212. Info: "2208",
  5213. }
  5214. customData = append(customData, custom2)
  5215. custom3 := &CustomData{
  5216. MsgId: "H44022900158202103301715524756",
  5217. PsnNo: "44020000001100187221",
  5218. Info: "2208",
  5219. }
  5220. customData = append(customData, custom3)
  5221. custom4 := &CustomData{
  5222. MsgId: "H44022900158202103301730376224",
  5223. PsnNo: "44020000001101959155",
  5224. Info: "2208",
  5225. }
  5226. customData = append(customData, custom4)
  5227. custom5 := &CustomData{
  5228. MsgId: "H44022900158202103301748008725",
  5229. PsnNo: "44020000001104246641",
  5230. Info: "2208",
  5231. }
  5232. customData = append(customData, custom5)
  5233. custom6 := &CustomData{
  5234. MsgId: "H44022900158202103301718096755",
  5235. PsnNo: "44020000001102211860",
  5236. Info: "2208",
  5237. }
  5238. customData = append(customData, custom6)
  5239. custom7 := &CustomData{
  5240. MsgId: "H44022900158202103301736551640",
  5241. PsnNo: "44020000001102687718",
  5242. Info: "2208",
  5243. }
  5244. customData = append(customData, custom7)
  5245. custom8 := &CustomData{
  5246. MsgId: "H44022900158202103301743097676",
  5247. PsnNo: "44020000001102127785",
  5248. Info: "2208",
  5249. }
  5250. customData = append(customData, custom8)
  5251. custom9 := &CustomData{
  5252. MsgId: "H44022900158202103301712304203",
  5253. PsnNo: "44020000001101518097",
  5254. Info: "2208",
  5255. }
  5256. customData = append(customData, custom9)
  5257. custom10 := &CustomData{
  5258. MsgId: "H44022900158202103301738448785",
  5259. PsnNo: "44020000001100500813",
  5260. Info: "2208",
  5261. }
  5262. customData = append(customData, custom10)
  5263. custom11 := &CustomData{
  5264. MsgId: "H44022900158202103301732455843",
  5265. PsnNo: "44020000001102690557",
  5266. Info: "2208",
  5267. }
  5268. customData = append(customData, custom11)
  5269. custom12 := &CustomData{
  5270. MsgId: "H44022900158202103301745421708",
  5271. PsnNo: "44020000001102211928",
  5272. Info: "2208",
  5273. }
  5274. customData = append(customData, custom12)
  5275. custom1212 := &CustomData{
  5276. MsgId: "H440229001582021033017351627",
  5277. PsnNo: "44020000001102481733",
  5278. Info: "2208",
  5279. }
  5280. customData = append(customData, custom1212)
  5281. custom13 := &CustomData{
  5282. MsgId: "H44022900158202103301740327951",
  5283. PsnNo: "44020000001103174866",
  5284. Info: "2208",
  5285. }
  5286. customData = append(customData, custom13)
  5287. custom14 := &CustomData{
  5288. MsgId: "H4402290015820210330174922668",
  5289. PsnNo: "44020000001102927272",
  5290. Info: "2208",
  5291. }
  5292. customData = append(customData, custom14)
  5293. custom15 := &CustomData{
  5294. MsgId: "H44022900158202103301752362273",
  5295. PsnNo: "44020000001102942890",
  5296. Info: "2208",
  5297. }
  5298. customData = append(customData, custom15)
  5299. custom16 := &CustomData{
  5300. MsgId: "H44022900158202103301751082917",
  5301. PsnNo: "44020000001101662162",
  5302. Info: "2208",
  5303. }
  5304. customData = append(customData, custom16)
  5305. custom17 := &CustomData{
  5306. MsgId: "H44022900158202103301754147728",
  5307. PsnNo: "44020000000229014511",
  5308. Info: "2208",
  5309. }
  5310. customData = append(customData, custom17)
  5311. adminUser := c.GetAdminUserInfo()
  5312. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  5313. for _, item := range customData {
  5314. result := service.Gdyb2601(item.PsnNo, item.MsgId, item.Info, miConfig.OrgName, "张俊杰", miConfig.Code, miConfig.InsuplcAdmdvs, miConfig.MdtrtareaAdmvs, miConfig.SecretKey)
  5315. fmt.Println(result)
  5316. }
  5317. }
  5318. func PathExists(path string) (bool, error) {
  5319. _, err := os.Stat(path)
  5320. if err == nil {
  5321. return true, nil
  5322. }
  5323. if os.IsNotExist(err) {
  5324. return false, nil
  5325. }
  5326. return false, err
  5327. }
  5328. //创建文件夹
  5329. func Mkdir(dir string) {
  5330. // 创建文件夹
  5331. exist, err := PathExists(dir)
  5332. if err != nil {
  5333. fmt.Println(err.Error())
  5334. } else {
  5335. if exist {
  5336. fmt.Println(dir + "文件夹已存在!")
  5337. } else {
  5338. // 文件夹名称,权限
  5339. err := os.Mkdir(dir, os.ModePerm)
  5340. if err != nil {
  5341. fmt.Println(dir+"文件夹创建失败:", err.Error())
  5342. } else {
  5343. fmt.Println(dir + "文件夹创建成功!")
  5344. }
  5345. }
  5346. }
  5347. }
  5348. //压缩文件
  5349. func Zip(srcFile string, destZip string) error {
  5350. zipfile, err := os.Create(destZip)
  5351. if err != nil {
  5352. return err
  5353. }
  5354. defer zipfile.Close()
  5355. archive := zip.NewWriter(zipfile)
  5356. defer archive.Close()
  5357. filepath.Walk(srcFile, func(path string, info os.FileInfo, err error) error {
  5358. if err != nil {
  5359. return err
  5360. }
  5361. header, err := zip.FileInfoHeader(info)
  5362. if err != nil {
  5363. return err
  5364. }
  5365. header.Name = strings.TrimPrefix(path, filepath.Dir(srcFile)+"/")
  5366. // header.Name = path
  5367. if info.IsDir() {
  5368. header.Name += "/"
  5369. } else {
  5370. header.Method = zip.Deflate
  5371. }
  5372. writer, err := archive.CreateHeader(header)
  5373. if err != nil {
  5374. return err
  5375. }
  5376. if !info.IsDir() {
  5377. file, err := os.Open(path)
  5378. if err != nil {
  5379. return err
  5380. }
  5381. defer file.Close()
  5382. _, err = io.Copy(writer, file)
  5383. }
  5384. return err
  5385. })
  5386. return err
  5387. }
  5388. func ReadFile(filePath string) []byte {
  5389. f, err := os.Open(filePath)
  5390. if err != nil {
  5391. fmt.Println("read file fail", err)
  5392. return nil
  5393. }
  5394. defer f.Close()
  5395. fd, err := ioutil.ReadAll(f)
  5396. if err != nil {
  5397. fmt.Println("read to fd fail", err)
  5398. return nil
  5399. }
  5400. return fd
  5401. }
  5402. func RemoveRepeatedCode(arr []string) (newArr []string) {
  5403. newArr = make([]string, 0)
  5404. for i := 0; i < len(arr); i++ {
  5405. repeat := false
  5406. for j := i + 1; j < len(arr); j++ {
  5407. if arr[i] == arr[j] {
  5408. repeat = true
  5409. break
  5410. }
  5411. }
  5412. if !repeat {
  5413. newArr = append(newArr, arr[i])
  5414. }
  5415. }
  5416. return
  5417. }