his_api_controller.go 202KB

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