sz_his_api_controller.go 78KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396
  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. "math"
  12. "math/rand"
  13. "strconv"
  14. "strings"
  15. //"strings"
  16. "syscall"
  17. "time"
  18. "unsafe"
  19. )
  20. type Result struct {
  21. Transtime string `json:"transTime"`
  22. Transtype string `json:"transType"`
  23. Transreturncode string `json:"transReturnCode"`
  24. Transreturnmessage string `json:"transReturnMessage"`
  25. Transversion string `json:"transVersion"`
  26. Serialnumber string `json:"serialNumber"`
  27. Cardarea string `json:"cardArea"`
  28. Hospitalcode string `json:"hospitalCode"`
  29. Operatorcode string `json:"operatorCode"`
  30. Operatorname string `json:"operatorName"`
  31. Operatorpass string `json:"operatorPass"`
  32. Transbody struct {
  33. Akc190 string `json:"akc190"`
  34. Listsize int `json:"listsize"`
  35. Outputlist []struct {
  36. Aae072 string `json:"aae072"`
  37. Bkc369 string `json:"bkc369"`
  38. Bkf500 string `json:"bkf500"`
  39. Aka111 string `json:"aka111"`
  40. Ake001 string `json:"ake001"`
  41. Ake002 string `json:"ake002"`
  42. Bkm017 string `json:"bkm017"`
  43. Ake005 string `json:"ake005"`
  44. Ake006 string `json:"ake006"`
  45. Akc225 float64 `json:"akc225"`
  46. Akc226 float64 `json:"akc226"`
  47. Akc264 float64 `json:"akc264"`
  48. Aka065 string `json:"aka065"`
  49. Cka319 float64 `json:"cka319"`
  50. Akc268 float64 `json:"akc268"`
  51. } `json:"outputlist"`
  52. } `json:"transBody"`
  53. Verifycode string `json:"verifyCode"`
  54. Extenddeviceid string `json:"extendDeviceId"`
  55. Transchannel string `json:"transChannel"`
  56. Extenduserid string `json:"extendUserId"`
  57. Extendserialnumber string `json:"extendSerialNumber"`
  58. Caz055 string `json:"caz055"`
  59. Aae501 string `json:"aae501"`
  60. }
  61. type ResultOne struct {
  62. Transtime string `json:"transTime"`
  63. Transtype string `json:"transType"`
  64. Transreturncode string `json:"transReturnCode"`
  65. Transreturnmessage string `json:"transReturnMessage"`
  66. Transversion string `json:"transVersion"`
  67. Serialnumber string `json:"serialNumber"`
  68. Cardarea string `json:"cardArea"`
  69. Hospitalcode string `json:"hospitalCode"`
  70. Operatorcode string `json:"operatorCode"`
  71. Operatorname string `json:"operatorName"`
  72. Operatorpass string `json:"operatorPass"`
  73. Transbody struct {
  74. Ckc618 string `json:"ckc618"`
  75. Akc264 float64 `json:"akc264"`
  76. Akb068 int `json:"akb068"`
  77. Akb066 float64 `json:"akb066"`
  78. Akb067 int `json:"akb067"`
  79. Aae240 float64 `json:"aae240"`
  80. Outputlist []struct {
  81. Aaa036 string `json:"aaa036"`
  82. Aae019 float64 `json:"aae019"`
  83. } `json:"outputlist"`
  84. Outputlist2 []interface{} `json:"outputlist2"`
  85. } `json:"transBody"`
  86. Verifycode string `json:"verifyCode"`
  87. Extenddeviceid string `json:"extendDeviceId"`
  88. Transchannel string `json:"transChannel"`
  89. Extenduserid string `json:"extendUserId"`
  90. Extendserialnumber string `json:"extendSerialNumber"`
  91. Caz055 string `json:"caz055"`
  92. Aae501 string `json:"aae501"`
  93. }
  94. type ResultTwo struct {
  95. Transtime string `json:"transTime"`
  96. Transtype string `json:"transType"`
  97. Transreturncode string `json:"transReturnCode"`
  98. Transreturnmessage string `json:"transReturnMessage"`
  99. Transversion string `json:"transVersion"`
  100. Serialnumber string `json:"serialNumber"`
  101. Cardarea string `json:"cardArea"`
  102. Hospitalcode string `json:"hospitalCode"`
  103. Operatorcode string `json:"operatorCode"`
  104. Operatorname string `json:"operatorName"`
  105. Operatorpass string `json:"operatorPass"`
  106. Transbody struct {
  107. Ckc618 string `json:"ckc618"`
  108. Akc264 float64 `json:"akc264"`
  109. Akb068 float64 `json:"akb068"`
  110. Akb066 float64 `json:"akb066"`
  111. Akb067 float64 `json:"akb067"`
  112. Aae240 float64 `json:"aae240"`
  113. Outputlist1 []struct {
  114. Aka111 string `json:"aka111"`
  115. Bka058 float64 `json:"bka058"`
  116. } `json:"outputlist1"`
  117. Outputlist2 []struct {
  118. Aaa036 string `json:"aaa036"`
  119. Aae019 float64 `json:"aae019"`
  120. } `json:"outputlist2"`
  121. Outputlist3 []interface{} `json:"outputlist3"`
  122. } `json:"transBody"`
  123. Verifycode string `json:"verifyCode"`
  124. Extenddeviceid string `json:"extendDeviceId"`
  125. Transchannel string `json:"transChannel"`
  126. Extenduserid string `json:"extendUserId"`
  127. Extendserialnumber string `json:"extendSerialNumber"`
  128. Caz055 string `json:"caz055"`
  129. Aae501 string `json:"aae501"`
  130. }
  131. type ResultThree struct {
  132. Transtime string `json:"transTime"`
  133. Transtype string `json:"transType"`
  134. Transreturncode string `json:"transReturnCode"`
  135. Transreturnmessage string `json:"transReturnMessage"`
  136. Transversion string `json:"transVersion"`
  137. Serialnumber string `json:"serialNumber"`
  138. Cardarea string `json:"cardArea"`
  139. Hospitalcode string `json:"hospitalCode"`
  140. Operatorcode string `json:"operatorCode"`
  141. Operatorname string `json:"operatorName"`
  142. Operatorpass string `json:"operatorPass"`
  143. Transbody struct {
  144. Baz700 string `json:"baz700"`
  145. Ckc618 string `json:"ckc618"`
  146. } `json:"transBody"`
  147. Verifycode string `json:"verifyCode"`
  148. Extenddeviceid string `json:"extendDeviceId"`
  149. Transchannel string `json:"transChannel"`
  150. Extenduserid string `json:"extendUserId"`
  151. Extendserialnumber string `json:"extendSerialNumber"`
  152. Caz055 string `json:"caz055"`
  153. Aae501 string `json:"aae501"`
  154. }
  155. type ResultFour struct {
  156. Transtime string `json:"transTime"`
  157. Transtype string `json:"transType"`
  158. Transreturncode string `json:"transReturnCode"`
  159. Transreturnmessage string `json:"transReturnMessage"`
  160. Transversion string `json:"transVersion"`
  161. Serialnumber string `json:"serialNumber"`
  162. Cardarea string `json:"cardArea"`
  163. Hospitalcode string `json:"hospitalCode"`
  164. Operatorcode string `json:"operatorCode"`
  165. Operatorname string `json:"operatorName"`
  166. Operatorpass string `json:"operatorPass"`
  167. Transbody struct {
  168. Akc190 string `json:"akc190"`
  169. Akc194 float64 `json:"akc194"`
  170. Bae917 int64 `json:"bae917"`
  171. Aka018 string `json:"aka018"`
  172. Aka030 string `json:"aka030"`
  173. Ckc618 string `json:"ckc618"`
  174. Akc264 float64 `json:"akc264"`
  175. Akb068 float64 `json:"akb068"`
  176. Akb066 float64 `json:"akb066"`
  177. Akb067 float64 `json:"akb067"`
  178. Cke298 float64 `json:"cke298"`
  179. Aae240 float64 `json:"aae240"`
  180. Outputlist2 []struct {
  181. Aka111 string `json:"aka111"`
  182. Bka058 float64 `json:"bka058"`
  183. } `json:"outputlist2"`
  184. Outputlist3 []struct {
  185. Aaa036 string `json:"aaa036"`
  186. Aae019 float64 `json:"aae019"`
  187. } `json:"outputlist3"`
  188. } `json:"transBody"`
  189. Verifycode string `json:"verifyCode"`
  190. Extenddeviceid string `json:"extendDeviceId"`
  191. Transchannel string `json:"transChannel"`
  192. Extenduserid string `json:"extendUserId"`
  193. Extendserialnumber string `json:"extendSerialNumber"`
  194. Caz055 string `json:"caz055"`
  195. Aae501 string `json:"aae501"`
  196. }
  197. type ResultFive struct {
  198. Transtime string `json:"transTime"`
  199. Transtype string `json:"transType"`
  200. Transreturncode string `json:"transReturnCode"`
  201. Transreturnmessage string `json:"transReturnMessage"`
  202. Transversion string `json:"transVersion"`
  203. Serialnumber string `json:"serialNumber"`
  204. Cardarea string `json:"cardArea"`
  205. Hospitalcode string `json:"hospitalCode"`
  206. Operatorcode string `json:"operatorCode"`
  207. Operatorname string `json:"operatorName"`
  208. Operatorpass string `json:"operatorPass"`
  209. Transbody struct {
  210. Akc190 string `json:"akc190"`
  211. Listsize int `json:"listsize"`
  212. Outputlist []struct {
  213. Aae072 string `json:"aae072"`
  214. Bkf500 string `json:"bkf500"`
  215. Baz700 string `json:"baz700"`
  216. Bce574 string `json:"bce574"`
  217. } `json:"outputlist"`
  218. } `json:"transBody"`
  219. Verifycode string `json:"verifyCode"`
  220. Extenddeviceid string `json:"extendDeviceId"`
  221. Transchannel string `json:"transChannel"`
  222. Extenduserid string `json:"extendUserId"`
  223. Extendserialnumber string `json:"extendSerialNumber"`
  224. Caz055 string `json:"caz055"`
  225. Aae501 string `json:"aae501"`
  226. }
  227. type SZHisApiController struct {
  228. controllers.BaseAuthAPIController
  229. }
  230. func SZHisManagerApiRegistRouters() {
  231. //挂号
  232. beego.Router("/sz/api/register/get", &SZHisApiController{}, "get:GetRegisterInfo")
  233. //上传明细,预结算
  234. beego.Router("/sz/api/upload/get", &SZHisApiController{}, "get:GetUploadInfo")
  235. //结算
  236. beego.Router("/sz/api/settle/get", &SZHisApiController{}, "get:GetSettleInfo")
  237. //退费
  238. beego.Router("/sz/api/refund/get", &SZHisApiController{}, "get:Refund")
  239. beego.Router("/sz/api/monthrefund/get", &SZHisApiController{}, "get:MonthRefund")
  240. //查询交易
  241. beego.Router("/sz/api/settle/query", &SZHisApiController{}, "get:GetSettleAccounts")
  242. //撤销明细
  243. beego.Router("/sz/api/detail/cancel", &SZHisApiController{}, "get:CancelOrderDetail")
  244. //机构药品目录备案
  245. beego.Router("/sz/api/drug/get", &SZHisApiController{}, "get:GetDrugList")
  246. //协议机构诊疗项目
  247. beego.Router("/sz/api/treatment/get", &SZHisApiController{}, "get:GetTreatmentProject")
  248. //协议机构目录
  249. beego.Router("/sz/api/revocation/get", &SZHisApiController{}, "get:GetRevocation")
  250. //定点机构约定信息查询
  251. //beego.Router("/sz/api/information/query/get",&SZHisApiController{},"get:GetInformationQuery")
  252. //-医药师信息登记
  253. beego.Router("/sz/api/doctor/get", &SZHisApiController{}, "get:GetDoctorList")
  254. //医药师执业状态变更
  255. beego.Router("/sz/api/medical/get", &SZHisApiController{}, "get:GetMedicalList")
  256. //医药师信息更新
  257. beego.Router("/sz/api/update/medical/get", &SZHisApiController{}, "get:GetUpdateMedicalList")
  258. }
  259. func IntPtr(n int) uintptr {
  260. return uintptr(n)
  261. }
  262. func StrPtr(s string) uintptr {
  263. return uintptr(unsafe.Pointer(syscall.StringBytePtr(s)))
  264. }
  265. type Custom struct {
  266. DetItemFeeSumamt string
  267. Cut string
  268. FeedetlSn string
  269. Price string
  270. MedListCodg string
  271. Type int64
  272. AdviceId int64
  273. ProjectId int64
  274. ItemId int64
  275. }
  276. //获取读卡信息 -- 门诊挂号
  277. func (c *SZHisApiController) GetRegisterInfo() {
  278. adminInfo := c.GetAdminUserInfo()
  279. admin_user_id, _ := c.GetInt64("admin_user_id")
  280. patient_id, _ := c.GetInt64("id")
  281. record_time := c.GetString("record_time")
  282. settlementValue, _ := c.GetInt64("settlement_value")
  283. medical_insurance_card := c.GetString("medical_insurance_card")
  284. name := c.GetString("name")
  285. id_card_type, _ := c.GetInt64("id_card_type")
  286. certificates, _ := c.GetInt64("certificates")
  287. medical_care, _ := c.GetInt64("medical_care")
  288. birthday := c.GetString("birthday")
  289. id_card := c.GetString("id_card")
  290. register_type, _ := c.GetInt64("register")
  291. doctor, _ := c.GetInt64("doctor")
  292. department, _ := c.GetInt64("department")
  293. gender, _ := c.GetInt64("sex")
  294. registration_fee, _ := c.GetFloat("registration_fee")
  295. medical_expenses, _ := c.GetFloat("medical_expenses")
  296. social_type, _ := c.GetInt64("social_type")
  297. is_yidi, _ := c.GetInt64("is_yidi")
  298. timeLayout := "2006-01-02"
  299. loc, _ := time.LoadLocation("Local")
  300. birthdays, _ := time.ParseInLocation(timeLayout+" 15:04:05", birthday+" 00:00:00", loc)
  301. birthUnix := birthdays.Unix()
  302. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  303. if err != nil {
  304. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  305. return
  306. }
  307. var patient service.Patients
  308. if patient_id == 0 {
  309. patient, _ = service.GetPatientByIDCard(id_card, adminInfo.CurrentOrgId)
  310. } else {
  311. patient, _ = service.GetPatientByIDTwo(adminInfo.CurrentOrgId, patient_id)
  312. }
  313. miConfig, _ := service.FindMedicalInsuranceInfo(adminInfo.CurrentOrgId)
  314. if patient.ID == 0 {
  315. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  316. return
  317. }
  318. if len(patient.IdCardNo) == 0 {
  319. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeIDCartNo)
  320. return
  321. }
  322. adminRole, _ := service.GetAdminUserInfoByID(adminInfo.CurrentOrgId, admin_user_id)
  323. his, _ := service.GetHisPatientInfo(adminInfo.CurrentOrgId, patient_id, theTime.Unix())
  324. var custom_code string
  325. var custom_project_name string
  326. var allPrice float64
  327. switch register_type {
  328. case 1:
  329. custom_code = "110100002"
  330. custom_project_name = "普通门诊"
  331. allPrice = registration_fee + medical_expenses
  332. break
  333. case 3:
  334. custom_code = "110200002-2"
  335. custom_project_name = "主任医师"
  336. allPrice = registration_fee + medical_expenses
  337. break
  338. case 2:
  339. custom_code = "110200002-3"
  340. custom_project_name = "副主任医师"
  341. allPrice = registration_fee + medical_expenses
  342. break
  343. case 4:
  344. custom_code = "0"
  345. custom_project_name = "免受诊金"
  346. allPrice = 0
  347. break
  348. case 5:
  349. custom_code = "110200002-1"
  350. custom_project_name = "专家"
  351. allPrice = registration_fee + medical_expenses
  352. break
  353. }
  354. if his.ID == 0 {
  355. var doctor_name string
  356. var doctor_code string
  357. if adminRole.ID == 0 {
  358. doctor_name = "黄亦轩"
  359. doctor_code = "1001"
  360. } else {
  361. doctor_name = adminRole.UserName
  362. doctor_code = strconv.FormatInt(admin_user_id, 10)
  363. }
  364. month := time.Unix(1557042972, 0).Format("1")
  365. year := time.Now().Format("2006")
  366. month = time.Now().Format("01")
  367. day := time.Now().Format("02")
  368. //流水号
  369. //
  370. number := miConfig.Code + year + month + day +
  371. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  372. mz_number := year + month + day + strconv.FormatInt(patient_id, 10) +
  373. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000))
  374. //number := miConfig.Code + year + month + day + "1590000"
  375. verifyCode, version_code := ReadCardGetCode("MZ002" + "|" + number + "|" + miConfig.Code)
  376. //verifyCode := "000000|4c871a545d1006754246a50a85c3a353"
  377. //version_code := "V0.3"
  378. //1.判断读卡类型
  379. //2.读卡 获取交易验证码,医疗证号,发卡地区行政区划代码
  380. //yiliao_number, id_card_number,verifyCode, err, ret4 := ReadBasCardGetNumber(number)
  381. yiliao_number := "%GAAFSAKSXSUKKWDKHDAD?;07734724145330238292?"
  382. //id_card_number := "142729195704031523"
  383. dept_code := "0305"
  384. ret4 := 0
  385. is_yidi = 1
  386. if err != nil {
  387. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeNoPateintException)
  388. return
  389. }
  390. if ret4 == 0 { //本地卡流程
  391. if is_yidi == 1 { //本地就医流程
  392. //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  393. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  394. //if tempPatient.ID == patient_id {
  395. //挂号
  396. 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)
  397. var dat map[string]interface{}
  398. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  399. fmt.Println(dat)
  400. } else {
  401. fmt.Println(err)
  402. }
  403. userJSONBytes, _ := json.Marshal(dat)
  404. var res ResultOne
  405. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  406. utils.ErrorLog("解析失败:%v", err)
  407. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  408. return
  409. }
  410. if res.Transreturncode == "00000000" {
  411. his := models.VMHisPatient{
  412. Name: name,
  413. Gender: gender,
  414. Birthday: birthUnix,
  415. MedicalTreatmentType: medical_care,
  416. IdType: certificates,
  417. IdCardNo: id_card,
  418. BalanceAccountsType: settlementValue,
  419. SocialType: social_type,
  420. MedicalInsuranceNumber: medical_insurance_card,
  421. RegisterType: register_type,
  422. RegisterCost: registration_fee,
  423. TreatmentCost: medical_expenses,
  424. Status: 1,
  425. Ctime: time.Now().Unix(),
  426. Mtime: time.Now().Unix(),
  427. Iinfo: resp_result,
  428. PatientId: patient.ID,
  429. RecordDate: theTime.Unix(),
  430. UserOrgId: adminInfo.CurrentOrgId,
  431. AdminUserId: admin_user_id,
  432. IsReturn: 1,
  433. IdCardType: id_card_type,
  434. Doctor: doctor,
  435. Departments: department,
  436. YiliaoNumber: yiliao_number,
  437. MzNumber: number,
  438. Number: mz_number,
  439. }
  440. service.CreateHisPatientTwo(&his)
  441. c.ServeSuccessJSON(map[string]interface{}{
  442. "msg": "挂号成功",
  443. })
  444. } else {
  445. c.ServeSuccessJSON(map[string]interface{}{
  446. "failed_code": -10,
  447. "msg": res.Transreturnmessage,
  448. })
  449. return
  450. }
  451. } else { //异地就医流程
  452. //异地走鉴权流程
  453. //authResult := CardAuth(number)
  454. //fmt.Println(authResult)
  455. //tempPatient, _ := service.GetPatientByNumber(id_card_number, adminInfo.CurrentOrgId)
  456. //if tempPatient.ID == patient_id {
  457. 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)
  458. var dat map[string]interface{}
  459. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  460. fmt.Println(dat)
  461. } else {
  462. fmt.Println(err)
  463. }
  464. userJSONBytes, _ := json.Marshal(dat)
  465. var res ResultOne
  466. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  467. utils.ErrorLog("解析失败:%v", err)
  468. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  469. return
  470. }
  471. if res.Transreturncode == "00000000" {
  472. his := models.VMHisPatient{
  473. Name: name,
  474. Gender: gender,
  475. Birthday: birthUnix,
  476. MedicalTreatmentType: medical_care,
  477. IdType: certificates,
  478. IdCardNo: id_card,
  479. BalanceAccountsType: settlementValue,
  480. SocialType: social_type,
  481. MedicalInsuranceNumber: medical_insurance_card,
  482. RegisterType: register_type,
  483. RegisterCost: registration_fee,
  484. TreatmentCost: medical_expenses,
  485. Status: 1,
  486. Ctime: time.Now().Unix(),
  487. Mtime: time.Now().Unix(),
  488. Iinfo: resp_result,
  489. PatientId: patient.ID,
  490. RecordDate: theTime.Unix(),
  491. UserOrgId: adminInfo.CurrentOrgId,
  492. AdminUserId: admin_user_id,
  493. IsReturn: 1,
  494. IdCardType: id_card_type,
  495. Doctor: doctor,
  496. Departments: department,
  497. YiliaoNumber: yiliao_number,
  498. MzNumber: number,
  499. Number: mz_number,
  500. }
  501. service.CreateHisPatientTwo(&his)
  502. c.ServeSuccessJSON(map[string]interface{}{
  503. "msg": "挂号成功",
  504. })
  505. } else {
  506. c.ServeSuccessJSON(map[string]interface{}{
  507. "failed_code": -10,
  508. "msg": res.Transreturnmessage,
  509. })
  510. return
  511. }
  512. //}
  513. }
  514. } else { //异地卡流程
  515. //readCardBasResult := ReadCardBasHSM(number)
  516. //fmt.Println(readCardBasResult)
  517. //是否异地就医,是的话走鉴权流程,不是的话走门诊挂号
  518. if is_yidi == 1 { //1本地就医
  519. 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)
  520. var dat map[string]interface{}
  521. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  522. fmt.Println(dat)
  523. } else {
  524. fmt.Println(err)
  525. }
  526. userJSONBytes, _ := json.Marshal(dat)
  527. var res ResultOne
  528. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  529. utils.ErrorLog("解析失败:%v", err)
  530. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  531. return
  532. }
  533. if res.Transreturncode == "00000000" {
  534. his := models.VMHisPatient{
  535. Name: name,
  536. Gender: gender,
  537. Birthday: birthUnix,
  538. MedicalTreatmentType: medical_care,
  539. IdType: certificates,
  540. IdCardNo: id_card,
  541. BalanceAccountsType: settlementValue,
  542. SocialType: social_type,
  543. MedicalInsuranceNumber: medical_insurance_card,
  544. RegisterType: register_type,
  545. RegisterCost: registration_fee,
  546. TreatmentCost: medical_expenses,
  547. Status: 1,
  548. Ctime: time.Now().Unix(),
  549. Mtime: time.Now().Unix(),
  550. Iinfo: resp_result,
  551. PatientId: patient.ID,
  552. RecordDate: theTime.Unix(),
  553. UserOrgId: adminInfo.CurrentOrgId,
  554. AdminUserId: admin_user_id,
  555. IsReturn: 1,
  556. IdCardType: id_card_type,
  557. Doctor: doctor,
  558. Departments: department,
  559. YiliaoNumber: yiliao_number,
  560. MzNumber: number,
  561. Number: mz_number,
  562. }
  563. service.CreateHisPatientTwo(&his)
  564. c.ServeSuccessJSON(map[string]interface{}{
  565. "msg": "挂号成功",
  566. })
  567. } else {
  568. c.ServeSuccessJSON(map[string]interface{}{
  569. "failed_code": -10,
  570. "msg": res.Transreturnmessage,
  571. })
  572. return
  573. }
  574. } else { //异地就医需要走鉴权流程
  575. //authResult := CardAuth(number)
  576. //fmt.Println(authResult)
  577. 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)
  578. var dat map[string]interface{}
  579. if err := json.Unmarshal([]byte(resp_result), &dat); err == nil {
  580. fmt.Println(dat)
  581. } else {
  582. fmt.Println(err)
  583. }
  584. userJSONBytes, _ := json.Marshal(dat)
  585. var res ResultOne
  586. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  587. utils.ErrorLog("解析失败:%v", err)
  588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  589. return
  590. }
  591. if res.Transreturncode == "00000000" {
  592. his := models.VMHisPatient{
  593. Name: name,
  594. Gender: gender,
  595. Birthday: birthUnix,
  596. MedicalTreatmentType: medical_care,
  597. IdType: certificates,
  598. IdCardNo: id_card,
  599. BalanceAccountsType: settlementValue,
  600. SocialType: social_type,
  601. MedicalInsuranceNumber: medical_insurance_card,
  602. RegisterType: register_type,
  603. RegisterCost: registration_fee,
  604. TreatmentCost: medical_expenses,
  605. Status: 1,
  606. Ctime: time.Now().Unix(),
  607. Mtime: time.Now().Unix(),
  608. Iinfo: resp_result,
  609. PatientId: patient.ID,
  610. RecordDate: theTime.Unix(),
  611. UserOrgId: adminInfo.CurrentOrgId,
  612. AdminUserId: admin_user_id,
  613. IsReturn: 1,
  614. IdCardType: id_card_type,
  615. Doctor: doctor,
  616. Departments: department,
  617. YiliaoNumber: yiliao_number,
  618. MzNumber: number,
  619. Number: mz_number,
  620. }
  621. service.CreateHisPatientTwo(&his)
  622. c.ServeSuccessJSON(map[string]interface{}{
  623. "msg": "挂号成功",
  624. })
  625. } else {
  626. c.ServeSuccessJSON(map[string]interface{}{
  627. "failed_code": -10,
  628. "msg": res.Transreturnmessage,
  629. })
  630. return
  631. }
  632. }
  633. }
  634. } else {
  635. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeRegisterRepeatException)
  636. return
  637. }
  638. }
  639. //上传明细----预结算----确认订单
  640. func (c *SZHisApiController) GetUploadInfo() {
  641. patient_id, _ := c.GetInt64("patient_id")
  642. record_time := c.GetString("record_time")
  643. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  644. admin_user_id, _ := c.GetInt64("admin_user_id")
  645. timestamp := time.Now().Unix()
  646. tempTime := time.Unix(timestamp, 0)
  647. timeFormat := tempTime.Format("20060102150405")
  648. chrgBchno := rand.Intn(10000) + 1000
  649. chrg_bchno := timeFormat + strconv.FormatInt(int64(chrgBchno), 10) + strconv.FormatInt(1, 10)
  650. adminUser := c.GetAdminUserInfo()
  651. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  652. month := time.Unix(1557042972, 0).Format("1")
  653. year := time.Now().Format("2006")
  654. month = time.Now().Format("01")
  655. day := time.Now().Format("02")
  656. timeLayout := "2006-01-02"
  657. loc, _ := time.LoadLocation("Local")
  658. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  659. fmt.Println(err)
  660. if err != nil {
  661. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  662. return
  663. }
  664. recordDateTime := theTime.Unix()
  665. var prescriptions []*models.HisPrescription
  666. var start_time int64
  667. var end_time int64
  668. if settle_accounts_type == 1 { //日结
  669. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  670. } else { //月结
  671. start_time_str := c.GetString("start_time")
  672. end_time_str := c.GetString("end_time")
  673. timeLayout := "2006-01-02"
  674. loc, _ := time.LoadLocation("Local")
  675. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  676. if err != nil {
  677. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  678. return
  679. }
  680. recordStartTime := theStartTime.Unix()
  681. start_time = recordStartTime
  682. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  683. if err != nil {
  684. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  685. return
  686. }
  687. recordEndTime := theEndTime.Unix()
  688. end_time = recordEndTime
  689. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  690. }
  691. var ids []int64
  692. for _, item := range prescriptions {
  693. ids = append(ids, item.ID)
  694. }
  695. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  696. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  697. adminRole, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  698. his, err := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  699. //number := his.MzNumber
  700. mz_number := his.Number
  701. number := miConfig.Code + year + month + day +
  702. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  703. //number := miConfig.Code + year + month + day + "1590003"
  704. var doctor_name string
  705. var doctor_code string
  706. var drug_doctor_code string
  707. drug_doctor_code = adminRole_two.DoctorCode
  708. drug_doctor_name := adminRole_two.UserName
  709. if adminRole.ID == 0 {
  710. doctor_name = "黄亦轩"
  711. doctor_code = "1"
  712. } else {
  713. doctor_name = adminRole.UserName
  714. doctor_code = strconv.FormatInt(admin_user_id, 10)
  715. }
  716. verifyCode, version_code := ReadCardGetCode("FY001" + "|" + number + "|" + miConfig.Code)
  717. //verifyCode := "000000|bf885fa312a7f92861d6b61542a637fa"
  718. //version_code := "V0.3"
  719. var customs []*models.CustomDetail
  720. for _, item := range prescriptions {
  721. fmt.Println("111111")
  722. if item.Type == 1 { //药品
  723. fmt.Println("222222")
  724. for _, subItem := range item.HisDoctorAdviceInfo {
  725. fmt.Println(subItem.BaseDrugLib.MedicalInsuranceNumber)
  726. if len(subItem.BaseDrugLib.MedicalInsuranceNumber) > 0 {
  727. fmt.Println("3333333")
  728. _, dose_code := service.GetDoseCode(subItem.BaseDrugLib.DrugDosageForm, adminUser.CurrentOrgId)
  729. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*subItem.PrescribingNumber), 64)
  730. price, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price), 64)
  731. cus := &models.CustomDetail{
  732. PrescriptionNumber: chrg_bchno,
  733. OrderType: "1",
  734. ChargeSerialNumber: subItem.FeedetlSn,
  735. Code: subItem.BaseDrugLib.MedicalInsuranceNumber,
  736. CodeName: subItem.BaseDrugLib.DrugName,
  737. Flag: "1",
  738. Price: price,
  739. Count: subItem.PrescribingNumber,
  740. ChargeOrderDate: year + month + day,
  741. DoctorCode: doctor_code,
  742. Total: detItemFeeSumamt,
  743. DoseCode: dose_code,
  744. Spec: subItem.BaseDrugLib.DrugSpec,
  745. }
  746. customs = append(customs, cus)
  747. }
  748. }
  749. }
  750. if item.Type == 2 { //项目
  751. for _, subItem := range item.HisPrescriptionProject {
  752. if len(subItem.HisProject.MedicalCode) > 0 {
  753. detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  754. count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  755. cus := &models.CustomDetail{
  756. PrescriptionNumber: chrg_bchno,
  757. OrderType: "1",
  758. ChargeSerialNumber: subItem.FeedetlSn,
  759. Code: subItem.HisProject.MedicalCode,
  760. CodeName: subItem.HisProject.ProjectName,
  761. Flag: "1",
  762. Price: subItem.Price,
  763. Count: count,
  764. ChargeOrderDate: year + month + day,
  765. DoctorCode: doctor_code,
  766. Total: detItemFeeSumamt,
  767. DoseCode: "",
  768. Spec: "",
  769. }
  770. customs = append(customs, cus)
  771. }
  772. }
  773. }
  774. //
  775. //for _, subItem := range item.HisAdditionalCharge {
  776. // if len(subItem.XtHisAddtionConfig.Code) > 0 {
  777. // detItemFeeSumamt, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", subItem.Price*float64(subItem.Count)), 64)
  778. //
  779. // count, _ := strconv.ParseFloat(fmt.Sprintf("%f", subItem.Count), 64)
  780. // cus := &models.CustomDetail{
  781. // PrescriptionNumber: chrg_bchno,
  782. // OrderType: "1",
  783. // ChargeSerialNumber: subItem.FeedetlSn,
  784. // Code: subItem.XtHisAddtionConfig.Code,
  785. // CodeName: subItem.XtHisAddtionConfig.Name,
  786. // Flag: "1",
  787. // Price: subItem.Price,
  788. // Count: count,
  789. // ChargeOrderDate: year + month + day,
  790. // DoctorCode: doctor_code,
  791. // Total: detItemFeeSumamt,
  792. // DoseCode: "",
  793. // Spec: subItem.XtHisAddtionConfig.,
  794. // }
  795. // customs = append(customs, cus)
  796. // }
  797. //}
  798. }
  799. var pagesize int = 50
  800. var start int = 1
  801. var stop int
  802. var pagecount int
  803. var curpage int
  804. var isSuccess bool = true
  805. //总页数,向上取整,注意除之前要先转换类型为float64
  806. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  807. var ress []*Result
  808. for curpage = 1; curpage <= pagecount; curpage++ {
  809. if curpage == 1 {
  810. start = 1
  811. } else {
  812. start = (curpage-1)*pagesize + 1
  813. }
  814. stop = curpage * pagesize
  815. if stop > len(customs) {
  816. stop = len(customs)
  817. }
  818. result := service.SzybFY001(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, number, mz_number, version_code, drug_doctor_code)
  819. fmt.Println(result)
  820. var dat map[string]interface{}
  821. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  822. fmt.Println(dat)
  823. } else {
  824. fmt.Println(err)
  825. }
  826. userJSONBytes, _ := json.Marshal(dat)
  827. var res Result
  828. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  829. utils.ErrorLog("解析失败:%v", err)
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  831. return
  832. }
  833. if res.Transreturncode == "00000000" {
  834. ress = append(ress, &res)
  835. } else {
  836. isSuccess = false
  837. //预结算报错
  838. errlog := &models.HisOrderError{
  839. UserOrgId: adminUser.CurrentOrgId,
  840. Ctime: time.Now().Unix(),
  841. Mtime: time.Now().Unix(),
  842. Number: chrg_bchno,
  843. ErrMsg: res.Transreturnmessage,
  844. Status: 1,
  845. PatientId: patient_id,
  846. RecordTime: recordDateTime,
  847. Stage: 10,
  848. }
  849. service.CreateErrMsgLog(errlog)
  850. c.ServeSuccessJSON(map[string]interface{}{
  851. "failed_code": -10,
  852. "msg": res.Transreturnmessage,
  853. })
  854. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  855. return
  856. }
  857. //设置变量,根据变量的值来判断上传是否成功
  858. }
  859. if isSuccess == true {
  860. order := &models.HisOrder{
  861. UserOrgId: adminUser.CurrentOrgId,
  862. HisPatientId: 0,
  863. PatientId: patient_id,
  864. SettleAccountsDate: recordDateTime,
  865. Ctime: time.Now().Unix(),
  866. Mtime: time.Now().Unix(),
  867. Status: 1,
  868. Number: chrg_bchno,
  869. Infcode: 0,
  870. WarnMsg: "",
  871. Cainfo: "",
  872. ErrMsg: "",
  873. RespondTime: "",
  874. InfRefmsgid: "",
  875. OrderStatus: 1,
  876. IsMedicineInsurance: 1,
  877. SettleType: settle_accounts_type,
  878. SettleStartTime: start_time,
  879. SettleEndTime: end_time,
  880. Creator: admin_user_id,
  881. Modify: admin_user_id,
  882. OrgSetlNumber: number,
  883. }
  884. data, _ := json.Marshal(ress)
  885. order.DetailLog = string(data)
  886. err = service.CreateOrder(order)
  887. if err != nil {
  888. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreatePreOrderException)
  889. return
  890. }
  891. for _, subItem := range ress {
  892. for _, item := range subItem.Transbody.Outputlist {
  893. temp := strings.Split(item.Bkf500, "-")
  894. var advice_id int64 = 0
  895. var project_id int64 = 0
  896. var types int64 = 0
  897. id, _ := strconv.ParseInt(temp[2], 10, 64)
  898. types, _ = strconv.ParseInt(temp[1], 10, 64)
  899. if temp[1] == "1" {
  900. advice_id = id
  901. project_id = 0
  902. } else if temp[1] == "2" {
  903. advice_id = 0
  904. project_id = id
  905. }
  906. info := &models.HisOrderInfo{
  907. OrderNumber: order.Number,
  908. FeedetlSn: item.Aae072,
  909. UploadDate: time.Now().Unix(),
  910. AdviceId: advice_id,
  911. DetItemFeeSumamt: item.Akc264,
  912. Cnt: item.Akc226,
  913. Pric: float64(item.Akc225),
  914. PatientId: patient_id,
  915. Status: 1,
  916. ChrgitmLv: item.Aka065,
  917. Mtime: time.Now().Unix(),
  918. Ctime: time.Now().Unix(),
  919. UserOrgId: adminUser.CurrentOrgId,
  920. OrderId: order.ID,
  921. ProjectId: project_id,
  922. Type: types,
  923. OverPricPsnPay: item.Akc268,
  924. AllowReimburse: item.Cka319,
  925. }
  926. service.CreateOrderInfo(info)
  927. }
  928. }
  929. service.UpDatePrescriptionNumber(adminUser.CurrentOrgId, ids, chrg_bchno)
  930. service.UpDatePrescriptionInfoNumber(adminUser.CurrentOrgId, patient_id, chrg_bchno, recordDateTime)
  931. var total float64
  932. for _, item := range prescriptions {
  933. if item.Type == 1 { //药品
  934. for _, subItem := range item.HisDoctorAdviceInfo {
  935. total = total + (subItem.Price * subItem.PrescribingNumber)
  936. }
  937. }
  938. if item.Type == 2 { //项目
  939. for _, subItem := range item.HisPrescriptionProject {
  940. total = total + (subItem.Price * float64(subItem.Count))
  941. }
  942. }
  943. }
  944. for _, item := range prescriptions {
  945. for _, subItem := range item.HisAdditionalCharge {
  946. total = total + (subItem.Price * float64(subItem.Count))
  947. }
  948. }
  949. verifyCode, version_code := ReadCardGetCode("FY004" + "|" + number + "|" + miConfig.Code)
  950. //verifyCode := "000000|08728e77da60a4857803af17aba9caae"
  951. //version_code := "V0.3"
  952. result_two := service.SzybFY004(doctor_name, doctor_code, miConfig.Code, total, verifyCode, number, mz_number, version_code, drug_doctor_code, drug_doctor_name)
  953. var dat map[string]interface{}
  954. if err := json.Unmarshal([]byte(result_two), &dat); err == nil {
  955. fmt.Println(dat)
  956. } else {
  957. fmt.Println(err)
  958. }
  959. userJSONBytes, _ := json.Marshal(dat)
  960. var res ResultTwo
  961. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  962. utils.ErrorLog("解析失败:%v", err)
  963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  964. return
  965. }
  966. if res.Transreturncode == "00000000" {
  967. c.ServeSuccessJSON(map[string]interface{}{
  968. "msg": "预结算成功",
  969. })
  970. } else {
  971. c.ServeSuccessJSON(map[string]interface{}{
  972. "failed_code": -10,
  973. "msg": res.Transreturnmessage,
  974. })
  975. //c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  976. return
  977. }
  978. } else {
  979. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  980. return
  981. }
  982. }
  983. //结算
  984. func (c *SZHisApiController) GetSettleInfo() {
  985. patient_id, _ := c.GetInt64("id")
  986. order_id, _ := c.GetInt64("order_id")
  987. record_time := c.GetString("record_time")
  988. pay_way, _ := c.GetInt64("pay_way")
  989. pay_price, _ := c.GetFloat("pay_price")
  990. pay_card_no := c.GetString("pay_card_no")
  991. discount_price, _ := c.GetFloat("discount_price")
  992. preferential_price, _ := c.GetFloat("preferential_price")
  993. reality_price, _ := c.GetFloat("reality_price")
  994. found_price, _ := c.GetFloat("found_price")
  995. medical_insurance_price, _ := c.GetFloat("medical_insurance_price")
  996. private_price, _ := c.GetFloat("private_price")
  997. settle_accounts_type, _ := c.GetInt64("settle_accounts_type")
  998. admin_user_id, _ := c.GetInt64("admin_user_id")
  999. timeLayout := "2006-01-02"
  1000. loc, _ := time.LoadLocation("Local")
  1001. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1002. if err != nil {
  1003. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1004. return
  1005. }
  1006. recordDateTime := theTime.Unix()
  1007. adminUser := c.GetAdminUserInfo()
  1008. var prescriptions []*models.HisPrescription
  1009. data := make(map[string]interface{})
  1010. if settle_accounts_type == 1 { //日结
  1011. prescriptions, _ = service.GetHisPrescription(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1012. data["pre"] = prescriptions
  1013. } else { //月结
  1014. start_time_str := c.GetString("start_time")
  1015. end_time_str := c.GetString("end_time")
  1016. timeLayout := "2006-01-02"
  1017. loc, _ := time.LoadLocation("Local")
  1018. theStartTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time_str+" 00:00:00", loc)
  1019. if err != nil {
  1020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1021. return
  1022. }
  1023. recordStartTime := theStartTime.Unix()
  1024. theEndTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time_str+" 00:00:00", loc)
  1025. if err != nil {
  1026. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1027. return
  1028. }
  1029. recordEndTime := theEndTime.Unix()
  1030. prescriptions, _ = service.GetMonthHisPrescription(adminUser.CurrentOrgId, patient_id, recordStartTime, recordEndTime)
  1031. data["pre"] = prescriptions
  1032. }
  1033. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1034. his, _ := service.GetVMHisPatientInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1035. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1036. strconv.FormatInt(his.PatientId, 10)
  1037. order_src, _ := service.GetHisOrderByID(order_id)
  1038. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1039. if config.IsOpen == 1 { //对接了医保,走医保流程
  1040. if order_src.OrderStatus != 2 {
  1041. var total float64
  1042. for _, item := range prescriptions {
  1043. if item.Type == 1 { //药品
  1044. for _, subItem := range item.HisDoctorAdviceInfo {
  1045. total = total + (subItem.Price * subItem.PrescribingNumber)
  1046. }
  1047. }
  1048. if item.Type == 2 { //项目
  1049. for _, subItem := range item.HisPrescriptionProject {
  1050. total = total + (subItem.Price * float64(subItem.Count))
  1051. }
  1052. }
  1053. }
  1054. for _, item := range prescriptions {
  1055. for _, subItem := range item.HisAdditionalCharge {
  1056. total = total + (subItem.Price * float64(subItem.Count))
  1057. }
  1058. }
  1059. patientPrescription, _ := service.FindPatientPrescriptionInfo(adminUser.CurrentOrgId, patient_id, recordDateTime)
  1060. adminRole_two, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, patientPrescription.DoctorId)
  1061. var drug_doctor string
  1062. drug_doctor = adminRole_two.DoctorCode
  1063. drug_doctor_name := adminRole_two.UserName
  1064. //结算流程
  1065. var doctor_name string
  1066. var doctor_code string
  1067. if roles.ID == 0 {
  1068. doctor_name = "黄亦轩"
  1069. doctor_code = "1010"
  1070. } else {
  1071. doctor_name = roles.UserName
  1072. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1073. }
  1074. number := order_src.OrgSetlNumber
  1075. mz_number := his.Number
  1076. verifyCode, version_code := ReadCardGetCode("FY005" + "|" + number + "|" + miConfig.Code)
  1077. //verifyCode := "000000|707c35a62c2f0609d7b0a811649f3913"
  1078. //version_code := "V0.3"
  1079. //yiliao_number, id_card_number,verifyCode,versionCode, err, ret4 := ReadBasCardGetNumber("FY005" + "|" + number + "|" + miConfig.Code)
  1080. yiliao_number := his.YiliaoNumber
  1081. result_three := service.SzybFY005(doctor_name, doctor_code, miConfig.Code, total, yiliao_number, verifyCode, number, mz_number, version_code, drug_doctor, drug_doctor_name)
  1082. var dat map[string]interface{}
  1083. if err := json.Unmarshal([]byte(result_three), &dat); err == nil {
  1084. fmt.Println(dat)
  1085. } else {
  1086. fmt.Println(err)
  1087. }
  1088. userJSONBytes, _ := json.Marshal(dat)
  1089. var res ResultTwo
  1090. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1091. utils.ErrorLog("解析失败:%v", err)
  1092. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1093. return
  1094. }
  1095. if res.Transreturncode == "00000000" {
  1096. order_src.OrderStatus = 2
  1097. order_src.PayWay = pay_way
  1098. order_src.PayPrice = pay_price
  1099. order_src.PayCardNo = pay_card_no
  1100. order_src.DiscountPrice = discount_price
  1101. order_src.PreferentialPrice = preferential_price
  1102. order_src.RealityPrice = reality_price
  1103. order_src.FoundPrice = found_price
  1104. order_src.MedicalInsurancePrice = medical_insurance_price
  1105. order_src.PrivatePrice = private_price
  1106. order_src.Creator = order_src.Creator
  1107. order_src.Modify = roles.ID
  1108. order_src.MedfeeSumamt = res.Transbody.Akc264
  1109. order_src.SetlId = res.Transbody.Ckc618
  1110. order_src.FundPaySumamt = res.Transbody.Akb068
  1111. order_src.AcctPay = res.Transbody.Akb066
  1112. order_src.PsnCashPay = res.Transbody.Akb067
  1113. order_src.PsnPartAmt = res.Transbody.Akb067
  1114. order_src.AccountPrice = res.Transbody.Aae240
  1115. order_src.MzNumber = mz_number
  1116. order_src.YiliaoNumber = yiliao_number
  1117. setlDetailOne, _ := json.Marshal(res.Transbody.Outputlist1)
  1118. detailStrOne := string(setlDetailOne)
  1119. order_src.SzChargeInfo = detailStrOne
  1120. setlDetailTwo, _ := json.Marshal(res.Transbody.Outputlist2)
  1121. detailStrTwo := string(setlDetailTwo)
  1122. order_src.SzProjectInfo = detailStrTwo
  1123. setlDetailThree, _ := json.Marshal(res.Transbody.Outputlist3)
  1124. detailStrThree := string(setlDetailThree)
  1125. order_src.SzMedicineInsuranceInfo = detailStrThree
  1126. order_src.Cainfo = result_three
  1127. err = service.UpdataOrderStatusTwo(order_src.Number, adminUser.CurrentOrgId)
  1128. err = service.UpDateOrder(order_src)
  1129. c.ServeSuccessJSON(map[string]interface{}{
  1130. "msg": "结算成功",
  1131. })
  1132. } else {
  1133. //version_code := "0.03"
  1134. c.ServeSuccessJSON(map[string]interface{}{
  1135. "failed_code": -10,
  1136. "msg": res.Transreturnmessage,
  1137. })
  1138. }
  1139. } else {
  1140. //错误提示
  1141. }
  1142. } else {
  1143. //错误提示
  1144. }
  1145. }
  1146. //当月退费
  1147. func (c *SZHisApiController) Refund() {
  1148. order_id, _ := c.GetInt64("order_id")
  1149. record_time := c.GetString("record_time")
  1150. patient_id, _ := c.GetInt64("patient_id")
  1151. admin_user_id, _ := c.GetInt64("admin_user_id")
  1152. timeLayout := "2006-01-02"
  1153. loc, _ := time.LoadLocation("Local")
  1154. adminUser := c.GetAdminUserInfo()
  1155. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1156. fmt.Println(err)
  1157. if err != nil {
  1158. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1159. return
  1160. }
  1161. recordDateTime := theTime.Unix()
  1162. fmt.Println(recordDateTime)
  1163. var order models.HisOrder
  1164. order, _ = service.GetHisOrderByID(order_id)
  1165. if order.ID == 0 {
  1166. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeHisOrderNoExistParamWrong)
  1167. return
  1168. }
  1169. his, _ := service.GetHisPatientInfo(adminUser.CurrentOrgId, patient_id, theTime.Unix())
  1170. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1171. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1172. //结算流程
  1173. var doctor_name string
  1174. var doctor_code string
  1175. if roles.ID == 0 {
  1176. doctor_name = "黄亦轩"
  1177. doctor_code = "1001"
  1178. } else {
  1179. doctor_name = roles.UserName
  1180. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1181. }
  1182. month := time.Unix(1557042972, 0).Format("1")
  1183. year := time.Now().Format("2006")
  1184. month = time.Now().Format("01")
  1185. day := time.Now().Format("02")
  1186. //number := miConfig.Code + year + month + day + "1367866"
  1187. number := miConfig.Code + year + month + day +
  1188. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  1189. //number := miConfig.Code + year + month + day + "1590003"
  1190. //流水号
  1191. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1192. verifyCode, version_code := ReadCardGetCode("JY002" + "|" + number + "|" + miConfig.Code)
  1193. //version_code := "V0.3"
  1194. //
  1195. //verifyCode := "000000|9972fca7ba9471c7dbe08324b2e31f70"
  1196. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1197. if config.IsOpen == 1 { //对接了医保,走医保流程
  1198. result := service.SzybJY002(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, number, version_code)
  1199. fmt.Println(result)
  1200. var dat map[string]interface{}
  1201. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1202. fmt.Println(dat)
  1203. } else {
  1204. fmt.Println(err)
  1205. }
  1206. userJSONBytes, _ := json.Marshal(dat)
  1207. var res ResultThree
  1208. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1209. utils.ErrorLog("解析失败:%v", err)
  1210. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1211. return
  1212. }
  1213. if res.Transreturncode == "00000000" {
  1214. service.UpdataOrderlog(order_id, adminUser.CurrentOrgId, result)
  1215. service.UpdataOrderStatusSZ(order_id, order.Number, adminUser.CurrentOrgId, his.MzNumber, his.Number)
  1216. c.ServeSuccessJSON(map[string]interface{}{
  1217. "msg": "退费成功",
  1218. })
  1219. } else {
  1220. c.ServeSuccessJSON(map[string]interface{}{
  1221. "failed_code": -10,
  1222. "msg": res.Transreturnmessage,
  1223. })
  1224. }
  1225. }
  1226. }
  1227. //跨月退费
  1228. func (c *SZHisApiController) MonthRefund() {
  1229. order_id, _ := c.GetInt64("order_id")
  1230. record_time := c.GetString("record_time")
  1231. patient_id, _ := c.GetInt64("patient_id")
  1232. admin_user_id, _ := c.GetInt64("admin_user_id")
  1233. timeLayout := "2006-01-02"
  1234. loc, _ := time.LoadLocation("Local")
  1235. adminUser := c.GetAdminUserInfo()
  1236. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1237. fmt.Println(err)
  1238. if err != nil {
  1239. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1240. return
  1241. }
  1242. recordDateTime := theTime.Unix()
  1243. var order models.HisOrder
  1244. order, _ = service.GetHisOrderByID(order_id)
  1245. if order.ID == 0 {
  1246. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1247. }
  1248. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1249. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1250. //结算流程
  1251. var doctor_name string
  1252. var doctor_code string
  1253. if roles.ID == 0 {
  1254. doctor_name = "黄亦轩"
  1255. doctor_code = "1001"
  1256. } else {
  1257. doctor_name = roles.UserName
  1258. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1259. }
  1260. month := time.Unix(1557042972, 0).Format("1")
  1261. year := time.Now().Format("2006")
  1262. month = time.Now().Format("01")
  1263. day := time.Now().Format("02")
  1264. //流水号
  1265. number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1266. //verifyCode,version_code := ReadCardGetCode("JY002" + "|" + number_two + "|" + miConfig.Code)
  1267. version_code := "0.03"
  1268. fmt.Println(number_two)
  1269. verifyCode := "000000|0872038667cc34efdc35ce4668589a5f"
  1270. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1271. if config.IsOpen == 1 { //对接了医保,走医保流程
  1272. result := service.SzybJY003(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1273. fmt.Println(result)
  1274. var dat map[string]interface{}
  1275. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1276. fmt.Println(dat)
  1277. } else {
  1278. fmt.Println(err)
  1279. }
  1280. userJSONBytes, _ := json.Marshal(dat)
  1281. var res ResultThree
  1282. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1283. utils.ErrorLog("解析失败:%v", err)
  1284. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1285. return
  1286. }
  1287. if res.Transreturncode == "00000000" {
  1288. c.ServeSuccessJSON(map[string]interface{}{
  1289. "msg": "退费成功",
  1290. })
  1291. } else {
  1292. }
  1293. }
  1294. }
  1295. //查询
  1296. func (c *SZHisApiController) GetSettleAccounts() {
  1297. order_id, _ := c.GetInt64("order_id")
  1298. record_time := c.GetString("record_time")
  1299. patient_id, _ := c.GetInt64("patient_id")
  1300. admin_user_id, _ := c.GetInt64("admin_user_id")
  1301. timeLayout := "2006-01-02"
  1302. loc, _ := time.LoadLocation("Local")
  1303. adminUser := c.GetAdminUserInfo()
  1304. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1305. fmt.Println(err)
  1306. if err != nil {
  1307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1308. return
  1309. }
  1310. recordDateTime := theTime.Unix()
  1311. var order models.HisOrder
  1312. order, _ = service.GetHisOrderByID(order_id)
  1313. if order.ID == 0 {
  1314. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1315. }
  1316. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1317. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1318. //结算流程
  1319. var doctor_name string
  1320. var doctor_code string
  1321. if roles.ID == 0 {
  1322. doctor_name = "黄亦轩"
  1323. doctor_code = "1001"
  1324. } else {
  1325. doctor_name = roles.UserName
  1326. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1327. }
  1328. //month := time.Unix(1557042972, 0).Format("1")
  1329. //year := time.Now().Format("2006")
  1330. //month = time.Now().Format("01")
  1331. //day := time.Now().Format("02")
  1332. //流水号
  1333. //number_two := miConfig.Code + "-" + year + month + day + "-" + strconv.FormatInt(patient_id, 10)
  1334. //fmt.Println(number_two)
  1335. verifyCode, version_code := ReadCardGetCode("JY001" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1336. //version_code := "V0.3"
  1337. //verifyCode := "000000|2c9854287e7c3cbc34439ab8e5157816"
  1338. config, _ := service.GetMedicalInsuranceConfig(adminUser.CurrentOrgId)
  1339. if config.IsOpen == 1 { //对接了医保,走医保流程
  1340. result := service.SzybJY001(doctor_name, doctor_code, miConfig.Code, order.OrgSetlNumber, order.MzNumber, verifyCode, version_code)
  1341. fmt.Println(result)
  1342. var dat map[string]interface{}
  1343. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1344. fmt.Println(dat)
  1345. } else {
  1346. fmt.Println(err)
  1347. }
  1348. userJSONBytes, _ := json.Marshal(dat)
  1349. var res ResultFour
  1350. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1351. utils.ErrorLog("解析失败:%v", err)
  1352. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1353. return
  1354. }
  1355. if res.Transreturncode == "00000000" {
  1356. c.ServeSuccessJSON(map[string]interface{}{})
  1357. } else {
  1358. c.ServeSuccessJSON(map[string]interface{}{
  1359. "failed_code": -10,
  1360. "msg": res.Transreturnmessage,
  1361. })
  1362. }
  1363. }
  1364. }
  1365. //费用录入取消
  1366. func (c *SZHisApiController) CancelOrderDetail() {
  1367. order_id, _ := c.GetInt64("order_id")
  1368. record_time := c.GetString("record_time")
  1369. patient_id, _ := c.GetInt64("patient_id")
  1370. admin_user_id, _ := c.GetInt64("admin_user_id")
  1371. timeLayout := "2006-01-02"
  1372. loc, _ := time.LoadLocation("Local")
  1373. adminUser := c.GetAdminUserInfo()
  1374. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", record_time+" 00:00:00", loc)
  1375. fmt.Println(err)
  1376. if err != nil {
  1377. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1378. return
  1379. }
  1380. recordDateTime := theTime.Unix()
  1381. var order models.HisOrder
  1382. order, _ = service.GetHisOrderByID(order_id)
  1383. if order.ID == 0 {
  1384. order, _ = service.GetHisOrderThree(recordDateTime, patient_id, adminUser.CurrentOrgId)
  1385. }
  1386. order_infos, _ := service.GetHisOrderInfoByNumber(order.Number)
  1387. roles, _ := service.GetAdminUserInfoByID(adminUser.CurrentOrgId, admin_user_id)
  1388. miConfig, _ := service.FindMedicalInsuranceInfo(adminUser.CurrentOrgId)
  1389. //结算流程
  1390. var doctor_name string
  1391. var doctor_code string
  1392. if roles.ID == 0 {
  1393. doctor_name = "黄亦轩"
  1394. doctor_code = "1001"
  1395. } else {
  1396. doctor_name = roles.UserName
  1397. doctor_code = strconv.FormatInt(admin_user_id, 10)
  1398. }
  1399. var customs []*models.CustomDetail
  1400. for _, item := range order_infos {
  1401. cus := &models.CustomDetail{
  1402. PrescriptionNumber: item.OrderNumber,
  1403. ChargeSerialNumber: item.FeedetlSn,
  1404. }
  1405. customs = append(customs, cus)
  1406. }
  1407. verifyCode, version_code := ReadCardGetCode("FY002" + "|" + order.OrgSetlNumber + "|" + miConfig.Code)
  1408. var pagesize int = 50
  1409. var start int = 1
  1410. var stop int
  1411. var pagecount int
  1412. var curpage int
  1413. var isSuccess bool = true
  1414. var ress []*ResultFive
  1415. //总页数,向上取整,注意除之前要先转换类型为float64
  1416. pagecount = int(math.Ceil(float64(len(customs)) / float64(pagesize)))
  1417. for curpage = 1; curpage <= pagecount; curpage++ {
  1418. if curpage == 1 {
  1419. start = 1
  1420. } else {
  1421. start = (curpage-1)*pagesize + 1
  1422. }
  1423. stop = curpage * pagesize
  1424. if stop > len(customs) {
  1425. stop = len(customs)
  1426. }
  1427. result := service.SzybFY002(doctor_name, doctor_code, miConfig.Code, customs[start-1:stop], verifyCode, order.OrgSetlNumber, order.MzNumber, version_code)
  1428. fmt.Println(result)
  1429. var dat map[string]interface{}
  1430. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1431. fmt.Println(dat)
  1432. } else {
  1433. fmt.Println(err)
  1434. }
  1435. userJSONBytes, _ := json.Marshal(dat)
  1436. var res ResultFive
  1437. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1438. utils.ErrorLog("解析失败:%v", err)
  1439. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1440. return
  1441. }
  1442. if res.Transreturncode == "00000000" {
  1443. ress = append(ress, &res)
  1444. } else {
  1445. isSuccess = false
  1446. //预结算报错
  1447. errlog := &models.HisOrderError{
  1448. UserOrgId: adminUser.CurrentOrgId,
  1449. Ctime: time.Now().Unix(),
  1450. Mtime: time.Now().Unix(),
  1451. ErrMsg: res.Transreturnmessage,
  1452. Status: 1,
  1453. PatientId: patient_id,
  1454. RecordTime: recordDateTime,
  1455. Stage: 11,
  1456. }
  1457. service.CreateErrMsgLog(errlog)
  1458. c.ServeSuccessJSON(map[string]interface{}{
  1459. "faild_code": -10,
  1460. "msg": res.Transreturnmessage,
  1461. })
  1462. return
  1463. }
  1464. }
  1465. if isSuccess == true {
  1466. c.ServeSuccessJSON(map[string]interface{}{
  1467. "msg": "撤销成功",
  1468. })
  1469. }
  1470. }
  1471. //获取verifyCode
  1472. func ReadCardGetCode(request string) (string, string) {
  1473. request = request + "|"
  1474. DllDef2 := syscall.MustLoadDLL("SSCardDriver_SZ.dll")
  1475. readCards := DllDef2.MustFindProc("iVerifyCode")
  1476. str := request
  1477. str3 := make([]byte, 256)
  1478. ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1479. fmt.Println(":", string(str3))
  1480. //fmt.Println(":",ConvertByte2String(str3,GB18030) )
  1481. if ret4 == 0 {
  1482. result := string(str3)
  1483. fmt.Println(result)
  1484. result_arr := strings.Split(result, "|")
  1485. verifyCode := result_arr[0] + "|" + result_arr[1]
  1486. versionCode := result_arr[2]
  1487. return verifyCode, versionCode
  1488. }
  1489. return "", ""
  1490. }
  1491. //
  1492. ////读卡
  1493. //func ReadBasCardGetNumber(request string) (string, string, string, string, error, int64) {
  1494. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1495. // readCards := DllDef2.MustFindProc("iReadCardBas")
  1496. // str := request
  1497. //
  1498. // str3 := make([]byte, 256)
  1499. // ret4, _, err := readCards.Call(IntPtr(3), StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1500. // fmt.Println(":", string(str3))
  1501. //
  1502. // if ret4 == 0 {
  1503. // result := string(str3)
  1504. // fmt.Println(result)
  1505. // result_arr := strings.Split(result, "|")
  1506. // //医疗证号
  1507. // yiliao_number := result_arr[12]
  1508. //
  1509. // //根据业务的人员信息跟设备读社保卡获取的信息进行匹配,判断是否为同一个人,相同则进行挂号操作,不同则报错
  1510. // id_card_number := result_arr[1]
  1511. //
  1512. // verifyCode := result_arr[11] + result_arr[13]
  1513. //
  1514. // versionCode := result_arr[14]
  1515. // return yiliao_number, id_card_number, verifyCode, versionCode, err, 1
  1516. //
  1517. // }
  1518. // return "", "", "", "", err, 0
  1519. //}
  1520. //
  1521. ////iReadCardBas_HSM_Step1 ---- 1903 iCardInnerAuthentication --- iReadCardBas_HSM_Step2
  1522. //func ReadCardBasHSM(number string) string {
  1523. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1524. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step1")
  1525. // str := make([]byte, 256)
  1526. // ret, _, _ := readCards.Call(IntPtr(3), (uintptr)(unsafe.Pointer(&str[0])))
  1527. // fmt.Println(":", string(str))
  1528. //
  1529. // result_arr := strings.Split(string(str), "|")
  1530. //
  1531. // if ret == 0 {
  1532. // readCards := DllDef2.MustFindProc("iCardInnerAuthentication")
  1533. // str2 := make([]byte, 256)
  1534. // str3 := "" + "|" + "" + "|" + "440300" + "|" + "" + "|" + "" + "|" + result_arr[1] + "|" + result_arr[2] + "|" + result_arr[3] + "|" + result_arr[4] + "|" + result_arr[5] + "|" + "" + "|" + "" + "|"
  1535. // ret2, _, _ := readCards.Call(StrPtr(str3), (uintptr)(unsafe.Pointer(&str2[0])))
  1536. // fmt.Println(":", string(str2))
  1537. //
  1538. // if ret2 == 0 {
  1539. // result_arr := strings.Split(string(str2), "|")
  1540. //
  1541. // if result_arr[2] == "0" {
  1542. // readCards := DllDef2.MustFindProc("iReadCardBas_HSM_Step2")
  1543. // str4 := result_arr[4] + "|" + result_arr[5]
  1544. // str5 := make([]byte, 256)
  1545. // ret3, _, _ := readCards.Call(StrPtr(str4), StrPtr(number), (uintptr)(unsafe.Pointer(&str5[0])))
  1546. //
  1547. // if ret3 == 0 {
  1548. // return string(str5)
  1549. //
  1550. // } else {
  1551. // return ""
  1552. // }
  1553. // } else {
  1554. // return ""
  1555. // }
  1556. // }
  1557. // return ""
  1558. // }
  1559. // return ""
  1560. //
  1561. //}
  1562. //
  1563. ////1904卡鉴权
  1564. //func CardAuth(request string) string {
  1565. // DllDef2 := syscall.MustLoadDLL("SSSE32.dll")
  1566. // readCards := DllDef2.MustFindProc("iCardAuthentication")
  1567. // str := request
  1568. // str3 := make([]byte, 256)
  1569. // ret4, _, _ := readCards.Call(StrPtr(str), (uintptr)(unsafe.Pointer(&str3[0])))
  1570. // fmt.Println(":", string(str3))
  1571. //
  1572. // if ret4 == 0 {
  1573. // return string(str3)
  1574. // }
  1575. // return ""
  1576. //}
  1577. func (c *SZHisApiController) GetDrugList() {
  1578. //获取药品库数据
  1579. list, _ := service.GetDrugList(10028)
  1580. //获取药品剂型
  1581. drugs, _ := service.GetDrugDosageForm(10028)
  1582. for _, item := range list {
  1583. fmt.Println(item.DrugDosageForm)
  1584. for _, it := range drugs {
  1585. fmt.Println("2222", it.Value, it.Name)
  1586. if item.DrugDosageForm == it.Value {
  1587. item.DrugDosageName = it.Name
  1588. }
  1589. }
  1590. }
  1591. fmt.Print("list22222222", list)
  1592. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1593. var doctor_name string
  1594. var doctor_code string
  1595. doctor_name = "黄亦轩"
  1596. doctor_code = "1001"
  1597. var pagesize int = 50
  1598. var start int = 1
  1599. var stop int
  1600. var pagecount int
  1601. var curpage int
  1602. var isSuccess bool = true
  1603. //总页数,向上取整,注意除之前要先转换类型为float64
  1604. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1605. var ress []*Result
  1606. for curpage = 1; curpage <= pagecount; curpage++ {
  1607. if curpage == 1 {
  1608. start = 1
  1609. } else {
  1610. start = (curpage-1)*pagesize + 1
  1611. }
  1612. stop = curpage * pagesize
  1613. if stop > len(list) {
  1614. stop = len(list)
  1615. }
  1616. //这里就可以查看开始和结束了
  1617. fmt.Println(list[start-1 : stop])
  1618. var customs []*models.DrugDetail
  1619. for _, item := range list {
  1620. detail := &models.DrugDetail{
  1621. MedicalInsuranceNumber: item.MedicalInsuranceNumber,
  1622. Code: item.Code,
  1623. DrugName: item.DrugName,
  1624. DrugSpec: item.DrugSpec,
  1625. DrugDosageName: item.DrugDosageName,
  1626. ManufacturerName: item.ManufacturerName,
  1627. MinUnit: item.MinUnit,
  1628. RetailPrice: item.RetailPrice,
  1629. LastPrice: item.LastPrice,
  1630. LimitRemark: item.LimitRemark,
  1631. }
  1632. customs = append(customs, detail)
  1633. }
  1634. result := service.SzybML008(doctor_name, doctor_code, miConfig.Code, customs)
  1635. fmt.Println("reuslt", result)
  1636. var dat map[string]interface{}
  1637. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1638. fmt.Println(dat)
  1639. } else {
  1640. fmt.Println(err)
  1641. }
  1642. userJSONBytes, _ := json.Marshal(dat)
  1643. var res Result
  1644. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1645. utils.ErrorLog("解析失败:%v", err)
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1647. return
  1648. }
  1649. if res.Transreturncode == "00000000" {
  1650. ress = append(ress, &res)
  1651. } else {
  1652. isSuccess = false
  1653. //失败
  1654. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1655. return
  1656. }
  1657. fmt.Println(isSuccess)
  1658. }
  1659. }
  1660. func (c *SZHisApiController) GetTreatmentProject() {
  1661. //获取药品库数据
  1662. list, _ := service.GetDrugList(10028)
  1663. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1664. var doctor_name string
  1665. var doctor_code string
  1666. doctor_name = "黄亦轩"
  1667. doctor_code = "1001"
  1668. var pagesize int = 50
  1669. var start int = 1
  1670. var stop int
  1671. var pagecount int
  1672. var curpage int
  1673. var isSuccess bool = true
  1674. //总页数,向上取整,注意除之前要先转换类型为float64
  1675. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1676. var ress []*Result
  1677. for curpage = 1; curpage <= pagecount; curpage++ {
  1678. if curpage == 1 {
  1679. start = 1
  1680. } else {
  1681. start = (curpage-1)*pagesize + 1
  1682. }
  1683. stop = curpage * pagesize
  1684. if stop > len(list) {
  1685. stop = len(list)
  1686. }
  1687. //这里就可以查看开始和结束了
  1688. fmt.Println(list[start-1 : stop])
  1689. var customs []*models.DrugDetail
  1690. for _, item := range list {
  1691. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  1692. detail := &models.DrugDetail{
  1693. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  1694. Code: item.Code, //协议机构内部目录编码
  1695. DrugName: item.DrugName, //协议机构内部目录名称
  1696. DrugSpec: item.DrugSpec,
  1697. ManufacturerName: item.ManufacturerName,
  1698. MinUnit: item.MinUnit,
  1699. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  1700. LimitRemark: item.LimitRemark,
  1701. }
  1702. customs = append(customs, detail)
  1703. }
  1704. result := service.SzybML009(doctor_name, doctor_code, miConfig.Code, customs)
  1705. fmt.Println("reuslt9999999999999999", result)
  1706. var dat map[string]interface{}
  1707. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1708. fmt.Println(dat)
  1709. } else {
  1710. fmt.Println(err)
  1711. }
  1712. userJSONBytes, _ := json.Marshal(dat)
  1713. var res Result
  1714. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1715. utils.ErrorLog("解析失败:%v", err)
  1716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1717. return
  1718. }
  1719. if res.Transreturncode == "00000000" {
  1720. ress = append(ress, &res)
  1721. } else {
  1722. isSuccess = false
  1723. //失败
  1724. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1725. return
  1726. }
  1727. fmt.Println(isSuccess)
  1728. }
  1729. }
  1730. func (c *SZHisApiController) GetRevocation() {
  1731. //获取药品库数据
  1732. list, _ := service.GetDrugList(10028)
  1733. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1734. var doctor_name string
  1735. var doctor_code string
  1736. doctor_name = "黄亦轩"
  1737. doctor_code = "1001"
  1738. var pagesize int = 50
  1739. var start int = 1
  1740. var stop int
  1741. var pagecount int
  1742. var curpage int
  1743. var isSuccess bool = true
  1744. //总页数,向上取整,注意除之前要先转换类型为float64
  1745. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1746. var ress []*Result
  1747. for curpage = 1; curpage <= pagecount; curpage++ {
  1748. if curpage == 1 {
  1749. start = 1
  1750. } else {
  1751. start = (curpage-1)*pagesize + 1
  1752. }
  1753. stop = curpage * pagesize
  1754. if stop > len(list) {
  1755. stop = len(list)
  1756. }
  1757. //这里就可以查看开始和结束了
  1758. fmt.Println(list[start-1 : stop])
  1759. var customs []*models.DrugDetail
  1760. for _, item := range list {
  1761. fmt.Println("医疗机构编码", item.MedicalInsuranceNumber)
  1762. detail := &models.DrugDetail{
  1763. MedicalInsuranceNumber: item.MedicalInsuranceNumber, //社保目录
  1764. Code: item.Code, //协议机构内部目录编码
  1765. DrugName: item.DrugName, //协议机构内部目录名称
  1766. DrugSpec: item.DrugSpec,
  1767. ManufacturerName: item.ManufacturerName,
  1768. MinUnit: item.MinUnit,
  1769. RetailPrice: item.RetailPrice, //协议机构内部项目收费价格
  1770. LimitRemark: item.LimitRemark,
  1771. }
  1772. customs = append(customs, detail)
  1773. }
  1774. result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs)
  1775. fmt.Println("reuslt9999999999999999", result)
  1776. var dat map[string]interface{}
  1777. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1778. fmt.Println(dat)
  1779. } else {
  1780. fmt.Println(err)
  1781. }
  1782. userJSONBytes, _ := json.Marshal(dat)
  1783. var res Result
  1784. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1785. utils.ErrorLog("解析失败:%v", err)
  1786. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1787. return
  1788. }
  1789. if res.Transreturncode == "00000000" {
  1790. ress = append(ress, &res)
  1791. } else {
  1792. isSuccess = false
  1793. //失败
  1794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1795. return
  1796. }
  1797. fmt.Println(isSuccess)
  1798. }
  1799. }
  1800. //func (c *SZHisApiController) GetInformationQuery() {
  1801. //
  1802. // var doctor_name string
  1803. // var doctor_code string
  1804. //
  1805. // doctor_name = "黄亦轩"
  1806. // doctor_code = "1001"
  1807. // miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1808. // result := service.SzybML010(doctor_name, doctor_code, miConfig.Code, customs)
  1809. // fmt.Println("reuslt9999999999999999", result)
  1810. // var dat map[string]interface{}
  1811. // if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1812. // fmt.Println(dat)
  1813. // } else {
  1814. // fmt.Println(err)
  1815. // }
  1816. //
  1817. // userJSONBytes, _ := json.Marshal(dat)
  1818. //
  1819. // var res Result
  1820. // if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1821. // utils.ErrorLog("解析失败:%v", err)
  1822. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1823. // return
  1824. // }
  1825. // if res.Transreturncode == "00000000" {
  1826. // ress = append(ress, &res)
  1827. // } else {
  1828. // isSuccess = false
  1829. // //失败
  1830. //
  1831. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1832. // return
  1833. // }
  1834. // fmt.Println(isSuccess)
  1835. //
  1836. //}
  1837. func (c *SZHisApiController) GetDoctorList() {
  1838. //获取所有医生护士信息
  1839. list, _ := service.GetDoctorList(10028)
  1840. //获取所有角色名称
  1841. roleList, _ := service.GetRoleList(10028)
  1842. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1843. for _, item := range list {
  1844. for _, it := range roleList {
  1845. if item.RoleId == it.ID {
  1846. item.Name = it.RoleName
  1847. }
  1848. }
  1849. }
  1850. var doctor_name string
  1851. var doctor_code string
  1852. doctor_name = "黄亦轩"
  1853. doctor_code = "1001"
  1854. var pagesize int = 50
  1855. var start int = 1
  1856. var stop int
  1857. var pagecount int
  1858. var curpage int
  1859. var isSuccess bool = true
  1860. //总页数,向上取整,注意除之前要先转换类型为float64
  1861. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1862. var ress []*Result
  1863. for curpage = 1; curpage <= pagecount; curpage++ {
  1864. if curpage == 1 {
  1865. start = 1
  1866. } else {
  1867. start = (curpage-1)*pagesize + 1
  1868. }
  1869. stop = curpage * pagesize
  1870. if stop > len(list) {
  1871. stop = len(list)
  1872. }
  1873. //这里就可以查看开始和结束了
  1874. fmt.Println(list[start-1 : stop])
  1875. var customs []*models.DocDetail
  1876. for _, item := range list {
  1877. fmt.Println("医护类别", item.Name)
  1878. detail := &models.DocDetail{
  1879. UserName: item.UserName,
  1880. RoleId: item.Name,
  1881. Sex: "",
  1882. CardType: "",
  1883. IdCard: "",
  1884. Phone: "",
  1885. WorkMajorName: "",
  1886. Nation: "",
  1887. BirthDay: 20201022,
  1888. WorkTime: 12,
  1889. Education: "",
  1890. StudyMajorName: "",
  1891. CertificateCode: "", //证书编码
  1892. MedicalCode: "", //医师资格编码
  1893. MedicalRangeCode: "", //医师执业范围代码
  1894. MedicalLevel: "", //医生级别
  1895. TypeJob: "", //职业类别
  1896. DoctorNumber: "", //医师编号
  1897. Licensing: "", //职业标志
  1898. DoctorServiceStatus: "", //医师医保服务资格状态
  1899. MonitoringLevel: "", //监控等级
  1900. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  1901. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  1902. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  1903. PharmacistType: "", //药师类别
  1904. PharmacistPracticeCategory: "", //药师执业类别
  1905. PharmacistsLicensing: "", //药师执业范围
  1906. PharmacistRegistrationNumber: "", //执业药师注册证编号
  1907. OfficeCode: "", //科室编码
  1908. JobNumber: "", //工号
  1909. PostName: "", //职位名称
  1910. TechnicalJobLevelCode: "", //专业技术职务级别编码
  1911. IsActive: "", //在职与否
  1912. PrescriptionQualificationIdentification: "", //处方资格标识
  1913. IdentificationOutpatients: "", //门诊大病医师标识
  1914. OutpatientIllnessCategory: "", //门诊大病类别
  1915. StartTime: 1233, //开始日期
  1916. }
  1917. customs = append(customs, detail)
  1918. }
  1919. result := service.SzybYS001(doctor_name, doctor_code, miConfig.Code, customs)
  1920. fmt.Println("reuslt9999999999999999", result)
  1921. var dat map[string]interface{}
  1922. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  1923. fmt.Println(dat)
  1924. } else {
  1925. fmt.Println(err)
  1926. }
  1927. userJSONBytes, _ := json.Marshal(dat)
  1928. var res Result
  1929. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  1930. utils.ErrorLog("解析失败:%v", err)
  1931. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  1932. return
  1933. }
  1934. if res.Transreturncode == "00000000" {
  1935. ress = append(ress, &res)
  1936. } else {
  1937. isSuccess = false
  1938. //失败
  1939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  1940. return
  1941. }
  1942. fmt.Println(isSuccess)
  1943. }
  1944. }
  1945. func (c *SZHisApiController) GetMedicalList() {
  1946. //获取所有医生护士信息
  1947. list, _ := service.GetDoctorList(10028)
  1948. //获取所有角色名称
  1949. roleList, _ := service.GetRoleList(10028)
  1950. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  1951. for _, item := range list {
  1952. for _, it := range roleList {
  1953. if item.RoleId == it.ID {
  1954. item.Name = it.RoleName
  1955. }
  1956. }
  1957. }
  1958. var doctor_name string
  1959. var doctor_code string
  1960. doctor_name = "黄亦轩"
  1961. doctor_code = "1001"
  1962. var pagesize int = 50
  1963. var start int = 1
  1964. var stop int
  1965. var pagecount int
  1966. var curpage int
  1967. var isSuccess bool = true
  1968. //总页数,向上取整,注意除之前要先转换类型为float64
  1969. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  1970. var ress []*Result
  1971. for curpage = 1; curpage <= pagecount; curpage++ {
  1972. if curpage == 1 {
  1973. start = 1
  1974. } else {
  1975. start = (curpage-1)*pagesize + 1
  1976. }
  1977. stop = curpage * pagesize
  1978. if stop > len(list) {
  1979. stop = len(list)
  1980. }
  1981. //这里就可以查看开始和结束了
  1982. fmt.Println(list[start-1 : stop])
  1983. var customs []*models.DocDetail
  1984. for _, item := range list {
  1985. fmt.Println("医护类别", item.Name)
  1986. detail := &models.DocDetail{
  1987. UserName: item.UserName,
  1988. RoleId: item.Name,
  1989. Sex: "",
  1990. CardType: "",
  1991. IdCard: "",
  1992. Phone: "",
  1993. WorkMajorName: "",
  1994. Nation: "",
  1995. BirthDay: 20201022,
  1996. WorkTime: 12,
  1997. Education: "",
  1998. StudyMajorName: "",
  1999. CertificateCode: "", //证书编码
  2000. MedicalCode: "", //医师资格编码
  2001. MedicalRangeCode: "", //医师执业范围代码
  2002. MedicalLevel: "", //医生级别
  2003. TypeJob: "", //职业类别
  2004. DoctorNumber: "", //医师编号
  2005. Licensing: "", //职业标志
  2006. DoctorServiceStatus: "", //医师医保服务资格状态
  2007. MonitoringLevel: "", //监控等级
  2008. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2009. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2010. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2011. PharmacistType: "", //药师类别
  2012. PharmacistPracticeCategory: "", //药师执业类别
  2013. PharmacistsLicensing: "", //药师执业范围
  2014. PharmacistRegistrationNumber: "", //执业药师注册证编号
  2015. OfficeCode: "", //科室编码
  2016. JobNumber: "", //工号
  2017. PostName: "", //职位名称
  2018. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2019. IsActive: "", //在职与否
  2020. PrescriptionQualificationIdentification: "", //处方资格标识
  2021. IdentificationOutpatients: "", //门诊大病医师标识
  2022. OutpatientIllnessCategory: "", //门诊大病类别
  2023. StartTime: 1233, //开始日期
  2024. }
  2025. customs = append(customs, detail)
  2026. }
  2027. result := service.SzybYS002(doctor_name, doctor_code, miConfig.Code, customs)
  2028. fmt.Println("reuslt9999999999999999", result)
  2029. var dat map[string]interface{}
  2030. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2031. fmt.Println(dat)
  2032. } else {
  2033. fmt.Println(err)
  2034. }
  2035. userJSONBytes, _ := json.Marshal(dat)
  2036. var res Result
  2037. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2038. utils.ErrorLog("解析失败:%v", err)
  2039. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2040. return
  2041. }
  2042. if res.Transreturncode == "00000000" {
  2043. ress = append(ress, &res)
  2044. } else {
  2045. isSuccess = false
  2046. //失败
  2047. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2048. return
  2049. }
  2050. fmt.Println(isSuccess)
  2051. }
  2052. }
  2053. func (c *SZHisApiController) GetUpdateMedicalList() {
  2054. //获取所有医生护士信息
  2055. list, _ := service.GetDoctorList(10028)
  2056. //获取所有角色名称
  2057. roleList, _ := service.GetRoleList(10028)
  2058. miConfig, _ := service.FindMedicalInsuranceInfo(10028)
  2059. for _, item := range list {
  2060. for _, it := range roleList {
  2061. if item.RoleId == it.ID {
  2062. item.Name = it.RoleName
  2063. }
  2064. }
  2065. }
  2066. var doctor_name string
  2067. var doctor_code string
  2068. doctor_name = "黄亦轩"
  2069. doctor_code = "1001"
  2070. var pagesize int = 50
  2071. var start int = 1
  2072. var stop int
  2073. var pagecount int
  2074. var curpage int
  2075. var isSuccess bool = true
  2076. //总页数,向上取整,注意除之前要先转换类型为float64
  2077. pagecount = int(math.Ceil(float64(len(list)) / float64(pagesize)))
  2078. var ress []*Result
  2079. for curpage = 1; curpage <= pagecount; curpage++ {
  2080. if curpage == 1 {
  2081. start = 1
  2082. } else {
  2083. start = (curpage-1)*pagesize + 1
  2084. }
  2085. stop = curpage * pagesize
  2086. if stop > len(list) {
  2087. stop = len(list)
  2088. }
  2089. //这里就可以查看开始和结束了
  2090. fmt.Println(list[start-1 : stop])
  2091. var customs []*models.DocDetail
  2092. for _, item := range list {
  2093. fmt.Println("医护类别", item.Name)
  2094. detail := &models.DocDetail{
  2095. StaffCode: "", //医护人员编码
  2096. UserName: item.UserName, //医护人员姓名
  2097. RoleId: item.Name, //医护人员类别
  2098. Sex: "", //性别
  2099. CardType: "", //证件类型
  2100. IdCard: "", //证件号码
  2101. Phone: "", //联系电话
  2102. WorkMajorName: "", //现从事专业名称
  2103. Nation: "", //民族
  2104. BirthDay: 20201022, //出生日期
  2105. WorkTime: 12, //参加工作日期
  2106. Education: "", //学历
  2107. StudyMajorName: "", //所学的专业名称
  2108. CertificateCode: "", //证书编码
  2109. MedicalCode: "", //医师资格编码
  2110. MedicalRangeCode: "", //医师执业范围代码
  2111. MedicalLevel: "", //医生级别
  2112. TypeJob: "", //职业类别
  2113. DoctorNumber: "", //医师编号
  2114. Licensing: "", //职业标志
  2115. DoctorServiceStatus: "", //医师医保服务资格状态
  2116. MonitoringLevel: "", //监控等级
  2117. DrugPsychotropicSubstances: "", //毒麻精神药品资格
  2118. HealthCareCode: "", // 母婴保健技术考核合格证书编号
  2119. PlanningTechnicalServiceCode: "", //计划生育技术服务人员合格证编号
  2120. PharmacistType: "", //药师类别
  2121. PharmacistPracticeCategory: "", //药师执业类别
  2122. PharmacistsLicensing: "", //药师执业范围
  2123. PharmacistRegistrationNumber: "", //执业药师注册证编号
  2124. OfficeCode: "", //科室编码
  2125. JobNumber: "", //工号
  2126. PostName: "", //职位名称
  2127. TechnicalJobLevelCode: "", //专业技术职务级别编码
  2128. IsActive: "", //在职与否
  2129. PrescriptionQualificationIdentification: "", //处方资格标识
  2130. IdentificationOutpatients: "", //门诊大病医师标识
  2131. OutpatientIllnessCategory: "", //门诊大病类别
  2132. StartTime: 1233, //开始日期
  2133. EndTime: 123333,
  2134. }
  2135. customs = append(customs, detail)
  2136. }
  2137. result := service.SzybYS003(doctor_name, doctor_code, miConfig.Code, customs)
  2138. fmt.Println("reuslt9999999999999999", result)
  2139. var dat map[string]interface{}
  2140. if err := json.Unmarshal([]byte(result), &dat); err == nil {
  2141. fmt.Println(dat)
  2142. } else {
  2143. fmt.Println(err)
  2144. }
  2145. userJSONBytes, _ := json.Marshal(dat)
  2146. var res Result
  2147. if err := json.Unmarshal(userJSONBytes, &res); err != nil {
  2148. utils.ErrorLog("解析失败:%v", err)
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDataException)
  2150. return
  2151. }
  2152. if res.Transreturncode == "00000000" {
  2153. ress = append(ress, &res)
  2154. } else {
  2155. isSuccess = false
  2156. //失败
  2157. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePreSettleFaildParamWrong)
  2158. return
  2159. }
  2160. fmt.Println(isSuccess)
  2161. }
  2162. }
  2163. //type Charset string
  2164. //const (
  2165. // UTF8 = Charset("UTF-8")
  2166. // GB18030 = Charset("GB18030")
  2167. //)
  2168. //func ConvertByte2String(byte []byte, charset Charset) string {
  2169. //
  2170. // var str string
  2171. // switch charset {
  2172. // case GB18030:
  2173. // decodeBytes, _ := simplifiedchinese.GB18030.NewDecoder().Bytes(byte)
  2174. // str = string(decodeBytes)
  2175. // case UTF8:
  2176. // fallthrough
  2177. // default:
  2178. // str = string(byte)
  2179. // }
  2180. //
  2181. // return str
  2182. //}