his_api_controller.go 188KB

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