sz_his_api_controller.go 158KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517
  1. package sz
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "gdyb/controllers"
  6. "gdyb/enums"
  7. "gdyb/models"
  8. "gdyb/service"
  9. "gdyb/utils"
  10. "github.com/astaxie/beego"
  11. "github.com/axgle/mahonia"
  12. "math/rand"
  13. //"github.com/axgle/mahonia"
  14. "math"
  15. //"math/rand"
  16. "strconv"
  17. "strings"
  18. //"strings"
  19. "syscall"
  20. "time"
  21. "unsafe"
  22. )
  23. type Result struct {
  24. Transtime string `json:"transTime"`
  25. Transtype string `json:"transType"`
  26. Transreturncode string `json:"transReturnCode"`
  27. Transreturnmessage string `json:"transReturnMessage"`
  28. Transversion string `json:"transVersion"`
  29. Serialnumber string `json:"serialNumber"`
  30. Cardarea string `json:"cardArea"`
  31. Hospitalcode string `json:"hospitalCode"`
  32. Operatorcode string `json:"operatorCode"`
  33. Operatorname string `json:"operatorName"`
  34. Operatorpass string `json:"operatorPass"`
  35. Transbody struct {
  36. Akc190 string `json:"akc190"`
  37. Listsize int `json:"listsize"`
  38. Outputlist []struct {
  39. Aae072 string `json:"aae072"`
  40. Bkc369 string `json:"bkc369"`
  41. Bkf500 string `json:"bkf500"`
  42. Aka111 string `json:"aka111"`
  43. Ake001 string `json:"ake001"`
  44. Ake002 string `json:"ake002"`
  45. Bkm017 string `json:"bkm017"`
  46. Ake005 string `json:"ake005"`
  47. Ake006 string `json:"ake006"`
  48. Akc225 float64 `json:"akc225"`
  49. Akc226 float64 `json:"akc226"`
  50. Akc264 float64 `json:"akc264"`
  51. Aka065 string `json:"aka065"`
  52. Cka319 float64 `json:"cka319"`
  53. Akc268 float64 `json:"akc268"`
  54. } `json:"outputlist"`
  55. } `json:"transBody"`
  56. Verifycode string `json:"verifyCode"`
  57. Extenddeviceid string `json:"extendDeviceId"`
  58. Transchannel string `json:"transChannel"`
  59. Extenduserid string `json:"extendUserId"`
  60. Extendserialnumber string `json:"extendSerialNumber"`
  61. Caz055 string `json:"caz055"`
  62. Aae501 string `json:"aae501"`
  63. }
  64. type ResultOne struct {
  65. Transtime string `json:"transTime"`
  66. Transtype string `json:"transType"`
  67. Transreturncode string `json:"transReturnCode"`
  68. Transreturnmessage string `json:"transReturnMessage"`
  69. Transversion string `json:"transVersion"`
  70. Serialnumber string `json:"serialNumber"`
  71. Cardarea string `json:"cardArea"`
  72. Hospitalcode string `json:"hospitalCode"`
  73. Operatorcode string `json:"operatorCode"`
  74. Operatorname string `json:"operatorName"`
  75. Operatorpass string `json:"operatorPass"`
  76. Transbody struct {
  77. Ckc618 string `json:"ckc618"`
  78. Akc264 float64 `json:"akc264"`
  79. Akb068 int `json:"akb068"`
  80. Akb066 float64 `json:"akb066"`
  81. Akb067 int `json:"akb067"`
  82. Aae240 float64 `json:"aae240"`
  83. Outputlist []struct {
  84. Aaa036 string `json:"aaa036"`
  85. Aae019 float64 `json:"aae019"`
  86. } `json:"outputlist"`
  87. Outputlist2 []interface{} `json:"outputlist2"`
  88. } `json:"transBody"`
  89. Verifycode string `json:"verifyCode"`
  90. Extenddeviceid string `json:"extendDeviceId"`
  91. Transchannel string `json:"transChannel"`
  92. Extenduserid string `json:"extendUserId"`
  93. Extendserialnumber string `json:"extendSerialNumber"`
  94. Caz055 string `json:"caz055"`
  95. Aae501 string `json:"aae501"`
  96. }
  97. type ResultTwo struct {
  98. Transtime string `json:"transTime"`
  99. Transtype string `json:"transType"`
  100. Transreturncode string `json:"transReturnCode"`
  101. Transreturnmessage string `json:"transReturnMessage"`
  102. Transversion string `json:"transVersion"`
  103. Serialnumber string `json:"serialNumber"`
  104. Cardarea string `json:"cardArea"`
  105. Hospitalcode string `json:"hospitalCode"`
  106. Operatorcode string `json:"operatorCode"`
  107. Operatorname string `json:"operatorName"`
  108. Operatorpass string `json:"operatorPass"`
  109. Transbody struct {
  110. Ckc618 string `json:"ckc618"`
  111. Akc264 float64 `json:"akc264"`
  112. Akb068 float64 `json:"akb068"`
  113. Akb066 float64 `json:"akb066"`
  114. Akb067 float64 `json:"akb067"`
  115. Aae240 float64 `json:"aae240"`
  116. Outputlist1 []struct {
  117. Aka111 string `json:"aka111"`
  118. Bka058 float64 `json:"bka058"`
  119. } `json:"outputlist1"`
  120. Outputlist2 []struct {
  121. Aaa036 string `json:"aaa036"`
  122. Aae019 float64 `json:"aae019"`
  123. } `json:"outputlist2"`
  124. Outputlist3 []interface{} `json:"outputlist3"`
  125. } `json:"transBody"`
  126. Verifycode string `json:"verifyCode"`
  127. Extenddeviceid string `json:"extendDeviceId"`
  128. Transchannel string `json:"transChannel"`
  129. Extenduserid string `json:"extendUserId"`
  130. Extendserialnumber string `json:"extendSerialNumber"`
  131. Caz055 string `json:"caz055"`
  132. Aae501 string `json:"aae501"`
  133. }
  134. type ResultThree struct {
  135. Transtime string `json:"transTime"`
  136. Transtype string `json:"transType"`
  137. Transreturncode string `json:"transReturnCode"`
  138. Transreturnmessage string `json:"transReturnMessage"`
  139. Transversion string `json:"transVersion"`
  140. Serialnumber string `json:"serialNumber"`
  141. Cardarea string `json:"cardArea"`
  142. Hospitalcode string `json:"hospitalCode"`
  143. Operatorcode string `json:"operatorCode"`
  144. Operatorname string `json:"operatorName"`
  145. Operatorpass string `json:"operatorPass"`
  146. Transbody struct {
  147. Baz700 string `json:"baz700"`
  148. Ckc618 string `json:"ckc618"`
  149. } `json:"transBody"`
  150. Verifycode string `json:"verifyCode"`
  151. Extenddeviceid string `json:"extendDeviceId"`
  152. Transchannel string `json:"transChannel"`
  153. Extenduserid string `json:"extendUserId"`
  154. Extendserialnumber string `json:"extendSerialNumber"`
  155. Caz055 string `json:"caz055"`
  156. Aae501 string `json:"aae501"`
  157. }
  158. type ResultFive struct {
  159. Transtime string `json:"transTime"`
  160. Transtype string `json:"transType"`
  161. Transreturncode string `json:"transReturnCode"`
  162. Transreturnmessage string `json:"transReturnMessage"`
  163. Transversion string `json:"transVersion"`
  164. Serialnumber string `json:"serialNumber"`
  165. Cardarea string `json:"cardArea"`
  166. Hospitalcode string `json:"hospitalCode"`
  167. Operatorcode string `json:"operatorCode"`
  168. Operatorname string `json:"operatorName"`
  169. Operatorpass string `json:"operatorPass"`
  170. Transbody struct {
  171. Akc190 string `json:"akc190"`
  172. Listsize int `json:"listsize"`
  173. Outputlist []struct {
  174. Aae072 string `json:"aae072"`
  175. Bkf500 string `json:"bkf500"`
  176. Baz700 string `json:"baz700"`
  177. Bce574 string `json:"bce574"`
  178. } `json:"outputlist"`
  179. } `json:"transBody"`
  180. Verifycode string `json:"verifyCode"`
  181. Extenddeviceid string `json:"extendDeviceId"`
  182. Transchannel string `json:"transChannel"`
  183. Extenduserid string `json:"extendUserId"`
  184. Extendserialnumber string `json:"extendSerialNumber"`
  185. Caz055 string `json:"caz055"`
  186. Aae501 string `json:"aae501"`
  187. }
  188. type ResultFour struct {
  189. Transtime string `json:"transTime"`
  190. Transtype string `json:"transType"`
  191. Transreturncode string `json:"transReturnCode"`
  192. Transreturnmessage string `json:"transReturnMessage"`
  193. Transversion string `json:"transVersion"`
  194. Serialnumber string `json:"serialNumber"`
  195. Cardarea string `json:"cardArea"`
  196. Hospitalcode string `json:"hospitalCode"`
  197. Operatorcode string `json:"operatorCode"`
  198. Operatorname string `json:"operatorName"`
  199. Operatorpass string `json:"operatorPass"`
  200. Transbody struct {
  201. Akc190 string `json:"akc190"`
  202. Akc194 int `json:"akc194"`
  203. Bae917 int64 `json:"bae917"`
  204. Aka018 string `json:"aka018"`
  205. Aka030 string `json:"aka030"`
  206. Ckc618 string `json:"ckc618"`
  207. Akc264 float64 `json:"akc264"`
  208. Akb068 float64 `json:"akb068"`
  209. Akb066 float64 `json:"akb066"`
  210. Akb067 float64 `json:"akb067"`
  211. Cke298 float64 `json:"cke298"`
  212. Aae240 float64 `json:"aae240"`
  213. Outputlist1 []struct {
  214. Aae072 string `json:"aae072"`
  215. Bkc369 string `json:"bkc369"`
  216. Bkf500 string `json:"bkf500"`
  217. Aka111 string `json:"aka111"`
  218. Ake001 string `json:"ake001"`
  219. Ake002 string `json:"ake002"`
  220. Bkm017 string `json:"bkm017"`
  221. Ake005 string `json:"ake005"`
  222. Ake006 string `json:"ake006"`
  223. Ala026 string `json:"ala026"`
  224. Aka070 string `json:"aka070"`
  225. Aka074 string `json:"aka074"`
  226. Akc226 float64 `json:"akc226"`
  227. Akc225 float64 `json:"akc225"`
  228. Akc264 float64 `json:"akc264"`
  229. Aka067 string `json:"aka067"`
  230. Akc271 int `json:"akc271"`
  231. Bkc320 string `json:"bkc320"`
  232. Cke400 string `json:"cke400"`
  233. Ckc618 string `json:"ckc618"`
  234. Bka069 int64 `json:"bka069"`
  235. Aka018 string `json:"aka018"`
  236. Aka030 string `json:"aka030"`
  237. Aka065 string `json:"aka065"`
  238. Cka319 float64 `json:"cka319"`
  239. Akc268 float64 `json:"akc268"`
  240. } `json:"outputlist1"`
  241. Outputlist2 []struct {
  242. Aka111 string `json:"aka111"`
  243. Bka058 float64 `json:"bka058"`
  244. } `json:"outputlist2"`
  245. Outputlist3 []struct {
  246. Aaa036 string `json:"aaa036"`
  247. Aae019 float64 `json:"aae019"`
  248. } `json:"outputlist3"`
  249. } `json:"transBody"`
  250. Verifycode string `json:"verifyCode"`
  251. Extenddeviceid string `json:"extendDeviceId"`
  252. Transchannel string `json:"transChannel"`
  253. Extenduserid string `json:"extendUserId"`
  254. Extendserialnumber string `json:"extendSerialNumber"`
  255. Caz055 string `json:"caz055"`
  256. Aae501 string `json:"aae501"`
  257. }
  258. type SZHisApiController struct {
  259. controllers.BaseAuthAPIController
  260. }
  261. func SZHisManagerApiRegistRouters() {
  262. //挂号
  263. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  264. //上传明细,预结算
  265. //beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  266. //结算
  267. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  268. //退费
  269. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  270. beego.Router("/sz/api/readcard", &SZHisApiController{}, "get:ReadCard")
  271. beego.Router("sz/api/refundnumber/get", &SZHisApiController{}, "get:RefundNumber")
  272. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  273. //查询交易
  274. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  275. //撤销明细
  276. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  277. //
  278. ////机构药品目录备案
  279. beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  280. ////协议机构诊疗项目
  281. beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  282. ////协议机构目录备案撤销
  283. beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  284. //
  285. ////定点机构约定信息查询
  286. //beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  287. ////-医药师信息登记
  288. beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  289. ////医药师执业状态变更
  290. beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  291. ////医药师信息更新
  292. //beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  293. ////协议机构材料目录备案
  294. //
  295. beego.Router("/sz/api/goods/get", &SZHisApiController{}, "get:GetGoodsList")
  296. }
  297. func IntPtr(n int) uintptr {
  298. return uintptr(n)
  299. }
  300. func StrPtr(s string) uintptr {
  301. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  302. }
  303. type Custom struct {
  304. DetItemFeeSumamt string
  305. Cut string
  306. FeedetlSn string
  307. Price string
  308. MedListCodg string
  309. Type int64
  310. AdviceId int64
  311. ProjectId int64
  312. ItemId int64
  313. }
  314. func (c *SZHisApiController) ReadCard() {
  315. id_card_type, _ := c.GetInt64("id_card_type")
  316. adminInfo := c.GetAdminUserInfo()
  317. if id_card_type != 1 {
  318. c.ServeFailJSONWithSGJErrorCode(enums.ErrorNoReadCardException)
  319. return
  320. }
  321. month := time.Unix(1557042972, 0).Format("1")
  322. year := time.Now().Format("2006")
  323. month = time.Now().Format("01")
  324. day := time.Now().Format("02")
  325. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  326. number := miConfig.Code + year + month + day +
  327. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  328. id_card_number, health_card_no, _, ret4 := ReadBasCard("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  329. if ret4 == 0 {
  330. patient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  331. if patient.ID == 0 {
  332. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  333. return
  334. } else {
  335. c.ServeSuccessJSON(map[string]interface{}{
  336. "patient": patient,
  337. "health_card_no": health_card_no,
  338. })
  339. }
  340. } else {
  341. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  342. return
  343. }
  344. }
  345. //获取读卡信息 -- 门诊挂号
  346. //func (c *SZHisApiController) GetRegisterInfo() {
  347. // adminInfo := c.GetAdminUserInfo()
  348. // admin_user_id, _ := c.GetInt64("admin_user_id")
  349. // patient_id, _ := c.GetInt64("id")
  350. // record_time := c.GetString("record_time")
  351. // settlementValue, _ := c.GetInt64("settlement_value")
  352. // medical_insurance_card := c.GetString("medical_insurance_card")
  353. // name := c.GetString("name")
  354. // id_card_type, _ := c.GetInt64("id_card_type")
  355. // certificates, _ := c.GetInt64("certificates")
  356. // medical_care, _ := c.GetInt64("medical_care")
  357. // birthday := c.GetString("birthday")
  358. // id_card := c.GetString("id_card")
  359. // register_type, _ := c.GetInt64("register")
  360. // doctor, _ := c.GetInt64("doctor")
  361. // department, _ := c.GetInt64("department")
  362. // gender, _ := c.GetInt64("sex")
  363. // registration_fee, _ := c.GetFloat("registration_fee")
  364. // medical_expenses, _ := c.GetFloat("medical_expenses")
  365. // social_type, _ := c.GetInt64("social_type")
  366. //
  367. // is_yidi, _ := c.GetInt64("is_yidi")
  368. //
  369. // timeLayout := "2006-01-02"
  370. // loc, _ := time.LoadLocation("Local")
  371. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  372. // birthUnix := birthdays.Unix()
  373. //
  374. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  375. // if err != nil {
  376. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  377. // return
  378. // }
  379. //
  380. // var patient service.Patients
  381. // if patient_id == 0 {
  382. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  383. // } else {
  384. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  385. // }
  386. //
  387. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  388. // if patient.ID == 0 {
  389. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  390. // return
  391. // }
  392. // if len(patient.IdCardNo) == 0 {
  393. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  394. // return
  395. // }
  396. //
  397. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  398. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  399. //
  400. // var custom_code string
  401. // var custom_project_name string
  402. // var allPrice float64
  403. //
  404. // switch register_type {
  405. // case 1:
  406. // custom_code = "110100002"
  407. // custom_project_name = "普通门诊"
  408. // allPrice = 10
  409. // break
  410. // case 3:
  411. // custom_code = "110200002-2"
  412. // custom_project_name = "主任医师"
  413. // allPrice = 10
  414. //
  415. // break
  416. // case 2:
  417. // custom_code = "110200002-3"
  418. // custom_project_name = "副主任医师"
  419. // allPrice = 10
  420. //
  421. // break
  422. // case 4:
  423. // custom_code = "0"
  424. // custom_project_name = "免受诊金"
  425. // allPrice = 0
  426. // break
  427. // case 5:
  428. // custom_code = "110200002-1"
  429. // custom_project_name = "专家"
  430. // allPrice = 10
  431. //
  432. // break
  433. // }
  434. //
  435. // if his.ID == 0 {
  436. //
  437. // var doctor_name string
  438. // var doctor_code string
  439. // if adminRole.ID == 0 {
  440. //
  441. // doctor_name = ""
  442. // doctor_code = "1001"
  443. // doctor_name = ""
  444. // doctor_code = ""
  445. //
  446. // } else {
  447. // doctor_name = adminRole.UserName
  448. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  449. //
  450. // }
  451. // month := time.Unix(1557042972, 0).Format("1")
  452. // year := time.Now().Format("2006")
  453. // month = time.Now().Format("01")
  454. // day := time.Now().Format("02")
  455. //
  456. // //流水号
  457. // //
  458. // number := miConfig.Code + year + month + day +
  459. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  460. // mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  461. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  462. // //1.判断读卡类型
  463. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  464. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  465. // fmt.Println(yiliao_number)
  466. // fmt.Println(id_card_number)
  467. // fmt.Println(verifyCode)
  468. // fmt.Println(version_code)
  469. // fmt.Println(ret4)
  470. //
  471. // dept_code := "0305"
  472. // is_yidi = 1
  473. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  474. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  475. // if tempPatient.ID == patient_id {
  476. // if ret4 == 0 { //本地卡流程
  477. // if is_yidi == 1 {
  478. // //本地就医流程
  479. // //挂号
  480. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice,medical_care)
  481. // var dat map[string]interface{}
  482. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  483. // fmt.Println(dat)
  484. // } else {
  485. // fmt.Println(err)
  486. // }
  487. // userJSONBytes, _ := json.Marshal(dat)
  488. // var res ResultOne
  489. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  490. // utils.ErrorLog("解析失败:%v", err)
  491. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  492. // return
  493. // }
  494. // if res.Transreturncode == "00000000" {
  495. // his := models.VMHisPatient{
  496. // Name: name,
  497. // Gender: gender,
  498. // Birthday: birthUnix,
  499. // MedicalTreatmentType: medical_care,
  500. // IdType: certificates,
  501. // IdCardNo: id_card,
  502. // BalanceAccountsType: settlementValue,
  503. // SocialType: social_type,
  504. // MedicalInsuranceNumber: medical_insurance_card,
  505. // RegisterType: register_type,
  506. // RegisterCost: registration_fee,
  507. // TreatmentCost: medical_expenses,
  508. // Status: 1,
  509. // Ctime: time.Now().Unix(),
  510. // Mtime: time.Now().Unix(),
  511. // Iinfo: resp_result,
  512. // PatientId: patient.ID,
  513. // RecordDate: theTime.Unix(),
  514. // UserOrgId: adminInfo.CurrentOrgId,
  515. // AdminUserId: admin_user_id,
  516. // IsReturn: 1,
  517. // IdCardType: id_card_type,
  518. // Doctor: doctor,
  519. // Departments: department,
  520. // YiliaoNumber: yiliao_number,
  521. // MzNumber: number,
  522. // Number: mz_number,
  523. // }
  524. // service.CreateHisPatientTwo(&his)
  525. // c.ServeSuccessJSON(map[string]interface{}{
  526. // "msg": "挂号成功",
  527. // })
  528. // } else {
  529. // c.ServeSuccessJSON(map[string]interface{}{
  530. // "failed_code": -10,
  531. // "msg": res.Transreturnmessage,
  532. // })
  533. // return
  534. // }
  535. //
  536. // } else {
  537. // //异地就医流程
  538. // //异地走鉴权流程
  539. // //authResult := CardAuth(number)
  540. // //fmt.Println(authResult)
  541. //
  542. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  543. // //if tempPatient.ID == patient_id {
  544. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  545. // var dat map[string]interface{}
  546. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  547. // fmt.Println(dat)
  548. // } else {
  549. // fmt.Println(err)
  550. // }
  551. //
  552. // userJSONBytes, _ := json.Marshal(dat)
  553. //
  554. // var res ResultOne
  555. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  556. // utils.ErrorLog("解析失败:%v", err)
  557. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  558. // return
  559. // }
  560. // if res.Transreturncode == "00000000" {
  561. // his := models.VMHisPatient{
  562. // Name: name,
  563. // Gender: gender,
  564. // Birthday: birthUnix,
  565. // MedicalTreatmentType: medical_care,
  566. // IdType: certificates,
  567. // IdCardNo: id_card,
  568. // BalanceAccountsType: settlementValue,
  569. // SocialType: social_type,
  570. // MedicalInsuranceNumber: medical_insurance_card,
  571. // RegisterType: register_type,
  572. // RegisterCost: registration_fee,
  573. // TreatmentCost: medical_expenses,
  574. // Status: 1,
  575. // Ctime: time.Now().Unix(),
  576. // Mtime: time.Now().Unix(),
  577. // Iinfo: resp_result,
  578. // PatientId: patient.ID,
  579. // RecordDate: theTime.Unix(),
  580. // UserOrgId: adminInfo.CurrentOrgId,
  581. // AdminUserId: admin_user_id,
  582. // IsReturn: 1,
  583. // IdCardType: id_card_type,
  584. // Doctor: doctor,
  585. // Departments: department,
  586. // YiliaoNumber: yiliao_number,
  587. // MzNumber: number,
  588. // Number: mz_number,
  589. // }
  590. // service.CreateHisPatientTwo(&his)
  591. // c.ServeSuccessJSON(map[string]interface{}{
  592. // "msg": "挂号成功",
  593. // })
  594. // } else {
  595. // c.ServeSuccessJSON(map[string]interface{}{
  596. // "failed_code": -10,
  597. // "msg": res.Transreturnmessage,
  598. // })
  599. // return
  600. // }
  601. //
  602. // }
  603. //
  604. // } else { //异地卡流程
  605. // //readCardBasResult := ReadCardBasHSM(number)
  606. // //fmt.Println(readCardBasResult)
  607. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  608. // if is_yidi == 1 { //1本地就医
  609. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  610. // var dat map[string]interface{}
  611. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  612. // fmt.Println(dat)
  613. // } else {
  614. // fmt.Println(err)
  615. // }
  616. //
  617. // userJSONBytes, _ := json.Marshal(dat)
  618. //
  619. // var res ResultOne
  620. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  621. // utils.ErrorLog("解析失败:%v", err)
  622. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  623. // return
  624. // }
  625. // if res.Transreturncode == "00000000" {
  626. // his := models.VMHisPatient{
  627. // Name: name,
  628. // Gender: gender,
  629. // Birthday: birthUnix,
  630. // MedicalTreatmentType: medical_care,
  631. // IdType: certificates,
  632. // IdCardNo: id_card,
  633. // BalanceAccountsType: settlementValue,
  634. // SocialType: social_type,
  635. // MedicalInsuranceNumber: medical_insurance_card,
  636. // RegisterType: register_type,
  637. // RegisterCost: registration_fee,
  638. // TreatmentCost: medical_expenses,
  639. // Status: 1,
  640. // Ctime: time.Now().Unix(),
  641. // Mtime: time.Now().Unix(),
  642. // Iinfo: resp_result,
  643. // PatientId: patient.ID,
  644. // RecordDate: theTime.Unix(),
  645. // UserOrgId: adminInfo.CurrentOrgId,
  646. // AdminUserId: admin_user_id,
  647. // IsReturn: 1,
  648. // IdCardType: id_card_type,
  649. // Doctor: doctor,
  650. // Departments: department,
  651. // YiliaoNumber: yiliao_number,
  652. // MzNumber: number,
  653. // Number: mz_number,
  654. // }
  655. // service.CreateHisPatientTwo(&his)
  656. // c.ServeSuccessJSON(map[string]interface{}{
  657. // "msg": "挂号成功",
  658. // })
  659. // } else {
  660. // c.ServeSuccessJSON(map[string]interface{}{
  661. // "failed_code": -10,
  662. // "msg": res.Transreturnmessage,
  663. // })
  664. // return
  665. // }
  666. //
  667. // } else { //异地就医需要走鉴权流程
  668. // //authResult := CardAuth(number)
  669. // //fmt.Println(authResult)
  670. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice)
  671. // var dat map[string]interface{}
  672. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  673. // fmt.Println(dat)
  674. // } else {
  675. // fmt.Println(err)
  676. // }
  677. //
  678. // userJSONBytes, _ := json.Marshal(dat)
  679. //
  680. // var res ResultOne
  681. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  682. // utils.ErrorLog("解析失败:%v", err)
  683. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  684. // return
  685. // }
  686. // if res.Transreturncode == "00000000" {
  687. // his := models.VMHisPatient{
  688. // Name: name,
  689. // Gender: gender,
  690. // Birthday: birthUnix,
  691. // MedicalTreatmentType: medical_care,
  692. // IdType: certificates,
  693. // IdCardNo: id_card,
  694. // BalanceAccountsType: settlementValue,
  695. // SocialType: social_type,
  696. // MedicalInsuranceNumber: medical_insurance_card,
  697. // RegisterType: register_type,
  698. // RegisterCost: registration_fee,
  699. // TreatmentCost: medical_expenses,
  700. // Status: 1,
  701. // Ctime: time.Now().Unix(),
  702. // Mtime: time.Now().Unix(),
  703. // Iinfo: resp_result,
  704. // PatientId: patient.ID,
  705. // RecordDate: theTime.Unix(),
  706. // UserOrgId: adminInfo.CurrentOrgId,
  707. // AdminUserId: admin_user_id,
  708. // IsReturn: 1,
  709. // IdCardType: id_card_type,
  710. // Doctor: doctor,
  711. // Departments: department,
  712. // YiliaoNumber: yiliao_number,
  713. // MzNumber: number,
  714. // Number: mz_number,
  715. // }
  716. // service.CreateHisPatientTwo(&his)
  717. // c.ServeSuccessJSON(map[string]interface{}{
  718. // "msg": "挂号成功",
  719. // })
  720. // } else {
  721. // c.ServeSuccessJSON(map[string]interface{}{
  722. // "failed_code": -10,
  723. // "msg": res.Transreturnmessage,
  724. // })
  725. // return
  726. // }
  727. //
  728. // }
  729. // }
  730. // } else {
  731. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  732. // return
  733. // }
  734. // } else {
  735. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  736. // return
  737. // }
  738. //}
  739. func (c *SZHisApiController) GetRegisterInfo() {
  740. adminInfo := c.GetAdminUserInfo()
  741. admin_user_id, _ := c.GetInt64("admin_user_id")
  742. patient_id, _ := c.GetInt64("id")
  743. record_time := c.GetString("record_time")
  744. settlementValue, _ := c.GetInt64("settlement_value")
  745. medical_insurance_card := c.GetString("medical_insurance_card")
  746. name := c.GetString("name")
  747. id_card_type, _ := c.GetInt64("id_card_type")
  748. certificates, _ := c.GetInt64("certificates")
  749. medical_care, _ := c.GetInt64("medical_care")
  750. birthday := c.GetString("birthday")
  751. id_card := c.GetString("id_card")
  752. register_type, _ := c.GetInt64("register")
  753. doctor, _ := c.GetInt64("doctor")
  754. department, _ := c.GetInt64("department")
  755. gender, _ := c.GetInt64("sex")
  756. registration_fee, _ := c.GetFloat("registration_fee")
  757. medical_expenses, _ := c.GetFloat("medical_expenses")
  758. social_type, _ := c.GetInt64("social_type")
  759. is_yidi, _ := c.GetInt64("is_yidi")
  760. timeLayout := "2006-01-02"
  761. loc, _ := time.LoadLocation("Local")
  762. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  763. birthUnix := birthdays.Unix()
  764. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  765. if err != nil {
  766. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  767. return
  768. }
  769. var patient service.Patients
  770. if patient_id == 0 {
  771. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  772. } else {
  773. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  774. }
  775. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  776. if patient.ID == 0 {
  777. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  778. return
  779. }
  780. if len(patient.IdCardNo) == 0 {
  781. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  782. return
  783. }
  784. //doctorInfo, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, doctor)
  785. doctorDepartment, _ := service.GetDepartMentDetail(department)
  786. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  787. his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  788. var custom_code string
  789. var custom_project_name string
  790. var allPrice float64
  791. switch register_type {
  792. case 1:
  793. custom_code = "110100002"
  794. custom_project_name = "普通门诊"
  795. allPrice = 10
  796. break
  797. case 3:
  798. custom_code = "110200002-2"
  799. custom_project_name = "主任医师"
  800. allPrice = 10
  801. break
  802. case 2:
  803. custom_code = "110200002-3"
  804. custom_project_name = "副主任医师"
  805. allPrice = 10
  806. break
  807. case 4:
  808. custom_code = "0"
  809. custom_project_name = "免受诊金"
  810. allPrice = 0
  811. break
  812. case 5:
  813. custom_code = "110200002-1"
  814. custom_project_name = "专家"
  815. allPrice = 10
  816. break
  817. }
  818. if his.ID == 0 {
  819. var opera_name string
  820. var opera_code string
  821. if adminRole.ID == 0 {
  822. opera_name = "管理员"
  823. opera_code = "01"
  824. } else {
  825. opera_name = adminRole.UserName
  826. opera_code = strconv.FormatInt(admin_user_id, 10)
  827. }
  828. month := time.Unix(1557042972, 0).Format("1")
  829. year := time.Now().Format("2006")
  830. month = time.Now().Format("01")
  831. day := time.Now().Format("02")
  832. //流水号
  833. number := miConfig.Code + year + month + day +
  834. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  835. mz_number := miConfig.Code + year + month + day +
  836. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  837. //1.判断读卡类型
  838. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  839. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  840. fmt.Println(yiliao_number)
  841. fmt.Println(id_card_number)
  842. fmt.Println(verifyCode)
  843. fmt.Println(version_code)
  844. fmt.Println(ret4)
  845. dept_code := doctorDepartment.Number
  846. is_yidi = 1
  847. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  848. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  849. fmt.Println(tempPatient.ID)
  850. fmt.Println(patient_id)
  851. if tempPatient.ID == patient_id {
  852. if ret4 == 0 { //本地卡流程
  853. if is_yidi == 1 {
  854. //本地就医流程
  855. //挂号
  856. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  857. var dat map[string]interface{}
  858. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  859. fmt.Println(dat)
  860. } else {
  861. fmt.Println(err)
  862. }
  863. userJSONBytes, _ := json.Marshal(dat)
  864. var res ResultOne
  865. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  866. utils.ErrorLog("解析失败:%v", err)
  867. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  868. return
  869. }
  870. if res.Transreturncode == "00000000" {
  871. his := models.VMHisPatient{
  872. Name: name,
  873. Gender: gender,
  874. Birthday: birthUnix,
  875. MedicalTreatmentType: medical_care,
  876. IdType: certificates,
  877. IdCardNo: id_card,
  878. BalanceAccountsType: settlementValue,
  879. SocialType: social_type,
  880. MedicalInsuranceNumber: medical_insurance_card,
  881. RegisterType: register_type,
  882. RegisterCost: registration_fee,
  883. TreatmentCost: medical_expenses,
  884. Status: 1,
  885. Ctime: time.Now().Unix(),
  886. Mtime: time.Now().Unix(),
  887. Iinfo: resp_result,
  888. PatientId: patient.ID,
  889. RecordDate: theTime.Unix(),
  890. UserOrgId: adminInfo.CurrentOrgId,
  891. AdminUserId: admin_user_id,
  892. IsReturn: 1,
  893. IdCardType: id_card_type,
  894. Doctor: doctor,
  895. Departments: department,
  896. YiliaoNumber: yiliao_number,
  897. MzNumber: number,
  898. Number: mz_number,
  899. PsnNo: health_card_no,
  900. }
  901. service.CreateHisPatientTwo(&his)
  902. c.ServeSuccessJSON(map[string]interface{}{
  903. "msg": "挂号成功",
  904. })
  905. } else {
  906. c.ServeSuccessJSON(map[string]interface{}{
  907. "failed_code": -10,
  908. "msg": res.Transreturnmessage,
  909. })
  910. return
  911. }
  912. } else {
  913. //异地就医流程
  914. //异地走鉴权流程
  915. //authResult := CardAuth(number)
  916. //fmt.Println(authResult)
  917. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  918. //if tempPatient.ID == patient_id {
  919. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  920. var dat map[string]interface{}
  921. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  922. fmt.Println(dat)
  923. } else {
  924. fmt.Println(err)
  925. }
  926. userJSONBytes, _ := json.Marshal(dat)
  927. var res ResultOne
  928. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  929. utils.ErrorLog("解析失败:%v", err)
  930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  931. return
  932. }
  933. if res.Transreturncode == "00000000" {
  934. his := models.VMHisPatient{
  935. Name: name,
  936. Gender: gender,
  937. Birthday: birthUnix,
  938. MedicalTreatmentType: medical_care,
  939. IdType: certificates,
  940. IdCardNo: id_card,
  941. BalanceAccountsType: settlementValue,
  942. SocialType: social_type,
  943. MedicalInsuranceNumber: medical_insurance_card,
  944. RegisterType: register_type,
  945. RegisterCost: registration_fee,
  946. TreatmentCost: medical_expenses,
  947. Status: 1,
  948. Ctime: time.Now().Unix(),
  949. Mtime: time.Now().Unix(),
  950. Iinfo: resp_result,
  951. PatientId: patient.ID,
  952. RecordDate: theTime.Unix(),
  953. UserOrgId: adminInfo.CurrentOrgId,
  954. AdminUserId: admin_user_id,
  955. IsReturn: 1,
  956. IdCardType: id_card_type,
  957. Doctor: doctor,
  958. Departments: department,
  959. YiliaoNumber: yiliao_number,
  960. MzNumber: number,
  961. Number: mz_number,
  962. PsnNo: health_card_no,
  963. }
  964. service.CreateHisPatientTwo(&his)
  965. c.ServeSuccessJSON(map[string]interface{}{
  966. "msg": "挂号成功",
  967. })
  968. } else {
  969. c.ServeSuccessJSON(map[string]interface{}{
  970. "failed_code": -10,
  971. "msg": res.Transreturnmessage,
  972. })
  973. return
  974. }
  975. }
  976. } else { //异地卡流程
  977. //readCardBasResult := ReadCardBasHSM(number)
  978. //fmt.Println(readCardBasResult)
  979. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  980. if is_yidi == 1 { //1本地就医
  981. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  982. var dat map[string]interface{}
  983. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  984. fmt.Println(dat)
  985. } else {
  986. fmt.Println(err)
  987. }
  988. userJSONBytes, _ := json.Marshal(dat)
  989. var res ResultOne
  990. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  991. utils.ErrorLog("解析失败:%v", err)
  992. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  993. return
  994. }
  995. if res.Transreturncode == "00000000" {
  996. his := models.VMHisPatient{
  997. Name: name,
  998. Gender: gender,
  999. Birthday: birthUnix,
  1000. MedicalTreatmentType: medical_care,
  1001. IdType: certificates,
  1002. IdCardNo: id_card,
  1003. BalanceAccountsType: settlementValue,
  1004. SocialType: social_type,
  1005. MedicalInsuranceNumber: medical_insurance_card,
  1006. RegisterType: register_type,
  1007. RegisterCost: registration_fee,
  1008. TreatmentCost: medical_expenses,
  1009. Status: 1,
  1010. Ctime: time.Now().Unix(),
  1011. Mtime: time.Now().Unix(),
  1012. Iinfo: resp_result,
  1013. PatientId: patient.ID,
  1014. RecordDate: theTime.Unix(),
  1015. UserOrgId: adminInfo.CurrentOrgId,
  1016. AdminUserId: admin_user_id,
  1017. IsReturn: 1,
  1018. IdCardType: id_card_type,
  1019. Doctor: doctor,
  1020. Departments: department,
  1021. YiliaoNumber: yiliao_number,
  1022. MzNumber: number,
  1023. Number: mz_number,
  1024. PsnNo: health_card_no,
  1025. }
  1026. service.CreateHisPatientTwo(&his)
  1027. c.ServeSuccessJSON(map[string]interface{}{
  1028. "msg": "挂号成功",
  1029. })
  1030. } else {
  1031. c.ServeSuccessJSON(map[string]interface{}{
  1032. "failed_code": -10,
  1033. "msg": res.Transreturnmessage,
  1034. })
  1035. return
  1036. }
  1037. } else { //异地就医需要走鉴权流程
  1038. //authResult := CardAuth(number)
  1039. //fmt.Println(authResult)
  1040. resp_result := service.SzybMZ002(opera_name, opera_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1041. var dat map[string]interface{}
  1042. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1043. fmt.Println(dat)
  1044. } else {
  1045. fmt.Println(err)
  1046. }
  1047. userJSONBytes, _ := json.Marshal(dat)
  1048. var res ResultOne
  1049. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1050. utils.ErrorLog("解析失败:%v", err)
  1051. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1052. return
  1053. }
  1054. if res.Transreturncode == "00000000" {
  1055. his := models.VMHisPatient{
  1056. Name: name,
  1057. Gender: gender,
  1058. Birthday: birthUnix,
  1059. MedicalTreatmentType: medical_care,
  1060. IdType: certificates,
  1061. IdCardNo: id_card,
  1062. BalanceAccountsType: settlementValue,
  1063. SocialType: social_type,
  1064. MedicalInsuranceNumber: medical_insurance_card,
  1065. RegisterType: register_type,
  1066. RegisterCost: registration_fee,
  1067. TreatmentCost: medical_expenses,
  1068. Status: 1,
  1069. Ctime: time.Now().Unix(),
  1070. Mtime: time.Now().Unix(),
  1071. Iinfo: resp_result,
  1072. PatientId: patient.ID,
  1073. RecordDate: theTime.Unix(),
  1074. UserOrgId: adminInfo.CurrentOrgId,
  1075. AdminUserId: admin_user_id,
  1076. IsReturn: 1,
  1077. IdCardType: id_card_type,
  1078. Doctor: doctor,
  1079. Departments: department,
  1080. YiliaoNumber: yiliao_number,
  1081. MzNumber: number,
  1082. Number: mz_number,
  1083. PsnNo: health_card_no,
  1084. }
  1085. service.CreateHisPatientTwo(&his)
  1086. c.ServeSuccessJSON(map[string]interface{}{
  1087. "msg": "挂号成功",
  1088. })
  1089. } else {
  1090. c.ServeSuccessJSON(map[string]interface{}{
  1091. "failed_code": -10,
  1092. "msg": res.Transreturnmessage,
  1093. })
  1094. return
  1095. }
  1096. }
  1097. }
  1098. } else {
  1099. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1100. return
  1101. }
  1102. } else {
  1103. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1104. return
  1105. }
  1106. }
  1107. func (c *SZHisApiController) RefundNumber() {
  1108. record_time := c.GetString("record_time")
  1109. patient_id, _ := c.GetInt64("patient_id")
  1110. admin_user_id, _ := c.GetInt64("admin_user_id")
  1111. timeLayout := "2006-01-02"
  1112. loc, _ := time.LoadLocation("Local")
  1113. adminUser := c.GetAdminUserInfo()
  1114. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1115. fmt.Println(err)
  1116. if err != nil {
  1117. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1118. return
  1119. }
  1120. recordDateTime := theTime.Unix()
  1121. fmt.Println(recordDateTime)
  1122. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1123. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1124. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1125. //结算流程
  1126. var doctor_name string
  1127. var doctor_code string
  1128. if roles.ID == 0 {
  1129. doctor_name = "管理员"
  1130. doctor_code = "01"
  1131. } else {
  1132. doctor_name = roles.UserName
  1133. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1134. }
  1135. month := time.Unix(1557042972, 0).Format("1")
  1136. year := time.Now().Format("2006")
  1137. month = time.Now().Format("01")
  1138. day := time.Now().Format("02")
  1139. //number := miConfig.Code + year + month + day + "1367866"
  1140. number := miConfig.Code + year + month + day +
  1141. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1142. //number := miConfig.Code + year + month + day + "1590003"
  1143. //流水号
  1144. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1145. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1146. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1147. if config.IsOpen == 1 { //对接了医保,走医保流程
  1148. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, his.MzNumber, his.Number, verifyCode, number, version_code)
  1149. var dat map[string]interface{}
  1150. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1151. fmt.Println(dat)
  1152. } else {
  1153. fmt.Println(err)
  1154. }
  1155. userJSONBytes, _ := json.Marshal(dat)
  1156. var res ResultThree
  1157. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1158. utils.ErrorLog("解析失败:%v", err)
  1159. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1160. return
  1161. }
  1162. if res.Transreturncode == "00000000" {
  1163. service.UpdataHisStatusSZ(adminUser.CurrentOrgId, his.MzNumber, his.Number, result)
  1164. c.ServeSuccessJSON(map[string]interface{}{
  1165. "msg": "退号成功",
  1166. })
  1167. } else {
  1168. c.ServeSuccessJSON(map[string]interface{}{
  1169. "failed_code": -10,
  1170. "msg": res.Transreturnmessage,
  1171. })
  1172. }
  1173. }
  1174. }
  1175. //func (c *SZHisApiController) GetRegisterInfo() {
  1176. // adminInfo := c.GetAdminUserInfo()
  1177. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1178. // patient_id, _ := c.GetInt64("id")
  1179. // record_time := c.GetString("record_time")
  1180. // settlementValue, _ := c.GetInt64("settlement_value")
  1181. // medical_insurance_card := c.GetString("medical_insurance_card")
  1182. // name := c.GetString("name")
  1183. // id_card_type, _ := c.GetInt64("id_card_type")
  1184. // certificates, _ := c.GetInt64("certificates")
  1185. // medical_care, _ := c.GetInt64("medical_care")
  1186. // birthday := c.GetString("birthday")
  1187. // id_card := c.GetString("id_card")
  1188. // register_type, _ := c.GetInt64("register")
  1189. // doctor, _ := c.GetInt64("doctor")
  1190. // department, _ := c.GetInt64("department")
  1191. // gender, _ := c.GetInt64("sex")
  1192. // registration_fee, _ := c.GetFloat("registration_fee")
  1193. // medical_expenses, _ := c.GetFloat("medical_expenses")
  1194. // social_type, _ := c.GetInt64("social_type")
  1195. //
  1196. // is_yidi, _ := c.GetInt64("is_yidi")
  1197. //
  1198. // timeLayout := "2006-01-02"
  1199. // loc, _ := time.LoadLocation("Local")
  1200. // birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  1201. // birthUnix := birthdays.Unix()
  1202. //
  1203. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1204. // if err != nil {
  1205. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1206. // return
  1207. // }
  1208. //
  1209. // var patient service.Patients
  1210. // if patient_id == 0 {
  1211. // patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  1212. // } else {
  1213. // patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  1214. // }
  1215. //
  1216. // miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  1217. // if patient.ID == 0 {
  1218. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  1219. // return
  1220. // }
  1221. // if len(patient.IdCardNo) == 0 {
  1222. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  1223. // return
  1224. // }
  1225. //
  1226. // adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  1227. // his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  1228. //
  1229. // var custom_code string
  1230. // var custom_project_name string
  1231. // var allPrice float64
  1232. //
  1233. // switch register_type {
  1234. // case 1:
  1235. // custom_code = "110100002"
  1236. // custom_project_name = "普通门诊"
  1237. // allPrice = 10
  1238. // break
  1239. // case 3:
  1240. // custom_code = "110200002-2"
  1241. // custom_project_name = "主任医师"
  1242. // allPrice = 10
  1243. //
  1244. // break
  1245. // case 2:
  1246. // custom_code = "110200002-3"
  1247. // custom_project_name = "副主任医师"
  1248. // allPrice = 10
  1249. //
  1250. // break
  1251. // case 4:
  1252. // custom_code = "0"
  1253. // custom_project_name = "免受诊金"
  1254. // allPrice = 0
  1255. // break
  1256. // case 5:
  1257. // custom_code = "110200002-1"
  1258. // custom_project_name = "专家"
  1259. // allPrice = 10
  1260. //
  1261. // break
  1262. // }
  1263. //
  1264. // if his.ID == 0 {
  1265. //
  1266. // var doctor_name string
  1267. // var doctor_code string
  1268. // if adminRole.ID == 0 {
  1269. //
  1270. // doctor_name = "管理员"
  1271. // doctor_code = "01"
  1272. //
  1273. // } else {
  1274. // doctor_name = adminRole.UserName
  1275. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  1276. //
  1277. // }
  1278. // month := time.Unix(1557042972, 0).Format("1")
  1279. // year := time.Now().Format("2006")
  1280. // month = time.Now().Format("01")
  1281. // day := time.Now().Format("02")
  1282. //
  1283. // //流水号
  1284. // //
  1285. // number := miConfig.Code + year + month + day +
  1286. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1287. // mz_number := miConfig.Code + year + month + day +
  1288. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  1289. // //1.判断读卡类型
  1290. // //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  1291. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("MZ002" + "|" + number + "|" + miConfig.Code + "|")
  1292. // fmt.Println(yiliao_number)
  1293. // fmt.Println(id_card_number)
  1294. // fmt.Println(verifyCode)
  1295. // fmt.Println(version_code)
  1296. // fmt.Println(ret4)
  1297. //
  1298. // dept_code := "0306"
  1299. // is_yidi = 1
  1300. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1301. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1302. // fmt.Println(tempPatient.ID)
  1303. // fmt.Println(patient_id)
  1304. //
  1305. // if tempPatient.ID == patient_id {
  1306. // if ret4 == 0 { //本地卡流程
  1307. // if is_yidi == 1 {
  1308. // //本地就医流程
  1309. // //挂号
  1310. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, dept_code, yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1311. // var dat map[string]interface{}
  1312. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1313. // fmt.Println(dat)
  1314. // } else {
  1315. // fmt.Println(err)
  1316. // }
  1317. // userJSONBytes, _ := json.Marshal(dat)
  1318. // var res ResultOne
  1319. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1320. // utils.ErrorLog("解析失败:%v", err)
  1321. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1322. // return
  1323. // }
  1324. // if res.Transreturncode == "00000000" {
  1325. // his := models.VMHisPatient{
  1326. // Name: name,
  1327. // Gender: gender,
  1328. // Birthday: birthUnix,
  1329. // MedicalTreatmentType: medical_care,
  1330. // IdType: certificates,
  1331. // IdCardNo: id_card,
  1332. // BalanceAccountsType: settlementValue,
  1333. // SocialType: social_type,
  1334. // MedicalInsuranceNumber: medical_insurance_card,
  1335. // RegisterType: register_type,
  1336. // RegisterCost: registration_fee,
  1337. // TreatmentCost: medical_expenses,
  1338. // Status: 1,
  1339. // Ctime: time.Now().Unix(),
  1340. // Mtime: time.Now().Unix(),
  1341. // Iinfo: resp_result,
  1342. // PatientId: patient.ID,
  1343. // RecordDate: theTime.Unix(),
  1344. // UserOrgId: adminInfo.CurrentOrgId,
  1345. // AdminUserId: admin_user_id,
  1346. // IsReturn: 1,
  1347. // IdCardType: id_card_type,
  1348. // Doctor: doctor,
  1349. // Departments: department,
  1350. // YiliaoNumber: yiliao_number,
  1351. // MzNumber: number,
  1352. // Number: mz_number,
  1353. // }
  1354. // service.CreateHisPatientTwo(&his)
  1355. // c.ServeSuccessJSON(map[string]interface{}{
  1356. // "msg": "挂号成功",
  1357. // })
  1358. // } else {
  1359. // c.ServeSuccessJSON(map[string]interface{}{
  1360. // "failed_code": -10,
  1361. // "msg": res.Transreturnmessage,
  1362. // })
  1363. // return
  1364. // }
  1365. //
  1366. // } else {
  1367. // //异地就医流程
  1368. // //异地走鉴权流程
  1369. // //authResult := CardAuth(number)
  1370. // //fmt.Println(authResult)
  1371. //
  1372. // //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  1373. // //if tempPatient.ID == patient_id {
  1374. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1375. // var dat map[string]interface{}
  1376. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1377. // fmt.Println(dat)
  1378. // } else {
  1379. // fmt.Println(err)
  1380. // }
  1381. //
  1382. // userJSONBytes, _ := json.Marshal(dat)
  1383. //
  1384. // var res ResultOne
  1385. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1386. // utils.ErrorLog("解析失败:%v", err)
  1387. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1388. // return
  1389. // }
  1390. // if res.Transreturncode == "00000000" {
  1391. // his := models.VMHisPatient{
  1392. // Name: name,
  1393. // Gender: gender,
  1394. // Birthday: birthUnix,
  1395. // MedicalTreatmentType: medical_care,
  1396. // IdType: certificates,
  1397. // IdCardNo: id_card,
  1398. // BalanceAccountsType: settlementValue,
  1399. // SocialType: social_type,
  1400. // MedicalInsuranceNumber: medical_insurance_card,
  1401. // RegisterType: register_type,
  1402. // RegisterCost: registration_fee,
  1403. // TreatmentCost: medical_expenses,
  1404. // Status: 1,
  1405. // Ctime: time.Now().Unix(),
  1406. // Mtime: time.Now().Unix(),
  1407. // Iinfo: resp_result,
  1408. // PatientId: patient.ID,
  1409. // RecordDate: theTime.Unix(),
  1410. // UserOrgId: adminInfo.CurrentOrgId,
  1411. // AdminUserId: admin_user_id,
  1412. // IsReturn: 1,
  1413. // IdCardType: id_card_type,
  1414. // Doctor: doctor,
  1415. // Departments: department,
  1416. // YiliaoNumber: yiliao_number,
  1417. // MzNumber: number,
  1418. // Number: mz_number,
  1419. // }
  1420. // service.CreateHisPatientTwo(&his)
  1421. // c.ServeSuccessJSON(map[string]interface{}{
  1422. // "msg": "挂号成功",
  1423. // })
  1424. // } else {
  1425. // c.ServeSuccessJSON(map[string]interface{}{
  1426. // "failed_code": -10,
  1427. // "msg": res.Transreturnmessage,
  1428. // })
  1429. // return
  1430. // }
  1431. //
  1432. // }
  1433. //
  1434. // } else { //异地卡流程
  1435. // //readCardBasResult := ReadCardBasHSM(number)
  1436. // //fmt.Println(readCardBasResult)
  1437. // //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  1438. // if is_yidi == 1 { //1本地就医
  1439. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1440. // var dat map[string]interface{}
  1441. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1442. // fmt.Println(dat)
  1443. // } else {
  1444. // fmt.Println(err)
  1445. // }
  1446. //
  1447. // userJSONBytes, _ := json.Marshal(dat)
  1448. //
  1449. // var res ResultOne
  1450. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1451. // utils.ErrorLog("解析失败:%v", err)
  1452. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1453. // return
  1454. // }
  1455. // if res.Transreturncode == "00000000" {
  1456. // his := models.VMHisPatient{
  1457. // Name: name,
  1458. // Gender: gender,
  1459. // Birthday: birthUnix,
  1460. // MedicalTreatmentType: medical_care,
  1461. // IdType: certificates,
  1462. // IdCardNo: id_card,
  1463. // BalanceAccountsType: settlementValue,
  1464. // SocialType: social_type,
  1465. // MedicalInsuranceNumber: medical_insurance_card,
  1466. // RegisterType: register_type,
  1467. // RegisterCost: registration_fee,
  1468. // TreatmentCost: medical_expenses,
  1469. // Status: 1,
  1470. // Ctime: time.Now().Unix(),
  1471. // Mtime: time.Now().Unix(),
  1472. // Iinfo: resp_result,
  1473. // PatientId: patient.ID,
  1474. // RecordDate: theTime.Unix(),
  1475. // UserOrgId: adminInfo.CurrentOrgId,
  1476. // AdminUserId: admin_user_id,
  1477. // IsReturn: 1,
  1478. // IdCardType: id_card_type,
  1479. // Doctor: doctor,
  1480. // Departments: department,
  1481. // YiliaoNumber: yiliao_number,
  1482. // MzNumber: number,
  1483. // Number: mz_number,
  1484. // }
  1485. // service.CreateHisPatientTwo(&his)
  1486. // c.ServeSuccessJSON(map[string]interface{}{
  1487. // "msg": "挂号成功",
  1488. // })
  1489. // } else {
  1490. // c.ServeSuccessJSON(map[string]interface{}{
  1491. // "failed_code": -10,
  1492. // "msg": res.Transreturnmessage,
  1493. // })
  1494. // return
  1495. // }
  1496. //
  1497. // } else { //异地就医需要走鉴权流程
  1498. // //authResult := CardAuth(number)
  1499. // //fmt.Println(authResult)
  1500. // resp_result := service.SzybMZ002(doctor_name, doctor_code, miConfig.Code, "0305", yiliao_number, verifyCode, number, mz_number, version_code, custom_code, custom_project_name, allPrice, medical_care)
  1501. // var dat map[string]interface{}
  1502. // if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  1503. // fmt.Println(dat)
  1504. // } else {
  1505. // fmt.Println(err)
  1506. // }
  1507. //
  1508. // userJSONBytes, _ := json.Marshal(dat)
  1509. //
  1510. // var res ResultOne
  1511. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1512. // utils.ErrorLog("解析失败:%v", err)
  1513. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1514. // return
  1515. // }
  1516. // if res.Transreturncode == "00000000" {
  1517. // his := models.VMHisPatient{
  1518. // Name: name,
  1519. // Gender: gender,
  1520. // Birthday: birthUnix,
  1521. // MedicalTreatmentType: medical_care,
  1522. // IdType: certificates,
  1523. // IdCardNo: id_card,
  1524. // BalanceAccountsType: settlementValue,
  1525. // SocialType: social_type,
  1526. // MedicalInsuranceNumber: medical_insurance_card,
  1527. // RegisterType: register_type,
  1528. // RegisterCost: registration_fee,
  1529. // TreatmentCost: medical_expenses,
  1530. // Status: 1,
  1531. // Ctime: time.Now().Unix(),
  1532. // Mtime: time.Now().Unix(),
  1533. // Iinfo: resp_result,
  1534. // PatientId: patient.ID,
  1535. // RecordDate: theTime.Unix(),
  1536. // UserOrgId: adminInfo.CurrentOrgId,
  1537. // AdminUserId: admin_user_id,
  1538. // IsReturn: 1,
  1539. // IdCardType: id_card_type,
  1540. // Doctor: doctor,
  1541. // Departments: department,
  1542. // YiliaoNumber: yiliao_number,
  1543. // MzNumber: number,
  1544. // Number: mz_number,
  1545. // }
  1546. // service.CreateHisPatientTwo(&his)
  1547. // c.ServeSuccessJSON(map[string]interface{}{
  1548. // "msg": "挂号成功",
  1549. // })
  1550. // } else {
  1551. // c.ServeSuccessJSON(map[string]interface{}{
  1552. // "failed_code": -10,
  1553. // "msg": res.Transreturnmessage,
  1554. // })
  1555. // return
  1556. // }
  1557. //
  1558. // }
  1559. // }
  1560. // } else {
  1561. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1562. // return
  1563. // }
  1564. // } else {
  1565. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  1566. // return
  1567. // }
  1568. //}
  1569. //上传明细----结算----确认订单
  1570. func (c *SZHisApiController) GetSettleInfo() {
  1571. pay_way, _ := c.GetInt64("pay_way")
  1572. pay_price, _ := c.GetFloat("pay_price")
  1573. pay_card_no := c.GetString("pay_card_no")
  1574. discount_price, _ := c.GetFloat("discount_price")
  1575. preferential_price, _ := c.GetFloat("preferential_price")
  1576. reality_price, _ := c.GetFloat("reality_price")
  1577. found_price, _ := c.GetFloat("found_price")
  1578. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1579. private_price, _ := c.GetFloat("private_price")
  1580. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1581. patient_id, _ := c.GetInt64("id")
  1582. record_time := c.GetString("record_time")
  1583. admin_user_id, _ := c.GetInt64("admin_user_id")
  1584. timestamp := time.Now().Unix()
  1585. tempTime := time.Unix(timestamp, 0)
  1586. timeFormat := tempTime.Format("20060102150405")
  1587. chrgBchno := rand.Intn(10000) + 1000
  1588. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  1589. adminUser := c.GetAdminUserInfo()
  1590. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1591. month := time.Unix(1557042972, 0).Format("1")
  1592. year := time.Now().Format("2006")
  1593. month = time.Now().Format("01")
  1594. day := time.Now().Format("02")
  1595. timeLayout := "2006-01-02"
  1596. loc, _ := time.LoadLocation("Local")
  1597. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1598. fmt.Println(err)
  1599. if err != nil {
  1600. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1601. return
  1602. }
  1603. recordDateTime := theTime.Unix()
  1604. var prescriptions []*models.HisPrescription
  1605. var start_time int64
  1606. var end_time int64
  1607. if settle_accounts_type == 1 { //日结
  1608. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1609. } else { //月结
  1610. start_time_str := c.GetString("start_time")
  1611. end_time_str := c.GetString("end_time")
  1612. timeLayout := "2006-01-02"
  1613. loc, _ := time.LoadLocation("Local")
  1614. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1615. if err != nil {
  1616. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1617. return
  1618. }
  1619. recordStartTime := theStartTime.Unix()
  1620. start_time = recordStartTime
  1621. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1622. if err != nil {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1624. return
  1625. }
  1626. recordEndTime := theEndTime.Unix()
  1627. end_time = recordEndTime
  1628. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  1629. }
  1630. var ids []int64
  1631. for _, item := range prescriptions {
  1632. ids = append(ids, item.ID)
  1633. }
  1634. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1635. sick, _ := service.FindSickById(patientPrescription.SickType)
  1636. if sick.ID == 0 {
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamSickTypeWrong)
  1638. return
  1639. }
  1640. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1641. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1642. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1643. mz_number := his.Number
  1644. number := miConfig.Code + year + month + day +
  1645. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1646. var doctor_name string
  1647. var doctor_code string
  1648. var drug_doctor_code string
  1649. drug_doctor_code = adminRole_two.DoctorCode
  1650. drug_doctor_name := adminRole_two.UserName
  1651. if adminRole.ID == 0 {
  1652. doctor_name = "管理员"
  1653. doctor_code = "01"
  1654. } else {
  1655. doctor_name = adminRole.UserName
  1656. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1657. }
  1658. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  1659. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  1660. //version_code := "V0.3"
  1661. var customs []*models.CustomDetail
  1662. for _, item := range prescriptions {
  1663. if item.Type == 1 { //药品
  1664. for _, subItem := range item.HisDoctorAdviceInfo {
  1665. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  1666. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  1667. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  1668. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  1669. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  1670. temp := strings.Split(subItem.FeedetlSn, "-")
  1671. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  1672. cus := &models.CustomDetail{
  1673. PrescriptionNumber: chrg_bchno,
  1674. OrderType: "1",
  1675. ChargeSerialNumber: newFl,
  1676. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  1677. CodeName: subItem.BaseDrugLib.DrugName,
  1678. Flag: "1",
  1679. Price: price,
  1680. Count: subItem.PrescribingNumber,
  1681. ChargeOrderDate: year + month + day,
  1682. DoctorCode: doctor_code,
  1683. Total: detItemFeeSumamt,
  1684. DoseCode: dose_code,
  1685. Spec: subItem.BaseDrugLib.DrugSpec,
  1686. }
  1687. customs = append(customs, cus)
  1688. }
  1689. }
  1690. }
  1691. if item.Type == 2 { //项目
  1692. for _, subItem := range item.HisPrescriptionProject {
  1693. if len(subItem.HisProject.MedicalCode) > 0 {
  1694. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  1695. //count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  1696. count, _ := strconv.ParseFloat(strconv.FormatInt(subItem.Count, 10), 64)
  1697. temp := strings.Split(subItem.FeedetlSn, "-")
  1698. newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  1699. cus := &models.CustomDetail{
  1700. PrescriptionNumber: chrg_bchno,
  1701. OrderType: "1",
  1702. ChargeSerialNumber: newFl,
  1703. Code: subItem.HisProject.MedicalCode,
  1704. CodeName: subItem.HisProject.ProjectName,
  1705. Flag: "1",
  1706. Price: subItem.Price,
  1707. Count: count,
  1708. ChargeOrderDate: year + month + day,
  1709. DoctorCode: doctor_code,
  1710. Total: detItemFeeSumamt,
  1711. DoseCode: "",
  1712. Spec: "次",
  1713. }
  1714. customs = append(customs, cus)
  1715. }
  1716. }
  1717. }
  1718. //
  1719. //for _, subItem := range item.HisAdditionalCharge {
  1720. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  1721. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  1722. //
  1723. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  1724. // cus := &models.CustomDetail{
  1725. // PrescriptionNumber: chrg_bchno,
  1726. // OrderType: "1",
  1727. // ChargeSerialNumber: subItem.FeedetlSn,
  1728. // Code: subItem.XtHisAddtionConfig.Code,
  1729. // CodeName: subItem.XtHisAddtionConfig.Name,
  1730. // Flag: "1",
  1731. // Price: subItem.Price,
  1732. // Count: count,
  1733. // ChargeOrderDate: year + month + day,
  1734. // DoctorCode: doctor_code,
  1735. // Total: detItemFeeSumamt,
  1736. // DoseCode: "",
  1737. // Spec: subItem.XtHisAddtionConfig.,
  1738. // }
  1739. // customs = append(customs, cus)
  1740. // }
  1741. //}
  1742. }
  1743. var pagesize int = 50
  1744. var start int = 1
  1745. var stop int
  1746. var pagecount int
  1747. var curpage int
  1748. var isSuccess bool = true
  1749. //总页数,向上取整,注意除之前要先转换类型为float64
  1750. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1751. var ress []*Result
  1752. for curpage = 1; curpage <= pagecount; curpage++ {
  1753. if curpage == 1 {
  1754. start = 1
  1755. } else {
  1756. start = (curpage-1)*pagesize + 1
  1757. }
  1758. stop = curpage * pagesize
  1759. if stop > len(customs) {
  1760. stop = len(customs)
  1761. }
  1762. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  1763. fmt.Println(result)
  1764. var dat map[string]interface{}
  1765. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1766. fmt.Println(dat)
  1767. } else {
  1768. fmt.Println(err)
  1769. }
  1770. userJSONBytes, _ := json.Marshal(dat)
  1771. var res Result
  1772. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1773. utils.ErrorLog("解析失败:%v", err)
  1774. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1775. return
  1776. }
  1777. if res.Transreturncode == "00000000" {
  1778. ress = append(ress, &res)
  1779. } else {
  1780. isSuccess = false
  1781. errlog := &models.HisOrderError{
  1782. UserOrgId: adminUser.CurrentOrgId,
  1783. Ctime: time.Now().Unix(),
  1784. Mtime: time.Now().Unix(),
  1785. Number: chrg_bchno,
  1786. ErrMsg: res.Transreturnmessage,
  1787. Status: 1,
  1788. PatientId: patient_id,
  1789. RecordTime: recordDateTime,
  1790. Stage: 4,
  1791. }
  1792. service.CreateErrMsgLog(errlog)
  1793. c.ServeSuccessJSON(map[string]interface{}{
  1794. "failed_code": -10,
  1795. "msg": res.Transreturnmessage,
  1796. })
  1797. return
  1798. }
  1799. //设置变量,根据变量的值来判断上传是否成功
  1800. }
  1801. if isSuccess == true {
  1802. order := &models.HisOrder{
  1803. UserOrgId: adminUser.CurrentOrgId,
  1804. HisPatientId: 0,
  1805. PatientId: patient_id,
  1806. SettleAccountsDate: recordDateTime,
  1807. Ctime: time.Now().Unix(),
  1808. Mtime: time.Now().Unix(),
  1809. Status: 1,
  1810. Number: chrg_bchno,
  1811. Infcode: 0,
  1812. WarnMsg: "",
  1813. Cainfo: "",
  1814. ErrMsg: "",
  1815. RespondTime: "",
  1816. InfRefmsgid: "",
  1817. OrderStatus: 1,
  1818. IsMedicineInsurance: 1,
  1819. SettleType: settle_accounts_type,
  1820. SettleStartTime: start_time,
  1821. SettleEndTime: end_time,
  1822. Creator: admin_user_id,
  1823. Modify: admin_user_id,
  1824. OrgSetlNumber: number,
  1825. }
  1826. data, _ := json.Marshal(ress)
  1827. order.DetailLog = string(data)
  1828. err = service.CreateOrder(order)
  1829. if err != nil {
  1830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  1831. return
  1832. }
  1833. for _, subItem := range ress {
  1834. for _, item := range subItem.Transbody.Outputlist {
  1835. temp := strings.Split(item.Bkf500, "-")
  1836. var advice_id int64 = 0
  1837. var project_id int64 = 0
  1838. var types int64 = 0
  1839. id, _ := strconv.ParseInt(temp[2], 10, 64)
  1840. types, _ = strconv.ParseInt(temp[1], 10, 64)
  1841. if temp[1] == "1" {
  1842. advice_id = id
  1843. project_id = 0
  1844. } else if temp[1] == "2" {
  1845. advice_id = 0
  1846. project_id = id
  1847. }
  1848. info := &models.HisOrderInfo{
  1849. OrderNumber: order.Number,
  1850. FeedetlSn: item.Bkf500,
  1851. UploadDate: time.Now().Unix(),
  1852. AdviceId: advice_id,
  1853. DetItemFeeSumamt: item.Akc264,
  1854. Cnt: item.Akc226,
  1855. Pric: float64(item.Akc225),
  1856. PatientId: patient_id,
  1857. Status: 1,
  1858. ChrgitmLv: item.Aka065,
  1859. Mtime: time.Now().Unix(),
  1860. Ctime: time.Now().Unix(),
  1861. UserOrgId: adminUser.CurrentOrgId,
  1862. OrderId: order.ID,
  1863. ProjectId: project_id,
  1864. Type: types,
  1865. OverPricPsnPay: item.Akc268,
  1866. AllowReimburse: item.Cka319,
  1867. }
  1868. service.CreateOrderInfo(info)
  1869. }
  1870. }
  1871. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  1872. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  1873. var total float64
  1874. for _, item := range prescriptions {
  1875. if item.Type == 1 { //药品
  1876. for _, subItem := range item.HisDoctorAdviceInfo {
  1877. total = total + (subItem.Price * subItem.PrescribingNumber)
  1878. }
  1879. }
  1880. if item.Type == 2 { //项目
  1881. for _, subItem := range item.HisPrescriptionProject {
  1882. total = total + (subItem.Price * float64(subItem.Count))
  1883. }
  1884. }
  1885. }
  1886. for _, item := range prescriptions {
  1887. for _, subItem := range item.HisAdditionalCharge {
  1888. total = total + (subItem.Price * float64(subItem.Count))
  1889. }
  1890. }
  1891. yiliao_number, id_card_number, verifyCode, version_code, health_card_no, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  1892. if ret4 == 0 {
  1893. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1894. tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  1895. if tempPatient.ID == patient_id {
  1896. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType, sick.CountryCode)
  1897. var dat map[string]interface{}
  1898. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  1899. fmt.Println(dat)
  1900. } else {
  1901. fmt.Println(err)
  1902. }
  1903. userJSONBytes, _ := json.Marshal(dat)
  1904. var res ResultTwo
  1905. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1906. utils.ErrorLog("解析失败:%v", err)
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1908. return
  1909. }
  1910. if res.Transreturncode == "00000000" {
  1911. order.OrderStatus = 2
  1912. order.PayWay = pay_way
  1913. order.PayPrice = pay_price
  1914. order.PayCardNo = pay_card_no
  1915. order.PsnNo = health_card_no
  1916. order.DiscountPrice = discount_price
  1917. order.PreferentialPrice = preferential_price
  1918. order.RealityPrice = reality_price
  1919. order.FoundPrice = found_price
  1920. order.MedicalInsurancePrice = medical_insurance_price
  1921. order.PrivatePrice = private_price
  1922. order.Modify = admin_user_id
  1923. order.MedfeeSumamt = res.Transbody.Akc264
  1924. order.SetlId = res.Transbody.Ckc618
  1925. order.FundPaySumamt = res.Transbody.Akb068
  1926. order.AcctPay = res.Transbody.Akb066
  1927. order.PsnCashPay = res.Transbody.Akb067
  1928. order.PsnPartAmt = res.Transbody.Akb067
  1929. order.AccountPrice = res.Transbody.Aae240
  1930. order.MzNumber = mz_number
  1931. order.YiliaoNumber = yiliao_number
  1932. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1933. detailStrOne := string(setlDetailOne)
  1934. order.SzChargeInfo = detailStrOne
  1935. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1936. detailStrTwo := string(setlDetailTwo)
  1937. order.SzProjectInfo = detailStrTwo
  1938. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1939. detailStrThree := string(setlDetailThree)
  1940. order.SzMedicineInsuranceInfo = detailStrThree
  1941. order.Cainfo = result_three
  1942. err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  1943. err = service.UpDateOrderTwo(order)
  1944. c.ServeSuccessJSON(map[string]interface{}{
  1945. "msg": "结算成功",
  1946. })
  1947. } else {
  1948. //结算报错
  1949. errlog := &models.HisOrderError{
  1950. UserOrgId: adminUser.CurrentOrgId,
  1951. Ctime: time.Now().Unix(),
  1952. Mtime: time.Now().Unix(),
  1953. Number: chrg_bchno,
  1954. ErrMsg: res.Transreturnmessage,
  1955. Status: 1,
  1956. PatientId: patient_id,
  1957. RecordTime: recordDateTime,
  1958. Stage: 6,
  1959. }
  1960. service.CreateErrMsgLog(errlog)
  1961. c.ServeSuccessJSON(map[string]interface{}{
  1962. "failed_code": -10,
  1963. "msg": res.Transreturnmessage,
  1964. })
  1965. }
  1966. } else {
  1967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  1968. return
  1969. }
  1970. } else {
  1971. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  1972. return
  1973. }
  1974. } else {
  1975. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1976. return
  1977. }
  1978. }
  1979. //func (c *SZHisApiController) GetSettleInfo() {
  1980. // pay_way, _ := c.GetInt64("pay_way")
  1981. // pay_price, _ := c.GetFloat("pay_price")
  1982. // pay_card_no := c.GetString("pay_card_no")
  1983. // discount_price, _ := c.GetFloat("discount_price")
  1984. // preferential_price, _ := c.GetFloat("preferential_price")
  1985. // reality_price, _ := c.GetFloat("reality_price")
  1986. // found_price, _ := c.GetFloat("found_price")
  1987. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  1988. // private_price, _ := c.GetFloat("private_price")
  1989. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  1990. // patient_id, _ := c.GetInt64("id")
  1991. // record_time := c.GetString("record_time")
  1992. // admin_user_id, _ := c.GetInt64("admin_user_id")
  1993. // timestamp := time.Now().Unix()
  1994. // tempTime := time.Unix(timestamp, 0)
  1995. // timeFormat := tempTime.Format("20060102150405")
  1996. // chrgBchno := rand.Intn(10000) + 1000
  1997. // chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  1998. // adminUser := c.GetAdminUserInfo()
  1999. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2000. // month := time.Unix(1557042972, 0).Format("1")
  2001. // year := time.Now().Format("2006")
  2002. // month = time.Now().Format("01")
  2003. // day := time.Now().Format("02")
  2004. //
  2005. // timeLayout := "2006-01-02"
  2006. // loc, _ := time.LoadLocation("Local")
  2007. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2008. // fmt.Println(err)
  2009. // if err != nil {
  2010. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2011. // return
  2012. // }
  2013. // recordDateTime := theTime.Unix()
  2014. //
  2015. // var prescriptions []*models.HisPrescription
  2016. //
  2017. // var start_time int64
  2018. // var end_time int64
  2019. //
  2020. // if settle_accounts_type == 1 { //日结
  2021. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2022. //
  2023. // } else { //月结
  2024. // start_time_str := c.GetString("start_time")
  2025. // end_time_str := c.GetString("end_time")
  2026. // timeLayout := "2006-01-02"
  2027. // loc, _ := time.LoadLocation("Local")
  2028. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2029. // if err != nil {
  2030. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2031. // return
  2032. // }
  2033. // recordStartTime := theStartTime.Unix()
  2034. // start_time = recordStartTime
  2035. //
  2036. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2037. // if err != nil {
  2038. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2039. // return
  2040. // }
  2041. // recordEndTime := theEndTime.Unix()
  2042. // end_time = recordEndTime
  2043. //
  2044. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2045. // }
  2046. //
  2047. // var ids []int64
  2048. // for _, item := range prescriptions {
  2049. // ids = append(ids, item.ID)
  2050. // }
  2051. //
  2052. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2053. //
  2054. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2055. //
  2056. // adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2057. // his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2058. // mz_number := his.Number
  2059. // number := miConfig.Code + year + month + day +
  2060. // fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2061. // var doctor_name string
  2062. // var doctor_code string
  2063. // var drug_doctor_code string
  2064. // drug_doctor_code = adminRole_two.DoctorCode
  2065. // drug_doctor_name := adminRole_two.UserName
  2066. //
  2067. // if adminRole.ID == 0 {
  2068. // doctor_name = "黄亦轩"
  2069. // doctor_code = "1"
  2070. // } else {
  2071. // doctor_name = adminRole.UserName
  2072. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2073. // }
  2074. //
  2075. // verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  2076. // //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  2077. // //version_code := "V0.3"
  2078. // var customs []*models.CustomDetail
  2079. // for _, item := range prescriptions {
  2080. // if item.Type == 1 { //药品
  2081. // for _, subItem := range item.HisDoctorAdviceInfo {
  2082. // fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  2083. //
  2084. // if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  2085. // _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  2086. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  2087. // price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  2088. // temp := strings.Split(subItem.FeedetlSn, "-")
  2089. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2090. //
  2091. // cus := &models.CustomDetail{
  2092. // PrescriptionNumber: chrg_bchno,
  2093. // OrderType: "1",
  2094. // ChargeSerialNumber: newFl,
  2095. // Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  2096. // CodeName: subItem.BaseDrugLib.DrugName,
  2097. // Flag: "1",
  2098. // Price: price,
  2099. // Count: subItem.PrescribingNumber,
  2100. // ChargeOrderDate: year + month + day,
  2101. // DoctorCode: doctor_code,
  2102. // Total: detItemFeeSumamt,
  2103. // DoseCode: dose_code,
  2104. // Spec: subItem.BaseDrugLib.DrugSpec,
  2105. // }
  2106. // customs = append(customs, cus)
  2107. // }
  2108. // }
  2109. // }
  2110. //
  2111. // if item.Type == 2 { //项目
  2112. // for _, subItem := range item.HisPrescriptionProject {
  2113. // if len(subItem.HisProject.MedicalCode) > 0 {
  2114. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2115. //
  2116. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2117. // temp := strings.Split(subItem.FeedetlSn, "-")
  2118. // newFl := fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) + "-" + temp[1] + "-" + temp[2]
  2119. //
  2120. // cus := &models.CustomDetail{
  2121. // PrescriptionNumber: chrg_bchno,
  2122. // OrderType: "1",
  2123. // ChargeSerialNumber: newFl,
  2124. // Code: subItem.HisProject.MedicalCode,
  2125. // CodeName: subItem.HisProject.ProjectName,
  2126. // Flag: "1",
  2127. // Price: subItem.Price,
  2128. // Count: count,
  2129. // ChargeOrderDate: year + month + day,
  2130. // DoctorCode: doctor_code,
  2131. // Total: detItemFeeSumamt,
  2132. // DoseCode: "",
  2133. // Spec: "次",
  2134. // }
  2135. // customs = append(customs, cus)
  2136. // }
  2137. // }
  2138. // }
  2139. // //
  2140. // //for _, subItem := range item.HisAdditionalCharge {
  2141. // // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  2142. // // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  2143. // //
  2144. // // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  2145. // // cus := &models.CustomDetail{
  2146. // // PrescriptionNumber: chrg_bchno,
  2147. // // OrderType: "1",
  2148. // // ChargeSerialNumber: subItem.FeedetlSn,
  2149. // // Code: subItem.XtHisAddtionConfig.Code,
  2150. // // CodeName: subItem.XtHisAddtionConfig.Name,
  2151. // // Flag: "1",
  2152. // // Price: subItem.Price,
  2153. // // Count: count,
  2154. // // ChargeOrderDate: year + month + day,
  2155. // // DoctorCode: doctor_code,
  2156. // // Total: detItemFeeSumamt,
  2157. // // DoseCode: "",
  2158. // // Spec: subItem.XtHisAddtionConfig.,
  2159. // // }
  2160. // // customs = append(customs, cus)
  2161. // // }
  2162. // //}
  2163. // }
  2164. //
  2165. // var pagesize int = 50
  2166. // var start int = 1
  2167. // var stop int
  2168. // var pagecount int
  2169. // var curpage int
  2170. // var isSuccess bool = true
  2171. // //总页数,向上取整,注意除之前要先转换类型为float64
  2172. // pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2173. //
  2174. // var ress []*Result
  2175. // for curpage = 1; curpage <= pagecount; curpage++ {
  2176. // if curpage == 1 {
  2177. // start = 1
  2178. // } else {
  2179. // start = (curpage-1)*pagesize + 1
  2180. // }
  2181. // stop = curpage * pagesize
  2182. // if stop > len(customs) {
  2183. // stop = len(customs)
  2184. // }
  2185. // result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  2186. // fmt.Println(result)
  2187. //
  2188. // var dat map[string]interface{}
  2189. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2190. // fmt.Println(dat)
  2191. // } else {
  2192. // fmt.Println(err)
  2193. // }
  2194. //
  2195. // userJSONBytes, _ := json.Marshal(dat)
  2196. //
  2197. // var res Result
  2198. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2199. // utils.ErrorLog("解析失败:%v", err)
  2200. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2201. // return
  2202. // }
  2203. // if res.Transreturncode == "00000000" {
  2204. // ress = append(ress, &res)
  2205. // } else {
  2206. // isSuccess = false
  2207. // errlog := &models.HisOrderError{
  2208. // UserOrgId: adminUser.CurrentOrgId,
  2209. // Ctime: time.Now().Unix(),
  2210. // Mtime: time.Now().Unix(),
  2211. // Number: chrg_bchno,
  2212. // ErrMsg: res.Transreturnmessage,
  2213. // Status: 1,
  2214. // PatientId: patient_id,
  2215. // RecordTime: recordDateTime,
  2216. // Stage: 4,
  2217. // }
  2218. // service.CreateErrMsgLog(errlog)
  2219. // c.ServeSuccessJSON(map[string]interface{}{
  2220. // "failed_code": -10,
  2221. // "msg": res.Transreturnmessage,
  2222. // })
  2223. // return
  2224. // }
  2225. // //设置变量,根据变量的值来判断上传是否成功
  2226. // }
  2227. // if isSuccess == true {
  2228. // order := &models.HisOrder{
  2229. // UserOrgId: adminUser.CurrentOrgId,
  2230. // HisPatientId: 0,
  2231. // PatientId: patient_id,
  2232. // SettleAccountsDate: recordDateTime,
  2233. // Ctime: time.Now().Unix(),
  2234. // Mtime: time.Now().Unix(),
  2235. // Status: 1,
  2236. // Number: chrg_bchno,
  2237. // Infcode: 0,
  2238. // WarnMsg: "",
  2239. // Cainfo: "",
  2240. // ErrMsg: "",
  2241. // RespondTime: "",
  2242. // InfRefmsgid: "",
  2243. // OrderStatus: 1,
  2244. // IsMedicineInsurance: 1,
  2245. // SettleType: settle_accounts_type,
  2246. // SettleStartTime: start_time,
  2247. // SettleEndTime: end_time,
  2248. // Creator: admin_user_id,
  2249. // Modify: admin_user_id,
  2250. // OrgSetlNumber: number,
  2251. // }
  2252. // data, _ := json.Marshal(ress)
  2253. // order.DetailLog = string(data)
  2254. //
  2255. // err = service.CreateOrder(order)
  2256. // if err != nil {
  2257. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  2258. // return
  2259. // }
  2260. //
  2261. // for _, subItem := range ress {
  2262. // for _, item := range subItem.Transbody.Outputlist {
  2263. //
  2264. // temp := strings.Split(item.Bkf500, "-")
  2265. // var advice_id int64 = 0
  2266. // var project_id int64 = 0
  2267. // var types int64 = 0
  2268. //
  2269. // id, _ := strconv.ParseInt(temp[2], 10, 64)
  2270. // types, _ = strconv.ParseInt(temp[1], 10, 64)
  2271. //
  2272. // if temp[1] == "1" {
  2273. // advice_id = id
  2274. // project_id = 0
  2275. // } else if temp[1] == "2" {
  2276. // advice_id = 0
  2277. // project_id = id
  2278. // }
  2279. //
  2280. // info := &models.HisOrderInfo{
  2281. // OrderNumber: order.Number,
  2282. // FeedetlSn: item.Bkf500,
  2283. // UploadDate: time.Now().Unix(),
  2284. // AdviceId: advice_id,
  2285. // DetItemFeeSumamt: item.Akc264,
  2286. // Cnt: item.Akc226,
  2287. // Pric: float64(item.Akc225),
  2288. // PatientId: patient_id,
  2289. // Status: 1,
  2290. // ChrgitmLv: item.Aka065,
  2291. // Mtime: time.Now().Unix(),
  2292. // Ctime: time.Now().Unix(),
  2293. // UserOrgId: adminUser.CurrentOrgId,
  2294. // OrderId: order.ID,
  2295. // ProjectId: project_id,
  2296. // Type: types,
  2297. //
  2298. // OverPricPsnPay: item.Akc268,
  2299. // AllowReimburse: item.Cka319,
  2300. // }
  2301. // service.CreateOrderInfo(info)
  2302. //
  2303. // }
  2304. // }
  2305. // service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  2306. // service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  2307. // var total float64
  2308. // for _, item := range prescriptions {
  2309. // if item.Type == 1 { //药品
  2310. // for _, subItem := range item.HisDoctorAdviceInfo {
  2311. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2312. // }
  2313. // }
  2314. // if item.Type == 2 { //项目
  2315. // for _, subItem := range item.HisPrescriptionProject {
  2316. // total = total + (subItem.Price * float64(subItem.Count))
  2317. // }
  2318. // }
  2319. // }
  2320. // for _, item := range prescriptions {
  2321. // for _, subItem := range item.HisAdditionalCharge {
  2322. // total = total + (subItem.Price * float64(subItem.Count))
  2323. // }
  2324. // }
  2325. //
  2326. // yiliao_number, id_card_number, verifyCode, version_code, _, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code + "|")
  2327. // if ret4 == 0 {
  2328. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  2329. // tempPatient, _ := service.GetPatientByNumber(id_card_number, adminUser.CurrentOrgId)
  2330. // if tempPatient.ID == patient_id {
  2331. //
  2332. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name, his.MedicalTreatmentType)
  2333. // var dat map[string]interface{}
  2334. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2335. // fmt.Println(dat)
  2336. // } else {
  2337. // fmt.Println(err)
  2338. // }
  2339. // userJSONBytes, _ := json.Marshal(dat)
  2340. // var res ResultTwo
  2341. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2342. // utils.ErrorLog("解析失败:%v", err)
  2343. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2344. // return
  2345. // }
  2346. //
  2347. // if res.Transreturncode == "00000000" {
  2348. // order.OrderStatus = 2
  2349. // order.PayWay = pay_way
  2350. // order.PayPrice = pay_price
  2351. // order.PayCardNo = pay_card_no
  2352. // order.DiscountPrice = discount_price
  2353. // order.PreferentialPrice = preferential_price
  2354. // order.RealityPrice = reality_price
  2355. // order.FoundPrice = found_price
  2356. // order.MedicalInsurancePrice = medical_insurance_price
  2357. // order.PrivatePrice = private_price
  2358. // order.Modify = admin_user_id
  2359. // order.MedfeeSumamt = res.Transbody.Akc264
  2360. // order.SetlId = res.Transbody.Ckc618
  2361. // order.FundPaySumamt = res.Transbody.Akb068
  2362. // order.AcctPay = res.Transbody.Akb066
  2363. // order.PsnCashPay = res.Transbody.Akb067
  2364. // order.PsnPartAmt = res.Transbody.Akb067
  2365. // order.AccountPrice = res.Transbody.Aae240
  2366. // order.MzNumber = mz_number
  2367. // order.YiliaoNumber = yiliao_number
  2368. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2369. // detailStrOne := string(setlDetailOne)
  2370. // order.SzChargeInfo = detailStrOne
  2371. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2372. // detailStrTwo := string(setlDetailTwo)
  2373. // order.SzProjectInfo = detailStrTwo
  2374. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2375. // detailStrThree := string(setlDetailThree)
  2376. // order.SzMedicineInsuranceInfo = detailStrThree
  2377. // order.Cainfo = result_three
  2378. // err = service.UpdataOrderStatusTwo(order.Number, adminUser.CurrentOrgId)
  2379. // err = service.UpDateOrderTwo(order)
  2380. // c.ServeSuccessJSON(map[string]interface{}{
  2381. // "msg": "结算成功",
  2382. // })
  2383. // } else {
  2384. // //结算报错
  2385. // errlog := &models.HisOrderError{
  2386. // UserOrgId: adminUser.CurrentOrgId,
  2387. // Ctime: time.Now().Unix(),
  2388. // Mtime: time.Now().Unix(),
  2389. // Number: chrg_bchno,
  2390. // ErrMsg: res.Transreturnmessage,
  2391. // Status: 1,
  2392. // PatientId: patient_id,
  2393. // RecordTime: recordDateTime,
  2394. // Stage: 6,
  2395. // }
  2396. // service.CreateErrMsgLog(errlog)
  2397. // c.ServeSuccessJSON(map[string]interface{}{
  2398. // "failed_code": -10,
  2399. // "msg": res.Transreturnmessage,
  2400. // })
  2401. // }
  2402. // } else {
  2403. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  2404. // return
  2405. // }
  2406. // } else {
  2407. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeReadCardException)
  2408. // return
  2409. // }
  2410. // } else {
  2411. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2412. // return
  2413. // }
  2414. //}
  2415. //结算
  2416. //func (c *SZHisApiController) GetSettleInfo() {
  2417. // patient_id, _ := c.GetInt64("id")
  2418. // order_id, _ := c.GetInt64("order_id")
  2419. // record_time := c.GetString("record_time")
  2420. // pay_way, _ := c.GetInt64("pay_way")
  2421. // pay_price, _ := c.GetFloat("pay_price")
  2422. // pay_card_no := c.GetString("pay_card_no")
  2423. // discount_price, _ := c.GetFloat("discount_price")
  2424. // preferential_price, _ := c.GetFloat("preferential_price")
  2425. // reality_price, _ := c.GetFloat("reality_price")
  2426. // found_price, _ := c.GetFloat("found_price")
  2427. // medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  2428. // private_price, _ := c.GetFloat("private_price")
  2429. // settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  2430. // admin_user_id, _ := c.GetInt64("admin_user_id")
  2431. //
  2432. // timeLayout := "2006-01-02"
  2433. // loc, _ := time.LoadLocation("Local")
  2434. // theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2435. // if err != nil {
  2436. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2437. // return
  2438. // }
  2439. // recordDateTime := theTime.Unix()
  2440. // adminUser := c.GetAdminUserInfo()
  2441. //
  2442. // var prescriptions []*models.HisPrescription
  2443. //
  2444. // data := make(map[string]interface{})
  2445. // if settle_accounts_type == 1 { //日结
  2446. // prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2447. // data["pre"] = prescriptions
  2448. //
  2449. // } else { //月结
  2450. // start_time_str := c.GetString("start_time")
  2451. // end_time_str := c.GetString("end_time")
  2452. // timeLayout := "2006-01-02"
  2453. // loc, _ := time.LoadLocation("Local")
  2454. // theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  2455. // if err != nil {
  2456. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2457. // return
  2458. // }
  2459. // recordStartTime := theStartTime.Unix()
  2460. // theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  2461. // if err != nil {
  2462. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2463. // return
  2464. // }
  2465. // recordEndTime := theEndTime.Unix()
  2466. // prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  2467. // data["pre"] = prescriptions
  2468. //
  2469. // }
  2470. //
  2471. // roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2472. // his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2473. // miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2474. // strconv.FormatInt(his.PatientId, 10)
  2475. //
  2476. // order_src, _ := service.GetHisOrderByID(order_id)
  2477. //
  2478. // if order_src.ID == 0 {
  2479. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2480. // return
  2481. // }
  2482. //
  2483. // config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2484. // if config.IsOpen == 1 { //对接了医保,走医保流程
  2485. // if order_src.OrderStatus != 2 {
  2486. // var total float64
  2487. // for _, item := range prescriptions {
  2488. // if item.Type == 1 { //药品
  2489. // for _, subItem := range item.HisDoctorAdviceInfo {
  2490. // total = total + (subItem.Price * subItem.PrescribingNumber)
  2491. // }
  2492. // }
  2493. // if item.Type == 2 { //项目
  2494. // for _, subItem := range item.HisPrescriptionProject {
  2495. // total = total + (subItem.Price * float64(subItem.Count))
  2496. // }
  2497. // }
  2498. // }
  2499. //
  2500. // for _, item := range prescriptions {
  2501. // for _, subItem := range item.HisAdditionalCharge {
  2502. // total = total + (subItem.Price * float64(subItem.Count))
  2503. // }
  2504. // }
  2505. //
  2506. // patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2507. //
  2508. // adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2509. //
  2510. // var drug_doctor string
  2511. // drug_doctor = adminRole_two.DoctorCode
  2512. // drug_doctor_name := adminRole_two.UserName
  2513. // //结算流程
  2514. // var doctor_name string
  2515. // var doctor_code string
  2516. // if roles.ID == 0 {
  2517. // doctor_name = "黄亦轩"
  2518. // doctor_code = "1010"
  2519. // } else {
  2520. // doctor_name = roles.UserName
  2521. // doctor_code = strconv.FormatInt(admin_user_id, 10)
  2522. // }
  2523. // number := order_src.OrgSetlNumber
  2524. // mz_number := his.Number
  2525. // verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  2526. //
  2527. // //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  2528. // //version_code := "V0.3"
  2529. // yiliao_number, id_card_number, verifyCode, version_code, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  2530. // yiliao_number := his.YiliaoNumber
  2531. // result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  2532. // var dat map[string]interface{}
  2533. // if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  2534. // fmt.Println(dat)
  2535. // } else {
  2536. // fmt.Println(err)
  2537. // }
  2538. // userJSONBytes, _ := json.Marshal(dat)
  2539. // var res ResultTwo
  2540. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2541. // utils.ErrorLog("解析失败:%v", err)
  2542. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2543. // return
  2544. // }
  2545. //
  2546. // if res.Transreturncode == "00000000" {
  2547. // order_src.OrderStatus = 2
  2548. // order_src.PayWay = pay_way
  2549. // order_src.PayPrice = pay_price
  2550. // order_src.PayCardNo = pay_card_no
  2551. // order_src.DiscountPrice = discount_price
  2552. // order_src.PreferentialPrice = preferential_price
  2553. // order_src.RealityPrice = reality_price
  2554. // order_src.FoundPrice = found_price
  2555. // order_src.MedicalInsurancePrice = medical_insurance_price
  2556. // order_src.PrivatePrice = private_price
  2557. // order_src.Creator = order_src.Creator
  2558. // order_src.Modify = roles.ID
  2559. // order_src.MedfeeSumamt = res.Transbody.Akc264
  2560. // order_src.SetlId = res.Transbody.Ckc618
  2561. // order_src.FundPaySumamt = res.Transbody.Akb068
  2562. // order_src.AcctPay = res.Transbody.Akb066
  2563. // order_src.PsnCashPay = res.Transbody.Akb067
  2564. // order_src.PsnPartAmt = res.Transbody.Akb067
  2565. // order_src.AccountPrice = res.Transbody.Aae240
  2566. // order_src.MzNumber = mz_number
  2567. // order_src.YiliaoNumber = yiliao_number
  2568. // setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  2569. // detailStrOne := string(setlDetailOne)
  2570. // order_src.SzChargeInfo = detailStrOne
  2571. // setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  2572. // detailStrTwo := string(setlDetailTwo)
  2573. // order_src.SzProjectInfo = detailStrTwo
  2574. // setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  2575. // detailStrThree := string(setlDetailThree)
  2576. // order_src.SzMedicineInsuranceInfo = detailStrThree
  2577. // order_src.Cainfo = result_three
  2578. //
  2579. // err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  2580. // err = service.UpDateOrder(order_src)
  2581. //
  2582. // c.ServeSuccessJSON(map[string]interface{}{
  2583. // "msg": "结算成功",
  2584. // })
  2585. // } else {
  2586. // //version_code := "0.03"
  2587. // c.ServeSuccessJSON(map[string]interface{}{
  2588. // "failed_code": -10,
  2589. // "msg": res.Transreturnmessage,
  2590. // })
  2591. //
  2592. // }
  2593. // } else {
  2594. //
  2595. // //错误提示
  2596. //
  2597. // }
  2598. // } else {
  2599. // //错误提示
  2600. //
  2601. // }
  2602. //}
  2603. //当月退费
  2604. func (c *SZHisApiController) Refund() {
  2605. order_id, _ := c.GetInt64("order_id")
  2606. record_time := c.GetString("record_time")
  2607. patient_id, _ := c.GetInt64("patient_id")
  2608. admin_user_id, _ := c.GetInt64("admin_user_id")
  2609. timeLayout := "2006-01-02"
  2610. loc, _ := time.LoadLocation("Local")
  2611. adminUser := c.GetAdminUserInfo()
  2612. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2613. fmt.Println(err)
  2614. if err != nil {
  2615. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2616. return
  2617. }
  2618. recordDateTime := theTime.Unix()
  2619. fmt.Println(recordDateTime)
  2620. var order models.HisOrder
  2621. order, _ = service.GetHisOrderByID(order_id)
  2622. if order.ID == 0 {
  2623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  2624. return
  2625. }
  2626. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  2627. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2628. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2629. //结算流程
  2630. var doctor_name string
  2631. var doctor_code string
  2632. if roles.ID == 0 {
  2633. doctor_name = "管理员"
  2634. doctor_code = "01"
  2635. } else {
  2636. doctor_name = roles.UserName
  2637. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2638. }
  2639. month := time.Unix(1557042972, 0).Format("1")
  2640. year := time.Now().Format("2006")
  2641. month = time.Now().Format("01")
  2642. day := time.Now().Format("02")
  2643. //number := miConfig.Code + year + month + day + "1367866"
  2644. number := miConfig.Code + year + month + day +
  2645. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  2646. //number := miConfig.Code + year + month + day + "1590003"
  2647. //流水号
  2648. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  2649. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  2650. //version_code := "V0.3"
  2651. //
  2652. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  2653. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2654. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  2655. var customs []*models.CustomDetail
  2656. for _, item := range order_infos {
  2657. cus := &models.CustomDetail{
  2658. PrescriptionNumber: item.OrderNumber,
  2659. ChargeSerialNumber: item.FeedetlSn,
  2660. }
  2661. customs = append(customs, cus)
  2662. }
  2663. if config.IsOpen == 1 { //对接了医保,走医保流程
  2664. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  2665. fmt.Println(result)
  2666. var dat map[string]interface{}
  2667. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2668. fmt.Println(dat)
  2669. } else {
  2670. fmt.Println(err)
  2671. }
  2672. userJSONBytes, _ := json.Marshal(dat)
  2673. var res ResultThree
  2674. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2675. utils.ErrorLog("解析失败:%v", err)
  2676. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2677. return
  2678. }
  2679. if res.Transreturncode == "00000000" {
  2680. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  2681. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  2682. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  2683. var pagesize int = 50
  2684. var start int = 1
  2685. var stop int
  2686. var pagecount int
  2687. var curpage int
  2688. var isSuccess bool = true
  2689. var ress []*ResultFive
  2690. //总页数,向上取整,注意除之前要先转换类型为float64
  2691. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2692. for curpage = 1; curpage <= pagecount; curpage++ {
  2693. if curpage == 1 {
  2694. start = 1
  2695. } else {
  2696. start = (curpage-1)*pagesize + 1
  2697. }
  2698. stop = curpage * pagesize
  2699. if stop > len(customs) {
  2700. stop = len(customs)
  2701. }
  2702. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  2703. var dat map[string]interface{}
  2704. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2705. fmt.Println(dat)
  2706. } else {
  2707. fmt.Println(err)
  2708. }
  2709. userJSONBytes, _ := json.Marshal(dat)
  2710. var res ResultFive
  2711. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2712. utils.ErrorLog("解析失败:%v", err)
  2713. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2714. return
  2715. }
  2716. if res.Transreturncode == "00000000" {
  2717. ress = append(ress, &res)
  2718. } else {
  2719. isSuccess = false
  2720. errlog := &models.HisOrderError{
  2721. UserOrgId: adminUser.CurrentOrgId,
  2722. Ctime: time.Now().Unix(),
  2723. Mtime: time.Now().Unix(),
  2724. ErrMsg: res.Transreturnmessage,
  2725. Status: 1,
  2726. PatientId: patient_id,
  2727. RecordTime: recordDateTime,
  2728. Stage: 11,
  2729. }
  2730. service.CreateErrMsgLog(errlog)
  2731. c.ServeSuccessJSON(map[string]interface{}{
  2732. "faild_code": -10,
  2733. "msg": res.Transreturnmessage,
  2734. })
  2735. return
  2736. }
  2737. }
  2738. if isSuccess == true {
  2739. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  2740. c.ServeSuccessJSON(map[string]interface{}{
  2741. "msg": "退费成功",
  2742. })
  2743. }
  2744. } else {
  2745. c.ServeSuccessJSON(map[string]interface{}{
  2746. "failed_code": -10,
  2747. "msg": res.Transreturnmessage,
  2748. })
  2749. }
  2750. }
  2751. }
  2752. //跨月退费
  2753. func (c *SZHisApiController) MonthRefund() {
  2754. order_id, _ := c.GetInt64("order_id")
  2755. record_time := c.GetString("record_time")
  2756. patient_id, _ := c.GetInt64("patient_id")
  2757. admin_user_id, _ := c.GetInt64("admin_user_id")
  2758. timeLayout := "2006-01-02"
  2759. loc, _ := time.LoadLocation("Local")
  2760. adminUser := c.GetAdminUserInfo()
  2761. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2762. fmt.Println(err)
  2763. if err != nil {
  2764. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2765. return
  2766. }
  2767. recordDateTime := theTime.Unix()
  2768. var order models.HisOrder
  2769. order, _ = service.GetHisOrderByID(order_id)
  2770. if order.ID == 0 {
  2771. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2772. }
  2773. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2774. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2775. //结算流程
  2776. var doctor_name string
  2777. var doctor_code string
  2778. if roles.ID == 0 {
  2779. doctor_name = "管理员"
  2780. doctor_code = "01"
  2781. } else {
  2782. doctor_name = roles.UserName
  2783. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2784. }
  2785. month := time.Unix(1557042972, 0).Format("1")
  2786. year := time.Now().Format("2006")
  2787. month = time.Now().Format("01")
  2788. day := time.Now().Format("02")
  2789. //流水号
  2790. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  2791. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  2792. version_code := "0.03"
  2793. fmt.Println(number_two)
  2794. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  2795. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2796. if config.IsOpen == 1 { //对接了医保,走医保流程
  2797. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  2798. fmt.Println(result)
  2799. var dat map[string]interface{}
  2800. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2801. fmt.Println(dat)
  2802. } else {
  2803. fmt.Println(err)
  2804. }
  2805. userJSONBytes, _ := json.Marshal(dat)
  2806. var res ResultThree
  2807. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2808. utils.ErrorLog("解析失败:%v", err)
  2809. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2810. return
  2811. }
  2812. if res.Transreturncode == "00000000" {
  2813. c.ServeSuccessJSON(map[string]interface{}{
  2814. "msg": "退费成功",
  2815. })
  2816. } else {
  2817. }
  2818. }
  2819. }
  2820. //查询
  2821. func (c *SZHisApiController) GetSettleAccounts() {
  2822. order_id, _ := c.GetInt64("order_id")
  2823. record_time := c.GetString("record_time")
  2824. patient_id, _ := c.GetInt64("patient_id")
  2825. admin_user_id, _ := c.GetInt64("admin_user_id")
  2826. timeLayout := "2006-01-02"
  2827. loc, _ := time.LoadLocation("Local")
  2828. adminUser := c.GetAdminUserInfo()
  2829. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2830. fmt.Println(err)
  2831. if err != nil {
  2832. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2833. return
  2834. }
  2835. recordDateTime := theTime.Unix()
  2836. var order models.HisOrder
  2837. order, _ = service.GetHisOrderByID(order_id)
  2838. patient, _ := service.GetPatientByIDTwo(adminUser.CurrentOrgId, patient_id)
  2839. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  2840. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  2841. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, order.SettleAccountsDate)
  2842. yiliao_leibie := ""
  2843. switch his.MedicalTreatmentType {
  2844. case 11:
  2845. yiliao_leibie = "普通门诊"
  2846. break
  2847. case 12:
  2848. yiliao_leibie = "家庭通道"
  2849. break
  2850. case 13:
  2851. yiliao_leibie = "门诊大病"
  2852. break
  2853. case 14:
  2854. yiliao_leibie = "重疾特药"
  2855. break
  2856. case 15:
  2857. yiliao_leibie = "门诊慢病"
  2858. break
  2859. case 16:
  2860. yiliao_leibie = "门诊特检"
  2861. break
  2862. case 17:
  2863. yiliao_leibie = "健康体检"
  2864. break
  2865. case 18:
  2866. yiliao_leibie = "预防接种"
  2867. break
  2868. case 19:
  2869. yiliao_leibie = "门诊输血"
  2870. break
  2871. case 91:
  2872. yiliao_leibie = "新冠肺炎门诊"
  2873. break
  2874. }
  2875. //departments, _ := service.Get(patientPrescription.Departments)
  2876. departments, _ := service.GetDepartMentDetail(patientPrescription.Departments)
  2877. if order.ID == 0 {
  2878. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2879. }
  2880. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2881. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2882. //结算流程
  2883. var doctor_name string
  2884. var doctor_code string
  2885. if roles.ID == 0 {
  2886. doctor_name = "管理员"
  2887. doctor_code = "01"
  2888. } else {
  2889. doctor_name = roles.UserName
  2890. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2891. }
  2892. //month := time.Unix(1557042972, 0).Format("1")
  2893. //year := time.Now().Format("2006")
  2894. //month = time.Now().Format("01")
  2895. //day := time.Now().Format("02")
  2896. //流水号
  2897. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  2898. //fmt.Println(number_two)
  2899. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  2900. //version_code := "V0.3"
  2901. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  2902. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  2903. if config.IsOpen == 1 { //对接了医保,走医保流程
  2904. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  2905. fmt.Println(result)
  2906. var dat map[string]interface{}
  2907. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2908. fmt.Println(dat)
  2909. } else {
  2910. fmt.Println(err)
  2911. }
  2912. userJSONBytes, _ := json.Marshal(dat)
  2913. var res ResultFour
  2914. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2915. utils.ErrorLog("解析失败:%v", err)
  2916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2917. return
  2918. }
  2919. if res.Transreturncode == "00000000" {
  2920. c.ServeSuccessJSON(map[string]interface{}{
  2921. "result": res,
  2922. "org_name": miConfig.OrgName,
  2923. "org_code": miConfig.Code,
  2924. "patient_name": patient.Name,
  2925. "doctor_code": adminRole_two.DoctorCode,
  2926. "doctor_name": doctor_name,
  2927. "health_card_no": order.PsnNo,
  2928. "order_number": order.Number,
  2929. "department": departments.Name,
  2930. "yiliao_leibie": yiliao_leibie,
  2931. })
  2932. } else {
  2933. c.ServeSuccessJSON(map[string]interface{}{
  2934. "failed_code": -10,
  2935. "msg": res.Transreturnmessage,
  2936. })
  2937. }
  2938. }
  2939. }
  2940. //费用录入取消
  2941. func (c *SZHisApiController) CancelOrderDetail() {
  2942. order_id, _ := c.GetInt64("order_id")
  2943. record_time := c.GetString("record_time")
  2944. patient_id, _ := c.GetInt64("patient_id")
  2945. admin_user_id, _ := c.GetInt64("admin_user_id")
  2946. timeLayout := "2006-01-02"
  2947. loc, _ := time.LoadLocation("Local")
  2948. adminUser := c.GetAdminUserInfo()
  2949. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  2950. fmt.Println(err)
  2951. if err != nil {
  2952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2953. return
  2954. }
  2955. recordDateTime := theTime.Unix()
  2956. var order models.HisOrder
  2957. order, _ = service.GetHisOrderByID(order_id)
  2958. if order.ID == 0 {
  2959. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  2960. }
  2961. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  2962. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  2963. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  2964. //结算流程
  2965. var doctor_name string
  2966. var doctor_code string
  2967. if roles.ID == 0 {
  2968. doctor_name = "管理员"
  2969. doctor_code = "1001"
  2970. } else {
  2971. doctor_name = roles.UserName
  2972. doctor_code = strconv.FormatInt(admin_user_id, 10)
  2973. }
  2974. var customs []*models.CustomDetail
  2975. for _, item := range order_infos {
  2976. cus := &models.CustomDetail{
  2977. PrescriptionNumber: item.OrderNumber,
  2978. ChargeSerialNumber: item.FeedetlSn,
  2979. }
  2980. customs = append(customs, cus)
  2981. }
  2982. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  2983. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  2984. var pagesize int = 50
  2985. var start int = 1
  2986. var stop int
  2987. var pagecount int
  2988. var curpage int
  2989. var isSuccess bool = true
  2990. var ress []*ResultFive
  2991. //总页数,向上取整,注意除之前要先转换类型为float64
  2992. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  2993. for curpage = 1; curpage <= pagecount; curpage++ {
  2994. if curpage == 1 {
  2995. start = 1
  2996. } else {
  2997. start = (curpage-1)*pagesize + 1
  2998. }
  2999. stop = curpage * pagesize
  3000. if stop > len(customs) {
  3001. stop = len(customs)
  3002. }
  3003. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, his.Number, version_code)
  3004. fmt.Println(result)
  3005. var dat map[string]interface{}
  3006. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3007. fmt.Println(dat)
  3008. } else {
  3009. fmt.Println(err)
  3010. }
  3011. userJSONBytes, _ := json.Marshal(dat)
  3012. var res ResultFive
  3013. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3014. utils.ErrorLog("解析失败:%v", err)
  3015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3016. return
  3017. }
  3018. if res.Transreturncode == "00000000" {
  3019. ress = append(ress, &res)
  3020. } else {
  3021. isSuccess = false
  3022. //预结算报错
  3023. errlog := &models.HisOrderError{
  3024. UserOrgId: adminUser.CurrentOrgId,
  3025. Ctime: time.Now().Unix(),
  3026. Mtime: time.Now().Unix(),
  3027. ErrMsg: res.Transreturnmessage,
  3028. Status: 1,
  3029. PatientId: patient_id,
  3030. RecordTime: recordDateTime,
  3031. Stage: 11,
  3032. }
  3033. service.CreateErrMsgLog(errlog)
  3034. c.ServeSuccessJSON(map[string]interface{}{
  3035. "faild_code": -10,
  3036. "msg": res.Transreturnmessage,
  3037. })
  3038. return
  3039. }
  3040. }
  3041. if isSuccess == true {
  3042. service.UpdataOrderInfoStatus(order.ID, order.Number, adminUser.CurrentOrgId)
  3043. c.ServeSuccessJSON(map[string]interface{}{
  3044. "msg": "撤销成功",
  3045. })
  3046. }
  3047. }
  3048. //获取verifyCode
  3049. func ReadCardGetCode(request string) (string, string) {
  3050. request = request + "|"
  3051. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3052. readCards := DllDef2.MustFindProc("iVerifyCode")
  3053. str := request
  3054. str3 := make([]byte, 256)
  3055. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3056. fmt.Println(":", string(str3))
  3057. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3058. if ret4 == 0 {
  3059. result := string(str3)
  3060. fmt.Println(result)
  3061. result_arr := strings.Split(result, "|")
  3062. verifyCode := result_arr[0] + "|" + result_arr[1]
  3063. versionCode := result_arr[2]
  3064. return verifyCode, versionCode
  3065. }
  3066. return "", ""
  3067. }
  3068. ////获取卡信息
  3069. func ReadBasCardGetNumber(request string) (string, string, string, string, string, error, int64) {
  3070. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3071. readCards := DllDef2.MustFindProc("iReadCardBas")
  3072. str := request
  3073. str3 := make([]byte, 1024)
  3074. fmt.Println(":", request)
  3075. fmt.Println(":", StrPtr(str))
  3076. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3077. fmt.Println(":", string(str3))
  3078. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3079. if ret4 == 0 {
  3080. result := string(str3)
  3081. fmt.Println(result)
  3082. result_arr := strings.Split(result, "|")
  3083. //医疗证号
  3084. yiliao_number := result_arr[12]
  3085. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3086. id_card_number := result_arr[1]
  3087. verifyCode := result_arr[11] + "|" + result_arr[13]
  3088. versionCode := result_arr[14]
  3089. health_card_no := result_arr[2]
  3090. return yiliao_number, id_card_number, verifyCode, versionCode, health_card_no, err, 0
  3091. }
  3092. return "", "", "", "", "", err, -10
  3093. }
  3094. //读卡
  3095. func ReadBasCard(request string) (string, string, error, int64) {
  3096. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  3097. readCards := DllDef2.MustFindProc("iReadCardBas")
  3098. str := request
  3099. str3 := make([]byte, 1024)
  3100. ret4, _, err := readCards.Call(IntPtr(1), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3101. fmt.Println(":", string(str3))
  3102. fmt.Println(":", ConvertToString(string(str3), "gbk", "utf-8"))
  3103. if ret4 == 0 {
  3104. result := string(str3)
  3105. result_arr := strings.Split(result, "|")
  3106. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  3107. id_card_number := result_arr[1]
  3108. health_card_no := result_arr[2]
  3109. return id_card_number, health_card_no, err, 0
  3110. }
  3111. return "", "", err, -10
  3112. }
  3113. //
  3114. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  3115. //func ReadCardBasHSM(number string) string {
  3116. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3117. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  3118. // str := make([]byte, 256)
  3119. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  3120. // fmt.Println(":", string(str))
  3121. //
  3122. // result_arr := strings.Split(string(str), "|")
  3123. //
  3124. // if ret == 0 {
  3125. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  3126. // str2 := make([]byte, 256)
  3127. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  3128. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  3129. // fmt.Println(":", string(str2))
  3130. //
  3131. // if ret2 == 0 {
  3132. // result_arr := strings.Split(string(str2), "|")
  3133. //
  3134. // if result_arr[2] == "0" {
  3135. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  3136. // str4 := result_arr[4] + "|" + result_arr[5]
  3137. // str5 := make([]byte, 256)
  3138. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  3139. //
  3140. // if ret3 == 0 {
  3141. // return string(str5)
  3142. //
  3143. // } else {
  3144. // return ""
  3145. // }
  3146. // } else {
  3147. // return ""
  3148. // }
  3149. // }
  3150. // return ""
  3151. // }
  3152. // return ""
  3153. //
  3154. //}
  3155. //
  3156. ////1904卡鉴权
  3157. //func CardAuth(request string) string {
  3158. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  3159. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  3160. // str := request
  3161. // str3 := make([]byte, 256)
  3162. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  3163. // fmt.Println(":", string(str3))
  3164. //
  3165. // if ret4 == 0 {
  3166. // return string(str3)
  3167. // }
  3168. // return ""
  3169. //}
  3170. func (c *SZHisApiController) GetDrugList() {
  3171. adminUserInfo := c.GetAdminUserInfo()
  3172. orgId := adminUserInfo.CurrentOrgId
  3173. admin_user_id, _ := c.GetInt64("admin_user_id")
  3174. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3175. fmt.Println("222222222222", roles)
  3176. fmt.Println("rolessssssss", roles.UserName)
  3177. ids := c.GetString("ids")
  3178. stringarr := strings.Split(ids, ",")
  3179. idss := make([]int64, 0)
  3180. for _, item := range stringarr {
  3181. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3182. id := int64(itemsss)
  3183. idss = append(idss, id)
  3184. }
  3185. //批量获取
  3186. list, _ := service.GetBatchDrugList(idss)
  3187. //获取药品剂型
  3188. drugs, _ := service.GetDrugDosageForm(orgId)
  3189. // for _, item := range list {
  3190. // for _, it := range drugs {
  3191. // if item.DrugDosageForm == it.Value {
  3192. // item.DrugDosageName = it.Code
  3193. // }
  3194. // }
  3195. // }
  3196. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3197. var doctor_name string
  3198. var doctor_code string
  3199. doctor_name = roles.UserName
  3200. doctor_code = "1001"
  3201. var isSuccess bool = true
  3202. //这里就可以查看开始和结束了
  3203. for _, item := range list {
  3204. detail := &models.DrugDetail{
  3205. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3206. Code: item.Code,
  3207. DrugName: item.DrugName,
  3208. DrugSpec: item.DrugSpec,
  3209. // DrugDosageName: item.DrugDosageName,
  3210. ManufacturerName: item.ManufacturerName,
  3211. MinUnit: item.MinUnit,
  3212. RetailPrice: item.RetailPrice,
  3213. LastPrice: item.LastPrice,
  3214. LimitRemark: item.LimitRemark,
  3215. }
  3216. for _, it := range drugs {
  3217. if item.DrugDosageForm == it.Value {
  3218. detail.DrugDosageName = it.Code
  3219. }
  3220. }
  3221. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3222. var dat map[string]interface{}
  3223. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3224. //fmt.Println(dat)
  3225. } else {
  3226. //fmt.Println(err)
  3227. }
  3228. userJSONBytes, _ := json.Marshal(dat)
  3229. var res Result
  3230. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3231. utils.ErrorLog("解析失败:%v", err)
  3232. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3233. c.ServeSuccessJSON(map[string]interface{}{
  3234. "failed_code": -10,
  3235. "msg": res.Transreturnmessage,
  3236. })
  3237. return
  3238. }
  3239. if res.Transreturncode == "00000000" {
  3240. //更新备案状态
  3241. _, err := service.UpdateBaseDrugById(item.ID)
  3242. fmt.Println("err", err)
  3243. c.ServeSuccessJSON(map[string]interface{}{
  3244. "failed_code": -10,
  3245. "msg": res.Transreturnmessage,
  3246. })
  3247. return
  3248. }
  3249. fmt.Println(isSuccess)
  3250. }
  3251. }
  3252. func (c *SZHisApiController) GetTreatmentProject() {
  3253. fmt.Println("触发了吗2222222222")
  3254. adminUserInfo := c.GetAdminUserInfo()
  3255. orgId := adminUserInfo.CurrentOrgId
  3256. ids := c.GetString("ids")
  3257. stringarr := strings.Split(ids, ",")
  3258. idss := make([]int64, 0)
  3259. admin_user_id, _ := c.GetInt64("admin_user_id")
  3260. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3261. for _, item := range stringarr {
  3262. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3263. id := int64(itemsss)
  3264. idss = append(idss, id)
  3265. }
  3266. fmt.Println("idsss", idss)
  3267. //获取项目库数据
  3268. //list, _ := service.GetMyPorjecgList(orgId)
  3269. list, _ := service.GetBathchMyPorjecgList(idss)
  3270. fmt.Println("list2222222222", list)
  3271. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3272. var doctor_name string
  3273. var doctor_code string
  3274. doctor_name = roles.UserName
  3275. doctor_code = "1001"
  3276. var isSuccess bool = true
  3277. for _, item := range list {
  3278. detail := &models.MyHisProject{
  3279. MedicalCode: item.MedicalCode, //社保目录
  3280. ProjectName: item.ProjectName,
  3281. Price: item.Price,
  3282. Category: item.Category,
  3283. Remark: item.Remark,
  3284. }
  3285. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3286. fmt.Println("reuslt9999999999999999", result)
  3287. var dat map[string]interface{}
  3288. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3289. fmt.Println(dat)
  3290. } else {
  3291. fmt.Println(err)
  3292. }
  3293. userJSONBytes, _ := json.Marshal(dat)
  3294. var res Result
  3295. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3296. utils.ErrorLog("解析失败:%v", err)
  3297. c.ServeSuccessJSON(map[string]interface{}{
  3298. "failed_code": -10,
  3299. "msg": res.Transreturnmessage,
  3300. })
  3301. return
  3302. }
  3303. if res.Transreturncode == "00000000" {
  3304. //备案成功返回状态值
  3305. _, err := service.UpdateProjectById(item.ID)
  3306. fmt.Println("err22222", err)
  3307. } else {
  3308. isSuccess = false
  3309. //失败
  3310. c.ServeSuccessJSON(map[string]interface{}{
  3311. "failed_code": -10,
  3312. "msg": res.Transreturnmessage,
  3313. })
  3314. return
  3315. }
  3316. fmt.Println(isSuccess)
  3317. }
  3318. }
  3319. func (c *SZHisApiController) GetRevocation() {
  3320. adminUserInfo := c.GetAdminUserInfo()
  3321. orgId := adminUserInfo.CurrentOrgId
  3322. id, _ := c.GetInt64("id")
  3323. admin_user_id, _ := c.GetInt64("admin_user_id")
  3324. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3325. //用来区分是药品的撤销还是耗材的撤销 1.药品 2.诊疗项目 3.材料 5.辅助器具项目
  3326. is_mark, _ := c.GetInt64("is_mark")
  3327. type_id, _ := c.GetInt64("type_id")
  3328. fmt.Println("type_id2222222", type_id)
  3329. if type_id == 1 {
  3330. //撤销
  3331. if is_mark == 1 {
  3332. //获取药品库数据
  3333. list, _ := service.GetDrugListByDetail(orgId, id)
  3334. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3335. var doctor_name string
  3336. var doctor_code string
  3337. doctor_name = roles.UserName
  3338. doctor_code = "1001"
  3339. var pagesize int = 50
  3340. var start int = 1
  3341. var stop int
  3342. var pagecount int
  3343. var curpage int
  3344. var isSuccess bool = true
  3345. //总页数,向上取整,注意除之前要先转换类型为float64
  3346. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3347. for curpage = 1; curpage <= pagecount; curpage++ {
  3348. if curpage == 1 {
  3349. start = 1
  3350. } else {
  3351. start = (curpage-1)*pagesize + 1
  3352. }
  3353. stop = curpage * pagesize
  3354. if stop > len(list) {
  3355. stop = len(list)
  3356. }
  3357. //这里就可以查看开始和结束了
  3358. fmt.Println(list[start-1 : stop])
  3359. var customs []*models.DrugDetail
  3360. for _, item := range list {
  3361. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber, item.Code)
  3362. detail := &models.DrugDetail{
  3363. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber, //社保目录
  3364. Code: item.Code, //协议机构内部目录编码
  3365. DrugName: item.DrugName, //协议机构内部目录名称
  3366. DrugSpec: item.DrugSpec,
  3367. ManufacturerName: item.ManufacturerName,
  3368. MinUnit: item.MinUnit,
  3369. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  3370. LimitRemark: item.LimitRemark,
  3371. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  3372. }
  3373. customs = append(customs, detail)
  3374. }
  3375. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3376. fmt.Println("reuslt", result)
  3377. var dat map[string]interface{}
  3378. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3379. fmt.Println(dat)
  3380. } else {
  3381. fmt.Println(err)
  3382. }
  3383. userJSONBytes, _ := json.Marshal(dat)
  3384. var res Result
  3385. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3386. utils.ErrorLog("解析失败:%v", err)
  3387. c.ServeSuccessJSON(map[string]interface{}{
  3388. "failed_code": -10,
  3389. "msg": res.Transreturnmessage,
  3390. })
  3391. return
  3392. }
  3393. if res.Transreturncode == "00000000" {
  3394. //撤销成功
  3395. _, err := service.UpdateDrugByIdDetail(id)
  3396. fmt.Println("err22222", err)
  3397. } else {
  3398. isSuccess = false
  3399. //失败
  3400. c.ServeSuccessJSON(map[string]interface{}{
  3401. "failed_code": -10,
  3402. "msg": res.Transreturnmessage,
  3403. })
  3404. return
  3405. }
  3406. fmt.Println(isSuccess)
  3407. }
  3408. }
  3409. // 备案
  3410. if is_mark == 0 {
  3411. adminUserInfo := c.GetAdminUserInfo()
  3412. orgId := adminUserInfo.CurrentOrgId
  3413. fmt.Println(orgId)
  3414. //获取药品库数据
  3415. list, _ := service.GetDrugListByDetail(orgId, id)
  3416. //获取药品剂型
  3417. drugs, _ := service.GetDrugDosageForm(orgId)
  3418. // for _, item := range list {
  3419. // fmt.Println(item.DrugDosageForm)
  3420. // for _, it := range drugs {
  3421. // if item.DrugDosageForm == it.Value {
  3422. // item.DrugDosageName = it.Name
  3423. // }
  3424. // }
  3425. // }
  3426. fmt.Print("长度", len(list))
  3427. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3428. var doctor_name string
  3429. var doctor_code string
  3430. doctor_name = roles.UserName
  3431. doctor_code = "1001"
  3432. var isSuccess bool = true
  3433. //这里就可以查看开始和结束了
  3434. for _, item := range list {
  3435. fmt.Print("长度", item.MedicalInsuranceNumber, item.Code)
  3436. detail := &models.DrugDetail{
  3437. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  3438. SocialSecurityDirectoryCode: item.MedicalInsuranceNumber,
  3439. Code: item.Code,
  3440. DrugName: item.DrugName,
  3441. DrugSpec: item.DrugSpec,
  3442. DrugDosageName: item.DrugDosageName,
  3443. ManufacturerName: item.ManufacturerName,
  3444. MinUnit: item.MinUnit,
  3445. RetailPrice: item.RetailPrice,
  3446. LastPrice: item.LastPrice,
  3447. LimitRemark: item.LimitRemark,
  3448. }
  3449. for _, it := range drugs {
  3450. if item.DrugDosageForm == it.Value {
  3451. detail.DrugDosageName = it.Code
  3452. }
  3453. }
  3454. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, detail)
  3455. var dat map[string]interface{}
  3456. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3457. //fmt.Println(dat)
  3458. } else {
  3459. //fmt.Println(err)
  3460. }
  3461. userJSONBytes, _ := json.Marshal(dat)
  3462. var res Result
  3463. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3464. utils.ErrorLog("解析失败:%v", err)
  3465. c.ServeSuccessJSON(map[string]interface{}{
  3466. "failed_code": -10,
  3467. "msg": res.Transreturnmessage,
  3468. })
  3469. return
  3470. }
  3471. if res.Transreturncode == "00000000" {
  3472. //更新备案状态
  3473. _, err := service.UpdateBaseDrugById(item.ID)
  3474. fmt.Println("err", err)
  3475. }
  3476. fmt.Println(isSuccess)
  3477. }
  3478. }
  3479. }
  3480. if type_id == 2 {
  3481. fmt.Println("222222222222222q2")
  3482. //撤销
  3483. if is_mark == 1 {
  3484. //获取药品库数据
  3485. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3486. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3487. var doctor_name string
  3488. var doctor_code string
  3489. doctor_name = roles.UserName
  3490. doctor_code = "1001"
  3491. var pagesize int = 50
  3492. var start int = 1
  3493. var stop int
  3494. var pagecount int
  3495. var curpage int
  3496. var isSuccess bool = true
  3497. //总页数,向上取整,注意除之前要先转换类型为float64
  3498. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3499. for curpage = 1; curpage <= pagecount; curpage++ {
  3500. if curpage == 1 {
  3501. start = 1
  3502. } else {
  3503. start = (curpage-1)*pagesize + 1
  3504. }
  3505. stop = curpage * pagesize
  3506. if stop > len(list) {
  3507. stop = len(list)
  3508. }
  3509. //这里就可以查看开始和结束了
  3510. fmt.Println(list[start-1 : stop])
  3511. var customs []*models.DrugDetail
  3512. for _, item := range list {
  3513. detail := &models.DrugDetail{
  3514. SocialSecurityDirectoryCode: item.MedicalCode,
  3515. }
  3516. customs = append(customs, detail)
  3517. }
  3518. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3519. fmt.Println("reuslt", result)
  3520. var dat map[string]interface{}
  3521. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3522. fmt.Println(dat)
  3523. } else {
  3524. fmt.Println(err)
  3525. }
  3526. userJSONBytes, _ := json.Marshal(dat)
  3527. var res Result
  3528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3529. utils.ErrorLog("解析失败:%v", err)
  3530. c.ServeSuccessJSON(map[string]interface{}{
  3531. "failed_code": -10,
  3532. "msg": res.Transreturnmessage,
  3533. })
  3534. return
  3535. }
  3536. if res.Transreturncode == "00000000" {
  3537. //核销成功返回状态码
  3538. _, err := service.UpdateMyProjectById(id)
  3539. fmt.Println("err", err)
  3540. } else {
  3541. isSuccess = false
  3542. //失败
  3543. c.ServeSuccessJSON(map[string]interface{}{
  3544. "failed_code": -10,
  3545. "msg": res.Transreturnmessage,
  3546. })
  3547. return
  3548. }
  3549. fmt.Println(isSuccess)
  3550. }
  3551. }
  3552. fmt.Println("is_marke", is_mark)
  3553. //备案
  3554. if is_mark == 0 {
  3555. adminUserInfo := c.GetAdminUserInfo()
  3556. orgId := adminUserInfo.CurrentOrgId
  3557. //获取药品库数据
  3558. list, _ := service.GetMyPorjecgListDetail(orgId, id)
  3559. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3560. var doctor_name string
  3561. var doctor_code string
  3562. doctor_name = roles.UserName
  3563. doctor_code = "1001"
  3564. var isSuccess bool = true
  3565. for _, item := range list {
  3566. detail := &models.MyHisProject{
  3567. MedicalCode: item.MedicalCode, //社保目录
  3568. ProjectName: item.ProjectName,
  3569. Price: item.Price,
  3570. Category: item.Category,
  3571. Remark: item.Remark,
  3572. }
  3573. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, detail)
  3574. fmt.Println("reuslt9999999999999999", result)
  3575. var dat map[string]interface{}
  3576. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3577. fmt.Println(dat)
  3578. } else {
  3579. fmt.Println(err)
  3580. }
  3581. userJSONBytes, _ := json.Marshal(dat)
  3582. var res Result
  3583. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3584. utils.ErrorLog("解析失败:%v", err)
  3585. c.ServeSuccessJSON(map[string]interface{}{
  3586. "failed_code": -10,
  3587. "msg": res.Transreturnmessage,
  3588. })
  3589. return
  3590. }
  3591. if res.Transreturncode == "00000000" {
  3592. //备案成功返回状态值
  3593. _, err := service.UpdateProjectById(item.ID)
  3594. fmt.Println("err22222", err)
  3595. } else {
  3596. isSuccess = false
  3597. //失败
  3598. c.ServeSuccessJSON(map[string]interface{}{
  3599. "failed_code": -10,
  3600. "msg": res.Transreturnmessage,
  3601. })
  3602. return
  3603. }
  3604. fmt.Println(isSuccess)
  3605. }
  3606. }
  3607. }
  3608. if type_id == 3 {
  3609. //撤销
  3610. if is_mark == 1 {
  3611. //获取药品库数据
  3612. list, _ := service.GetGoodListByDetail(orgId, id)
  3613. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3614. var doctor_name string
  3615. var doctor_code string
  3616. doctor_name = roles.UserName
  3617. doctor_code = "1001"
  3618. var pagesize int = 50
  3619. var start int = 1
  3620. var stop int
  3621. var pagecount int
  3622. var curpage int
  3623. var isSuccess bool = true
  3624. //总页数,向上取整,注意除之前要先转换类型为float64
  3625. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  3626. for curpage = 1; curpage <= pagecount; curpage++ {
  3627. if curpage == 1 {
  3628. start = 1
  3629. } else {
  3630. start = (curpage-1)*pagesize + 1
  3631. }
  3632. stop = curpage * pagesize
  3633. if stop > len(list) {
  3634. stop = len(list)
  3635. }
  3636. //这里就可以查看开始和结束了
  3637. fmt.Println(list[start-1 : stop])
  3638. var customs []*models.DrugDetail
  3639. for _, item := range list {
  3640. fmt.Println("医疗机构编码", item.SocialSecurityDirectoryCode)
  3641. detail := &models.DrugDetail{
  3642. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3643. ManufacturerName: item.ManufacturerName,
  3644. }
  3645. customs = append(customs, detail)
  3646. }
  3647. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs, type_id)
  3648. fmt.Println("reuslt", result)
  3649. var dat map[string]interface{}
  3650. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3651. fmt.Println(dat)
  3652. } else {
  3653. fmt.Println(err)
  3654. }
  3655. userJSONBytes, _ := json.Marshal(dat)
  3656. var res Result
  3657. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3658. utils.ErrorLog("解析失败:%v", err)
  3659. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3660. return
  3661. }
  3662. if res.Transreturncode == "00000000" {
  3663. //撤销成功后改变状态
  3664. _, err := service.UpdateGoodInfoById(id)
  3665. fmt.Println("err", err)
  3666. } else {
  3667. isSuccess = false
  3668. //失败
  3669. c.ServeSuccessJSON(map[string]interface{}{
  3670. "failed_code": -10,
  3671. "msg": res.Transreturnmessage,
  3672. })
  3673. return
  3674. }
  3675. fmt.Println(isSuccess)
  3676. }
  3677. }
  3678. //备案
  3679. if is_mark == 0 {
  3680. adminUserInfo := c.GetAdminUserInfo()
  3681. orgId := adminUserInfo.CurrentOrgId
  3682. fmt.Println("3344555555555", orgId)
  3683. //获取所有耗材信息
  3684. list, _ := service.GetGoodListByDetail(orgId, id)
  3685. fmt.Println("list22222", list)
  3686. //获取单位
  3687. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3688. var doctor_name string
  3689. var doctor_code string
  3690. doctor_name = roles.UserName
  3691. doctor_code = "1001"
  3692. var isSuccess bool = true
  3693. for _, item := range list {
  3694. fmt.Println("生产厂商", item.ManufacturerName)
  3695. detail := &models.XtGoodInformation{
  3696. GoodName: item.GoodName,
  3697. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  3698. ManufacturerName: item.ManufacturerName,
  3699. ProductionType: item.ProductionType,
  3700. SpecialMedical: item.SpecialMedical,
  3701. BuyPrice: item.BuyPrice,
  3702. SellPrice: item.SellPrice,
  3703. Remark: item.Remark,
  3704. SpecificationName: item.SpecificationName,
  3705. }
  3706. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  3707. fmt.Println("reuslt8888", result)
  3708. var dat map[string]interface{}
  3709. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3710. fmt.Println(dat)
  3711. } else {
  3712. fmt.Println(err)
  3713. }
  3714. userJSONBytes, _ := json.Marshal(dat)
  3715. var res Result
  3716. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3717. utils.ErrorLog("解析失败:%v", err)
  3718. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3719. return
  3720. }
  3721. if res.Transreturncode == "00000000" {
  3722. //备案成功返回状态
  3723. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  3724. fmt.Println("err2222222", err)
  3725. } else {
  3726. isSuccess = false
  3727. //失败
  3728. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  3729. return
  3730. }
  3731. fmt.Println(isSuccess)
  3732. }
  3733. }
  3734. }
  3735. }
  3736. func (c *SZHisApiController) GetDoctorList() {
  3737. adminUserInfo := c.GetAdminUserInfo()
  3738. orgid := adminUserInfo.CurrentOrgId
  3739. fmt.Println("or3gi", orgid)
  3740. ids := c.GetString("ids")
  3741. fmt.Println("ids2222222222", ids)
  3742. admin_user_id, _ := c.GetInt64("admin_user_id")
  3743. roles, _ := service.GetAdminUserInfoByID(orgid, admin_user_id)
  3744. stringarr := strings.Split(ids, ",")
  3745. idss := make([]int64, 0)
  3746. for _, item := range stringarr {
  3747. itemsss, _ := strconv.ParseInt(item, 10, 64)
  3748. id := int64(itemsss)
  3749. idss = append(idss, id)
  3750. }
  3751. //获取所有医生护士信息
  3752. //list, _ := service.GetDoctorList(orgid)
  3753. //批量查询
  3754. list, _ := service.GetBatchDoctorList(idss)
  3755. fmt.Println("list22222222222", list)
  3756. //获取所有角色名称
  3757. roleList, _ := service.GetRoleList(orgid)
  3758. miConfig, _ := service.FindMedicalInsuranceInfo(orgid)
  3759. for _, item := range list {
  3760. for _, it := range roleList {
  3761. if item.RoleId == it.ID {
  3762. item.Name = it.RoleName
  3763. }
  3764. }
  3765. }
  3766. var doctor_name string
  3767. var doctor_code string
  3768. doctor_name = roles.UserName
  3769. doctor_code = "1001"
  3770. var isSuccess bool = true
  3771. for _, item := range list {
  3772. fmt.Println("医护类别", item.StudyMajorName)
  3773. detail := &models.DocDetail{
  3774. UserName: item.UserName, //医护姓名
  3775. RoleId: item.Name, //医护人员类别
  3776. Sex: strconv.FormatInt(item.Sex, 10), //性别
  3777. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  3778. IdCard: item.IdCard, //证件号码
  3779. Phone: item.Mobile, //联系电话
  3780. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  3781. Nation: item.Nation, //民族
  3782. BirthDay: 20201022, // 出生日期
  3783. WorkTime: 20201022, //参加工作日期
  3784. Education: strconv.FormatInt(item.Education, 10), //学历
  3785. StudyMajorName: item.StudyMajorName, //所学的专业名称
  3786. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  3787. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  3788. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  3789. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  3790. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  3791. DoctorNumber: item.DoctorNumber, //医保医师编号
  3792. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  3793. DoctorServiceStatus: "", //医师医保服务资格状态
  3794. MonitoringLevel: "", //监控等级
  3795. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  3796. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  3797. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  3798. PharmacistType: "", //药师类别
  3799. PharmacistPracticeCategory: "", //药师执业类别
  3800. PharmacistsLicensing: "", //药师执业范围
  3801. PharmacistRegistrationNumber: "", //执业药师注册证编号
  3802. OfficeCode: "", //科室编码
  3803. JobNumber: item.JobNumber, //工号
  3804. PostName: "", //职位名称
  3805. TechnicalJobLevelCode: "", //专业技术职务级别编码
  3806. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  3807. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  3808. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  3809. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  3810. StartTime: 20201010, //开始日期
  3811. StaffCode: "", //医护人员编码
  3812. EndTime: 0, // 结束日期
  3813. }
  3814. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  3815. fmt.Println("reuslt9999999999999999", result)
  3816. var dat map[string]interface{}
  3817. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3818. fmt.Println(dat)
  3819. } else {
  3820. fmt.Println(err)
  3821. }
  3822. userJSONBytes, _ := json.Marshal(dat)
  3823. var res Result
  3824. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3825. utils.ErrorLog("解析失败:%v", err)
  3826. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3827. return
  3828. }
  3829. if res.Transreturncode == "00000000" {
  3830. //批量插入数据
  3831. _, err := service.UpdateAdminUserRoleById(item.AdminUserId, orgid)
  3832. fmt.Println("err2222", err)
  3833. } else {
  3834. isSuccess = false
  3835. //失败
  3836. c.ServeSuccessJSON(map[string]interface{}{
  3837. "failed_code": -10,
  3838. "msg": res.Transreturnmessage,
  3839. })
  3840. return
  3841. }
  3842. fmt.Println(isSuccess)
  3843. }
  3844. }
  3845. func (c *SZHisApiController) GetMedicalList() {
  3846. adminUserInfo := c.GetAdminUserInfo()
  3847. orgId := adminUserInfo.CurrentOrgId
  3848. id, _ := c.GetInt64("id")
  3849. fmt.Println("id22222222", id)
  3850. is_mark, _ := c.GetInt64("is_mark")
  3851. admin_user_id, _ := c.GetInt64("admin_user_id")
  3852. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  3853. //去登记
  3854. if is_mark == 0 {
  3855. list, _ := service.GetDoctorListByDetail(orgId, id)
  3856. fmt.Println("list22222222222", list)
  3857. //获取所有角色名称
  3858. roleList, _ := service.GetRoleList(orgId)
  3859. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3860. for _, item := range list {
  3861. for _, it := range roleList {
  3862. if item.RoleId == it.ID {
  3863. item.Name = it.RoleName
  3864. }
  3865. }
  3866. }
  3867. var doctor_name string
  3868. var doctor_code string
  3869. doctor_name = roles.UserName
  3870. doctor_code = "1001"
  3871. var isSuccess bool = true
  3872. for _, item := range list {
  3873. fmt.Println("医护类别", item.Mobile)
  3874. detail := &models.DocDetail{
  3875. UserName: item.UserName, //医护姓名
  3876. RoleId: item.Name, //医护人员类别
  3877. Sex: strconv.FormatInt(item.Sex, 10), //性别
  3878. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  3879. IdCard: item.IdCard, //证件号码
  3880. Phone: item.Mobile, //联系电话
  3881. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  3882. Nation: item.Nation, //民族
  3883. BirthDay: 20201022, // 出生日期
  3884. WorkTime: 20201022, //参加工作日期
  3885. Education: strconv.FormatInt(item.Education, 10), //学历
  3886. StudyMajorName: item.StudyMajorName, //所学的专业名称
  3887. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  3888. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  3889. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  3890. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  3891. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  3892. DoctorNumber: item.DoctorNumber, //医保医师编号
  3893. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  3894. DoctorServiceStatus: "", //医师医保服务资格状态
  3895. MonitoringLevel: "", //监控等级
  3896. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  3897. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  3898. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  3899. PharmacistType: "", //药师类别
  3900. PharmacistPracticeCategory: "", //药师执业类别
  3901. PharmacistsLicensing: "", //药师执业范围
  3902. PharmacistRegistrationNumber: "", //执业药师注册证编号
  3903. OfficeCode: "", //科室编码
  3904. JobNumber: item.JobNumber, //工号
  3905. PostName: "", //职位名称
  3906. TechnicalJobLevelCode: "", //专业技术职务级别编码
  3907. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  3908. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  3909. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  3910. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  3911. StartTime: 20201010, //开始日期
  3912. StaffCode: "", //医护人员编码
  3913. EndTime: 0, // 结束日期
  3914. }
  3915. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, detail)
  3916. fmt.Println("reuslt9999999999999999", result)
  3917. var dat map[string]interface{}
  3918. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  3919. fmt.Println(dat)
  3920. } else {
  3921. fmt.Println(err)
  3922. }
  3923. userJSONBytes, _ := json.Marshal(dat)
  3924. var res Result
  3925. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  3926. utils.ErrorLog("解析失败:%v", err)
  3927. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  3928. return
  3929. }
  3930. if res.Transreturncode == "00000000" {
  3931. //登记成功
  3932. service.UpdateAdminUserRoleById(item.ID, orgId)
  3933. } else {
  3934. isSuccess = false
  3935. //失败
  3936. c.ServeSuccessJSON(map[string]interface{}{
  3937. "failed_code": -10,
  3938. "msg": res.Transreturnmessage,
  3939. })
  3940. return
  3941. }
  3942. fmt.Println(isSuccess)
  3943. }
  3944. }
  3945. //去撤销
  3946. if is_mark == 1 {
  3947. //获取所有医生护士信息
  3948. list, _ := service.GetDoctorListByDetail(orgId, id)
  3949. //获取所有角色名称
  3950. roleList, _ := service.GetRoleList(orgId)
  3951. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  3952. for _, item := range list {
  3953. for _, it := range roleList {
  3954. if item.RoleId == it.ID {
  3955. item.Name = it.RoleName
  3956. }
  3957. }
  3958. }
  3959. var doctor_name string
  3960. var doctor_code string
  3961. doctor_name = "黄亦轩"
  3962. doctor_code = "1001"
  3963. var isSuccess bool = true
  3964. for _, item := range list {
  3965. fmt.Println("医护类别", item.Name)
  3966. detail := &models.DocDetail{
  3967. UserName: item.UserName, //医护姓名
  3968. RoleId: item.Name, //医护人员类别
  3969. Sex: strconv.FormatInt(item.Sex, 10), //性别
  3970. CardType: strconv.FormatInt(item.CardType, 10), //证件类型
  3971. IdCard: item.IdCard, //证件号码
  3972. Phone: item.Mobile, //联系电话
  3973. WorkMajorName: item.WorkMajorName, // 现从事专业名称
  3974. Nation: item.Nation, //民族
  3975. BirthDay: 20201022, // 出生日期
  3976. WorkTime: 20201022, //参加工作日期
  3977. Education: strconv.FormatInt(item.Education, 10), //学历
  3978. StudyMajorName: item.StudyMajorName, //所学的专业名称
  3979. CertificateCode: item.MedicalCode, //医(药)师执业证书编码
  3980. MedicalCode: item.DoctorCode, //医(药)师资格证编码
  3981. MedicalRangeCode: strconv.FormatInt(item.DoctorRangeCode, 10), //医师执业范围代码
  3982. MedicalLevel: strconv.FormatInt(item.DoctorLevel, 10), //医生执业资格证中的医师级别
  3983. TypeJob: strconv.FormatInt(item.DoctorTypeJob, 10), //医生执业资格证中的执业类别
  3984. DoctorNumber: item.DoctorNumber, //医保医师编号
  3985. Licensing: strconv.FormatInt(item.Licensing, 10), //多点执业标志
  3986. DoctorServiceStatus: "", //医师医保服务资格状态
  3987. MonitoringLevel: "", //监控等级
  3988. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  3989. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  3990. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  3991. PharmacistType: "", //药师类别
  3992. PharmacistPracticeCategory: "", //药师执业类别
  3993. PharmacistsLicensing: "", //药师执业范围
  3994. PharmacistRegistrationNumber: "", //执业药师注册证编号
  3995. OfficeCode: "", //科室编码
  3996. JobNumber: item.JobNumber, //工号
  3997. PostName: "", //职位名称
  3998. TechnicalJobLevelCode: "", //专业技术职务级别编码
  3999. IsActive: strconv.FormatInt(item.IsActive, 10), //在职与否
  4000. PrescriptionQualificationIdentification: strconv.FormatInt(item.PrescriptionQualificationIdentification, 10), //处方资格标识
  4001. IdentificationOutpatients: strconv.FormatInt(item.IdentificationOutpatients, 10), //门诊大病医师标识
  4002. OutpatientIllnessCategory: item.OutpatientIllnessCategory, //门诊大病类别
  4003. StartTime: 20201010, //开始日期
  4004. StaffCode: "", //医护人员编码
  4005. EndTime: 0, // 结束日期
  4006. }
  4007. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, detail)
  4008. fmt.Println("reuslt9999999999999999", result)
  4009. var dat map[string]interface{}
  4010. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4011. fmt.Println(dat)
  4012. } else {
  4013. fmt.Println(err)
  4014. }
  4015. userJSONBytes, _ := json.Marshal(dat)
  4016. var res Result
  4017. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4018. utils.ErrorLog("解析失败:%v", err)
  4019. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4020. return
  4021. }
  4022. if res.Transreturncode == "00000000" {
  4023. //去撤销
  4024. service.UpdateAdminUserRoleById(item.ID, orgId)
  4025. } else {
  4026. isSuccess = false
  4027. //失败
  4028. c.ServeSuccessJSON(map[string]interface{}{
  4029. "failed_code": -10,
  4030. "msg": res.Transreturnmessage,
  4031. })
  4032. return
  4033. }
  4034. fmt.Println(isSuccess)
  4035. }
  4036. }
  4037. }
  4038. func (c *SZHisApiController) GetUpdateMedicalList() {
  4039. adminUserInfo := c.GetAdminUserInfo()
  4040. orgId := adminUserInfo.CurrentOrgId
  4041. //获取所有医生护士信息
  4042. list, _ := service.GetDoctorList(orgId)
  4043. //获取所有角色名称
  4044. roleList, _ := service.GetRoleList(orgId)
  4045. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4046. for _, item := range list {
  4047. for _, it := range roleList {
  4048. if item.RoleId == it.ID {
  4049. item.Name = it.RoleName
  4050. }
  4051. }
  4052. }
  4053. var doctor_name string
  4054. var doctor_code string
  4055. doctor_name = "黄亦轩"
  4056. doctor_code = "1001"
  4057. var pagesize int = 50
  4058. var start int = 1
  4059. var stop int
  4060. var pagecount int
  4061. var curpage int
  4062. var isSuccess bool = true
  4063. //总页数,向上取整,注意除之前要先转换类型为float64
  4064. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  4065. var ress []*Result
  4066. for curpage = 1; curpage <= pagecount; curpage++ {
  4067. if curpage == 1 {
  4068. start = 1
  4069. } else {
  4070. start = (curpage-1)*pagesize + 1
  4071. }
  4072. stop = curpage * pagesize
  4073. if stop > len(list) {
  4074. stop = len(list)
  4075. }
  4076. //这里就可以查看开始和结束了
  4077. fmt.Println(list[start-1 : stop])
  4078. var customs []*models.DocDetail
  4079. for _, item := range list {
  4080. fmt.Println("医护类别", item.Name)
  4081. detail := &models.DocDetail{
  4082. StaffCode: "", //医护人员编码
  4083. UserName: item.UserName, //医护人员姓名
  4084. RoleId: item.Name, //医护人员类别
  4085. Sex: "", //性别
  4086. CardType: "", //证件类型
  4087. IdCard: "", //证件号码
  4088. Phone: "", //联系电话
  4089. WorkMajorName: "", //现从事专业名称
  4090. Nation: "", //民族
  4091. BirthDay: 20201022, //出生日期
  4092. WorkTime: 12, //参加工作日期
  4093. Education: "", //学历
  4094. StudyMajorName: "", //所学的专业名称
  4095. CertificateCode: "", //证书编码
  4096. MedicalCode: "", //医师资格编码
  4097. MedicalRangeCode: "", //医师执业范围代码
  4098. MedicalLevel: "", //医生级别
  4099. TypeJob: "", //职业类别
  4100. DoctorNumber: "", //医师编号
  4101. Licensing: "", //职业标志
  4102. DoctorServiceStatus: "", //医师医保服务资格状态
  4103. MonitoringLevel: "", //监控等级
  4104. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  4105. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  4106. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  4107. PharmacistType: "", //药师类别
  4108. PharmacistPracticeCategory: "", //药师执业类别
  4109. PharmacistsLicensing: "", //药师执业范围
  4110. PharmacistRegistrationNumber: "", //执业药师注册证编号
  4111. OfficeCode: "", //科室编码
  4112. JobNumber: "", //工号
  4113. PostName: "", //职位名称
  4114. TechnicalJobLevelCode: "", //专业技术职务级别编码
  4115. IsActive: "", //在职与否
  4116. PrescriptionQualificationIdentification: "", //处方资格标识
  4117. IdentificationOutpatients: "", //门诊大病医师标识
  4118. OutpatientIllnessCategory: "", //门诊大病类别
  4119. StartTime: 1233, //开始日期
  4120. EndTime: 123333,
  4121. }
  4122. customs = append(customs, detail)
  4123. }
  4124. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  4125. fmt.Println("reuslt9999999999999999", result)
  4126. var dat map[string]interface{}
  4127. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4128. fmt.Println(dat)
  4129. } else {
  4130. fmt.Println(err)
  4131. }
  4132. userJSONBytes, _ := json.Marshal(dat)
  4133. var res Result
  4134. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4135. utils.ErrorLog("解析失败:%v", err)
  4136. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4137. return
  4138. }
  4139. if res.Transreturncode == "00000000" {
  4140. ress = append(ress, &res)
  4141. } else {
  4142. isSuccess = false
  4143. //失败
  4144. c.ServeFailJSONWithSGJErrorCode(enums.ErrorDrugPreSettleFaildParamWrong)
  4145. return
  4146. }
  4147. fmt.Println(isSuccess)
  4148. }
  4149. }
  4150. func (c *SZHisApiController) GetGoodsList() {
  4151. adminUserInfo := c.GetAdminUserInfo()
  4152. orgId := adminUserInfo.CurrentOrgId
  4153. ids := c.GetString("ids")
  4154. fmt.Println("ids2222222222", ids)
  4155. admin_user_id, _ := c.GetInt64("admin_user_id")
  4156. roles, _ := service.GetAdminUserInfoByID(orgId, admin_user_id)
  4157. stringarr := strings.Split(ids, ",")
  4158. idss := make([]int64, 0)
  4159. for _, item := range stringarr {
  4160. itemsss, _ := strconv.ParseInt(item, 10, 64)
  4161. id := int64(itemsss)
  4162. idss = append(idss, id)
  4163. }
  4164. //批量获取所有耗材信息
  4165. list, _ := service.GetBatchGoodInformationList(idss)
  4166. fmt.Println("list22222", list)
  4167. //获取单位
  4168. miConfig, _ := service.FindMedicalInsuranceInfo(orgId)
  4169. var doctor_name string
  4170. var doctor_code string
  4171. doctor_name = roles.UserName
  4172. doctor_code = "1001"
  4173. var isSuccess bool = true
  4174. for _, item := range list {
  4175. fmt.Println("生产厂商", item.ManufacturerName)
  4176. detail := &models.XtGoodInformation{
  4177. GoodName: item.GoodName,
  4178. SocialSecurityDirectoryCode: item.SocialSecurityDirectoryCode,
  4179. ManufacturerName: item.ManufacturerName,
  4180. ProductionType: item.ProductionType,
  4181. SpecialMedical: item.SpecialMedical,
  4182. BuyPrice: item.BuyPrice,
  4183. SellPrice: item.SellPrice,
  4184. Remark: item.Remark,
  4185. SpecificationName: item.SpecificationName,
  4186. }
  4187. result := service.SzybYML007(doctor_name, doctor_code, miConfig.Code, detail)
  4188. fmt.Println("reuslt8888", result)
  4189. var dat map[string]interface{}
  4190. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  4191. fmt.Println(dat)
  4192. } else {
  4193. fmt.Println(err)
  4194. }
  4195. userJSONBytes, _ := json.Marshal(dat)
  4196. var res Result
  4197. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  4198. utils.ErrorLog("解析失败:%v", err)
  4199. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  4200. return
  4201. }
  4202. if res.Transreturncode == "00000000" {
  4203. //备案成功返回状态
  4204. _, err := service.UpdateGoodInformaitonByDetail(item.ID)
  4205. fmt.Println("err2222222", err)
  4206. } else {
  4207. isSuccess = false
  4208. //失败
  4209. c.ServeSuccessJSON(map[string]interface{}{
  4210. "failed_code": -10,
  4211. "msg": res.Transreturnmessage,
  4212. })
  4213. return
  4214. }
  4215. fmt.Println(isSuccess)
  4216. }
  4217. }
  4218. type Charset string
  4219. const (
  4220. UTF8 = Charset("UTF-8")
  4221. GB18030 = Charset("GB18030")
  4222. )
  4223. func ConvertToString(src string, srcCode string, tagCode string) string {
  4224. srcCoder := mahonia.NewDecoder(srcCode)
  4225. srcResult := srcCoder.ConvertString(src)
  4226. tagCoder := mahonia.NewDecoder(tagCode)
  4227. _, cdata, _ := tagCoder.Translate([]byte(srcResult), true)
  4228. result := string(cdata)
  4229. return result
  4230. }