sz_his_api_controller.go 71KB

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