sz_his_api_controller.go 163KB

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