sz_his_api_controller.go 164KB

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