his_api_controller.go 202KB

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