sz_his_service.go 52KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512
  1. package service
  2. import (
  3. "bytes"
  4. "encoding/json"
  5. "fmt"
  6. "gdyb/models"
  7. "github.com/astaxie/beego"
  8. "io/ioutil"
  9. "math/rand"
  10. "net/http"
  11. "strconv"
  12. "time"
  13. _ "unsafe"
  14. )
  15. func SzybXX001(doctor string, doctor_code string, fixmedins_code string, account string, verify_code string, serial_number string, version_code string) string {
  16. // 生成输入报文
  17. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
  18. inputData := make(map[string]interface{})
  19. inputMessage["transType"] = "XX001" // 交易编码
  20. inputMessage["transVersion"] = version_code // 交易编码
  21. inputData["aaz500"] = account
  22. inputData["bzz269"] = "000000"
  23. inputData["bke384"] = inputMessage["serialNumber"]
  24. inputMessage["transBody"] = inputData
  25. bytesData, err := json.Marshal(inputMessage)
  26. fmt.Println(string(bytesData))
  27. if err != nil {
  28. fmt.Println(err.Error())
  29. return err.Error()
  30. }
  31. reader := bytes.NewReader(bytesData)
  32. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  33. url := "http://192.168.1.88:6666/szsi-portal/transData"
  34. request, err := http.NewRequest("POST", url, reader)
  35. if err != nil {
  36. fmt.Println(err.Error())
  37. return err.Error()
  38. }
  39. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  40. client := http.Client{}
  41. resp, err := client.Do(request)
  42. if err != nil {
  43. fmt.Println(err.Error())
  44. return err.Error()
  45. }
  46. respBytes, err := ioutil.ReadAll(resp.Body)
  47. if err != nil {
  48. fmt.Println(err.Error())
  49. return err.Error()
  50. }
  51. fmt.Println(string(respBytes))
  52. str := string(respBytes)
  53. return str
  54. }
  55. func SzybMZ002(doctor string, doctor_code string, fixmedins_code string, dept_code string, account string, verify_code string, serial_number string, mz_number string, version_code string, custom_code string, project_name string, price float64, medical_care int64) string {
  56. // 生成输入报文
  57. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
  58. inputData := make(map[string]interface{})
  59. inputMessage["transType"] = "MZ002" // 交易编码
  60. inputMessage["transVersion"] = version_code // 交易编码
  61. if medical_care == 11 || medical_care == 1111 || medical_care == 1112 {
  62. inputData["aka130"] = "11"
  63. } else if medical_care == 13 {
  64. inputData["aka130"] = "13"
  65. } else {
  66. inputData["aka130"] = fmt.Sprintf("%d", medical_care)
  67. }
  68. //inputData["aka130"] = "13"
  69. inputData["akc190"] = mz_number
  70. inputData["aaz500"] = account
  71. inputData["bzz269"] = "000000"
  72. inputData["akf001"] = dept_code
  73. inputData["akc264"] = price
  74. inputData["bke384"] = inputMessage["serialNumber"]
  75. switch custom_code {
  76. case "110100002":
  77. inputData["bkc368"] = "1"
  78. break
  79. case "110200002-2":
  80. inputData["bkc368"] = "3"
  81. break
  82. case "110200002-3":
  83. inputData["bkc368"] = "2"
  84. break
  85. case "110200003":
  86. break
  87. case "110200002-1":
  88. inputData["bkc368"] = "5"
  89. break
  90. }
  91. if custom_code == "0" {
  92. inputData["bkc368"] = "4"
  93. inputData["listsize"] = 0
  94. inputMessage["transBody"] = inputData
  95. bytesData, err := json.Marshal(inputMessage)
  96. fmt.Println(string(bytesData))
  97. if err != nil {
  98. fmt.Println(err.Error())
  99. return err.Error()
  100. }
  101. reader := bytes.NewReader(bytesData)
  102. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  103. url := "http://192.168.1.88:6666/szsi-portal/transData"
  104. request, err := http.NewRequest("POST", url, reader)
  105. if err != nil {
  106. fmt.Println(err.Error())
  107. return err.Error()
  108. }
  109. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  110. client := http.Client{}
  111. resp, err := client.Do(request)
  112. if err != nil {
  113. fmt.Println(err.Error())
  114. return err.Error()
  115. }
  116. respBytes, err := ioutil.ReadAll(resp.Body)
  117. if err != nil {
  118. fmt.Println(err.Error())
  119. return err.Error()
  120. }
  121. fmt.Println(string(respBytes))
  122. str := string(respBytes)
  123. return str
  124. } else {
  125. inputData["listsize"] = 1
  126. timestamp := time.Now().Unix()
  127. tempTime := time.Unix(timestamp, 0)
  128. timeFormat := tempTime.Format("20060102150405")
  129. feedetail := make([]map[string]interface{}, 0)
  130. feedetailInfo := make(map[string]interface{})
  131. feedetailInfo["aae072"] = timeFormat
  132. feedetailInfo["bkf500"] = timeFormat
  133. feedetailInfo["ake001"] = custom_code
  134. feedetailInfo["ake005"] = custom_code
  135. feedetailInfo["ake006"] = project_name
  136. feedetailInfo["aae019"] = price
  137. feedetail = append(feedetail, feedetailInfo)
  138. inputData["inputlist"] = feedetail
  139. inputMessage["transBody"] = inputData
  140. bytesData, err := json.Marshal(inputMessage)
  141. fmt.Println(string(bytesData))
  142. if err != nil {
  143. fmt.Println(err.Error())
  144. return err.Error()
  145. }
  146. reader := bytes.NewReader(bytesData)
  147. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  148. url := "http://192.168.1.88:6666/szsi-portal/transData"
  149. request, err := http.NewRequest("POST", url, reader)
  150. if err != nil {
  151. fmt.Println(err.Error())
  152. return err.Error()
  153. }
  154. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  155. client := http.Client{}
  156. resp, err := client.Do(request)
  157. if err != nil {
  158. fmt.Println(err.Error())
  159. return err.Error()
  160. }
  161. respBytes, err := ioutil.ReadAll(resp.Body)
  162. if err != nil {
  163. fmt.Println(err.Error())
  164. return err.Error()
  165. }
  166. fmt.Println(string(respBytes))
  167. str := string(respBytes)
  168. return str
  169. }
  170. }
  171. func SzybFY001(doctor string, doctor_code string, fixmedins_code string, datas []*models.CustomDetail, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor_code string) string {
  172. // 生成输入报文
  173. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
  174. inputData := make(map[string]interface{})
  175. inputMessage["transType"] = "FY001" // 交易编码
  176. inputMessage["transChannel"] = "10" // 交易编码
  177. inputMessage["transVersion"] = version_code // 交易编码
  178. inputData["akc190"] = mz_number
  179. inputData["bke384"] = serial_number
  180. inputData["listsize"] = len(datas)
  181. feedetail := make([]map[string]interface{}, 0)
  182. for _, item := range datas {
  183. feedetailInfo := make(map[string]interface{})
  184. feedetailInfo["aae072"] = item.PrescriptionNumber
  185. feedetailInfo["bkc369"] = item.OrderType
  186. feedetailInfo["bkf500"] = item.ChargeSerialNumber
  187. feedetailInfo["ake001"] = item.Code
  188. feedetailInfo["ake002"] = item.CodeName
  189. feedetailInfo["bkm017"] = item.BwCode
  190. feedetailInfo["aka070"] = item.DoseCode
  191. feedetailInfo["aka074"] = item.Spec
  192. feedetailInfo["aka064"] = 1
  193. feedetailInfo["ake005"] = item.Code
  194. feedetailInfo["ake006"] = item.CodeName
  195. feedetailInfo["akc225"] = item.Price
  196. feedetailInfo["akc226"] = item.Count
  197. feedetailInfo["akc264"] = item.Total
  198. feedetailInfo["aka067"] = item.Unit
  199. feedetailInfo["akc271"] = item.ChargeOrderDate
  200. feedetailInfo["bkc320"] = drug_doctor_code
  201. feedetail = append(feedetail, feedetailInfo)
  202. }
  203. inputData["inputlist"] = feedetail
  204. inputMessage["transBody"] = inputData
  205. fmt.Println(inputMessage)
  206. bytesData, err := json.Marshal(inputMessage)
  207. fmt.Println(string(bytesData))
  208. if err != nil {
  209. fmt.Println(err.Error())
  210. return err.Error()
  211. }
  212. reader := bytes.NewReader(bytesData)
  213. url := "http://192.168.1.88:6666/szsi-portal/transData"
  214. request, err := http.NewRequest("POST", url, reader)
  215. if err != nil {
  216. fmt.Println(err.Error())
  217. return err.Error()
  218. }
  219. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  220. client := http.Client{}
  221. resp, err := client.Do(request)
  222. if err != nil {
  223. fmt.Println(err.Error())
  224. return err.Error()
  225. }
  226. respBytes, err := ioutil.ReadAll(resp.Body)
  227. if err != nil {
  228. fmt.Println(err.Error())
  229. return err.Error()
  230. }
  231. fmt.Println(string(respBytes))
  232. str := string(respBytes)
  233. return str
  234. }
  235. func SzybFY002(doctor string, doctor_code string, fixmedins_code string, datas []*models.CustomDetail, verify_code string, serial_number string, mz_number string, version_code string) string {
  236. // 生成输入报文
  237. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, serial_number)
  238. inputData := make(map[string]interface{})
  239. inputMessage["transType"] = "FY002" // 交易编码
  240. inputMessage["transVersion"] = version_code // 交易编码
  241. inputData["akc190"] = mz_number
  242. inputData["bke384"] = serial_number
  243. inputData["listsize"] = len(datas)
  244. feedetail := make([]map[string]interface{}, 0)
  245. for _, item := range datas {
  246. feedetailInfo := make(map[string]interface{})
  247. feedetailInfo["aae072"] = item.PrescriptionNumber
  248. feedetailInfo["bkf500"] = item.ChargeSerialNumber
  249. feedetail = append(feedetail, feedetailInfo)
  250. }
  251. inputData["inputlist"] = feedetail
  252. inputMessage["transBody"] = inputData
  253. bytesData, err := json.Marshal(inputMessage)
  254. fmt.Println(string(bytesData))
  255. if err != nil {
  256. fmt.Println(err.Error())
  257. return err.Error()
  258. }
  259. reader := bytes.NewReader(bytesData)
  260. //url := "http://192.168.1.99:10000"
  261. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  262. url := "http://192.168.1.88:6666/szsi-portal/transData"
  263. request, err := http.NewRequest("POST", url, reader)
  264. if err != nil {
  265. fmt.Println(err.Error())
  266. return err.Error()
  267. }
  268. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  269. client := http.Client{}
  270. resp, err := client.Do(request)
  271. if err != nil {
  272. fmt.Println(err.Error())
  273. return err.Error()
  274. }
  275. respBytes, err := ioutil.ReadAll(resp.Body)
  276. if err != nil {
  277. fmt.Println(err.Error())
  278. return err.Error()
  279. }
  280. fmt.Println(string(respBytes))
  281. str := string(respBytes)
  282. return str
  283. }
  284. func SzybFY004(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string, new_number string) string {
  285. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, new_number)
  286. inputData := make(map[string]interface{})
  287. inputMessage["transType"] = "FY004" // 交易编码
  288. inputMessage["transVersion"] = version_code // 交易编码
  289. inputData["akc190"] = mz_number
  290. if medical_care == 11 || medical_care == 1111 || medical_care == 1112 {
  291. inputData["aka130"] = "11"
  292. } else if medical_care == 13 {
  293. inputData["aka130"] = "13"
  294. inputData["cka303"] = code
  295. } else {
  296. inputData["aka130"] = fmt.Sprintf("%d", medical_care)
  297. }
  298. inputData["bkc320"] = drug_doctor
  299. inputData["ckc350"] = drug_doctor_name
  300. inputData["bzz269"] = "000000"
  301. inputData["aka030"] = "12"
  302. inputData["akc264"] = total
  303. inputData["ckc601"] = "0"
  304. inputData["bke384"] = serial_number
  305. inputMessage["transBody"] = inputData
  306. bytesData, err := json.Marshal(inputMessage)
  307. fmt.Println(string(bytesData))
  308. if err != nil {
  309. fmt.Println(err.Error())
  310. return err.Error()
  311. }
  312. reader := bytes.NewReader(bytesData)
  313. //url := "http://192.168.1.99:10000"
  314. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  315. url := "http://192.168.1.88:6666/szsi-portal/transData"
  316. request, err := http.NewRequest("POST", url, reader)
  317. if err != nil {
  318. fmt.Println(err.Error())
  319. return err.Error()
  320. }
  321. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  322. client := http.Client{}
  323. resp, err := client.Do(request)
  324. if err != nil {
  325. fmt.Println(err.Error())
  326. return err.Error()
  327. }
  328. respBytes, err := ioutil.ReadAll(resp.Body)
  329. if err != nil {
  330. fmt.Println(err.Error())
  331. return err.Error()
  332. }
  333. fmt.Println(string(respBytes))
  334. str := string(respBytes)
  335. return str
  336. }
  337. func SzybFY005(doctor string, doctor_code string, fixmedins_code string, total float64, account string, verify_code string, serial_number string, mz_number string, version_code string, drug_doctor string, drug_doctor_name string, medical_care int64, code string, new_number string) string {
  338. // 生成输入报文
  339. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, new_number)
  340. inputData := make(map[string]interface{})
  341. inputMessage["transType"] = "FY005" // 交易编码
  342. inputMessage["transVersion"] = version_code // 交易编码
  343. if medical_care == 11 || medical_care == 1111 || medical_care == 1112 {
  344. inputData["aka130"] = "11"
  345. } else if medical_care == 13 {
  346. inputData["aka130"] = "13"
  347. inputData["cka303"] = code
  348. } else {
  349. inputData["aka130"] = fmt.Sprintf("%d", medical_care)
  350. }
  351. inputData["aaz500"] = account
  352. inputData["bzz269"] = "000000"
  353. inputData["akc190"] = mz_number
  354. inputData["bkc320"] = drug_doctor
  355. inputData["ckc350"] = drug_doctor_name
  356. inputData["aka030"] = "12"
  357. inputData["akc264"] = total
  358. inputData["ckc601"] = "0"
  359. inputData["bke384"] = serial_number
  360. inputMessage["transBody"] = inputData
  361. bytesData, err := json.Marshal(inputMessage)
  362. fmt.Println(string(bytesData))
  363. if err != nil {
  364. fmt.Println(err.Error())
  365. return err.Error()
  366. }
  367. reader := bytes.NewReader(bytesData)
  368. //url := "http://192.168.1.99:10000"
  369. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  370. url := "http://192.168.1.88:6666/szsi-portal/transData"
  371. request, err := http.NewRequest("POST", url, reader)
  372. if err != nil {
  373. fmt.Println(err.Error())
  374. return err.Error()
  375. }
  376. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  377. client := http.Client{}
  378. resp, err := client.Do(request)
  379. if err != nil {
  380. fmt.Println(err.Error())
  381. return err.Error()
  382. }
  383. respBytes, err := ioutil.ReadAll(resp.Body)
  384. if err != nil {
  385. fmt.Println(err.Error())
  386. return err.Error()
  387. }
  388. fmt.Println(string(respBytes))
  389. str := string(respBytes)
  390. return str
  391. }
  392. func SzybJY001(doctor string, doctor_code string, fixmedins_code string, setl_number string, mz_number string, verify_code string, version_code string) string {
  393. // 生成输入报文
  394. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, setl_number)
  395. inputData := make(map[string]interface{})
  396. inputMessage["transType"] = "JY001" // 交易编码
  397. inputMessage["transVersion"] = version_code // 交易编码
  398. inputData["akc190"] = mz_number
  399. inputData["bke384"] = setl_number
  400. inputMessage["transBody"] = inputData
  401. bytesData, err := json.Marshal(inputMessage)
  402. fmt.Println(string(bytesData))
  403. if err != nil {
  404. fmt.Println(err.Error())
  405. return err.Error()
  406. }
  407. reader := bytes.NewReader(bytesData)
  408. //url := "http://192.168.1.99:10000"
  409. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  410. url := "http://192.168.1.88:6666/szsi-portal/transData"
  411. request, err := http.NewRequest("POST", url, reader)
  412. if err != nil {
  413. fmt.Println(err.Error())
  414. return err.Error()
  415. }
  416. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  417. client := http.Client{}
  418. resp, err := client.Do(request)
  419. if err != nil {
  420. fmt.Println(err.Error())
  421. return err.Error()
  422. }
  423. respBytes, err := ioutil.ReadAll(resp.Body)
  424. if err != nil {
  425. fmt.Println(err.Error())
  426. return err.Error()
  427. }
  428. fmt.Println(string(respBytes))
  429. str := string(respBytes)
  430. return str
  431. }
  432. func SzybJY002(doctor string, doctor_code string, fixmedins_code string, setl_number string, mz_number string, verify_code string, new_setl_number string, version_code string) string {
  433. // 生成输入报文
  434. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, new_setl_number)
  435. inputData := make(map[string]interface{})
  436. inputMessage["transType"] = "JY002" // 交易编码
  437. inputMessage["transVersion"] = version_code // 交易编码
  438. inputData["akc190"] = mz_number
  439. inputData["bke384"] = setl_number
  440. inputMessage["transBody"] = inputData
  441. bytesData, err := json.Marshal(inputMessage)
  442. fmt.Println(string(bytesData))
  443. if err != nil {
  444. fmt.Println(err.Error())
  445. return err.Error()
  446. }
  447. reader := bytes.NewReader(bytesData)
  448. //url := "http://192.168.1.99:10000"
  449. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  450. url := "http://192.168.1.88:6666/szsi-portal/transData"
  451. request, err := http.NewRequest("POST", url, reader)
  452. if err != nil {
  453. fmt.Println(err.Error())
  454. return err.Error()
  455. }
  456. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  457. client := http.Client{}
  458. resp, err := client.Do(request)
  459. if err != nil {
  460. fmt.Println(err.Error())
  461. return err.Error()
  462. }
  463. respBytes, err := ioutil.ReadAll(resp.Body)
  464. if err != nil {
  465. fmt.Println(err.Error())
  466. return err.Error()
  467. }
  468. fmt.Println(string(respBytes))
  469. str := string(respBytes)
  470. return str
  471. }
  472. func SzybJY003(doctor string, doctor_code string, fixmedins_code string, setl_number string, mz_number string, verify_code string, version_code string) string {
  473. // 生成输入报文
  474. inputMessage := SetSZInputMessage(doctor, doctor_code, fixmedins_code, verify_code, setl_number)
  475. inputData := make(map[string]interface{})
  476. inputMessage["transType"] = "JY003" // 交易编码
  477. inputMessage["transVersion"] = version_code // 交易编码
  478. inputData["akc190"] = mz_number
  479. inputData["bke384"] = setl_number
  480. inputMessage["transBody"] = inputData
  481. bytesData, err := json.Marshal(inputMessage)
  482. fmt.Println(string(bytesData))
  483. if err != nil {
  484. fmt.Println(err.Error())
  485. return err.Error()
  486. }
  487. reader := bytes.NewReader(bytesData)
  488. //url := "http://192.168.1.99:10000"
  489. //url := "http://192.168.1.228:17001/szsi-portal/transData"
  490. url := "http://192.168.1.88:6666/szsi-portal/transData"
  491. request, err := http.NewRequest("POST", url, reader)
  492. if err != nil {
  493. fmt.Println(err.Error())
  494. return err.Error()
  495. }
  496. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  497. client := http.Client{}
  498. resp, err := client.Do(request)
  499. if err != nil {
  500. fmt.Println(err.Error())
  501. return err.Error()
  502. }
  503. respBytes, err := ioutil.ReadAll(resp.Body)
  504. if err != nil {
  505. fmt.Println(err.Error())
  506. return err.Error()
  507. }
  508. fmt.Println(string(respBytes))
  509. str := string(respBytes)
  510. return str
  511. }
  512. // 生成基础报文
  513. func SetSZInputMessage(doctor string, doctor_code string, fixmedins_code string, verify_code string, number string) map[string]interface{} {
  514. month := time.Unix(1557042972, 0).Format("1")
  515. year := time.Now().Format("2006")
  516. month = time.Now().Format("01")
  517. day := time.Now().Format("02")
  518. hour := time.Now().Format("15")
  519. min := time.Now().Format("04")
  520. sec := time.Now().Format("05")
  521. msec := time.Now().Format("000")
  522. // 生成输入报文
  523. inputMessage := make(map[string]interface{})
  524. //
  525. inputMessage["cardArea"] = "440300" // 发卡地行政区划代码
  526. inputMessage["extendDeviceId"] = ""
  527. inputMessage["extendSerialNumber"] = ""
  528. inputMessage["extendUserId"] = ""
  529. inputMessage["hospitalCode"] = fixmedins_code // 协议机构编码
  530. inputMessage["operatorCode"] = doctor_code // 操作员编码
  531. inputMessage["operatorName"] = doctor // 操作员名字
  532. inputMessage["operatorPass"] = "" // 定点协议机构操作人员编码
  533. inputMessage["serialNumber"] = number
  534. inputMessage["transReturnCode"] = "" //
  535. inputMessage["transReturnMessage"] = "" //
  536. inputMessage["transTime"] = year + month + day + hour + min + sec + ":" + msec //
  537. inputMessage["verifyCode"] = verify_code //
  538. inputMessage["transChannel"] = "10" //
  539. return inputMessage
  540. }
  541. func msToTime(ms int64) string {
  542. tm := time.Unix(0, ms*int64(time.Millisecond))
  543. return tm.Format("2006-02-01 15:04:05.000")
  544. }
  545. //
  546. //func SzybML008(doctor string, doctor_code string, fixmedins_code string, datas []*models.DrugDetail) string {
  547. // //生成输入报文
  548. // inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  549. //
  550. // inputData := make(map[string]interface{})
  551. // inputMessage["transType"] = "JY003" // 交易编码
  552. //
  553. // inputData["listsize"] = len(datas)
  554. // inputMessage["transType"] = "ML008" // 交易编码S
  555. // feedetail := make([]map[string]interface{}, 0)
  556. // //inputData["akc190"] = mz_number
  557. // //inputData["bke384"] = setl_number
  558. //
  559. // for _, item := range datas {
  560. //
  561. // feedetailInfo := make(map[string]interface{})
  562. // feedetailInfo["ake001"] = item.MedicalInsuranceNumber
  563. // feedetailInfo["bkm017"] = item.Code
  564. // feedetailInfo["ake005"] = item.Code
  565. // feedetailInfo["ake006"] = item.DrugName
  566. // feedetailInfo["aka074"] = item.DrugSpec
  567. // feedetailInfo["aka070"] = item.DrugDosageName
  568. // //feedetailInfo["aka070"] = "片"
  569. // feedetailInfo["aka067"] = item.MinUnit
  570. // feedetailInfo["bka053"] = item.ManufacturerName
  571. // feedetailInfo["aka064"] = "1"
  572. // feedetailInfo["bka505"] = item.LastPrice
  573. // feedetailInfo["bka506"] = item.RetailPrice
  574. // feedetailInfo["aae030"] = 20210406
  575. // feedetailInfo["aae013"] = item.LimitRemark
  576. // feedetail = append(feedetail, feedetailInfo)
  577. // }
  578. //
  579. // inputData["inputlist"] = feedetail
  580. // inputMessage["transBody"] = inputData
  581. //
  582. // bytesData, err := json.Marshal(inputMessage)
  583. // fmt.Println(string(bytesData))
  584. // if err != nil {
  585. // fmt.Println(err.Error())
  586. // return err.Error()
  587. // }
  588. // reader := bytes.NewReader(bytesData)
  589. // //url := "http://192.168.1.99:10000"
  590. // url := "http://192.168.1.228:17001/szsi-portal/transData"
  591. //
  592. // request, err := http.NewRequest("POST", url, reader)
  593. // if err != nil {
  594. // fmt.Println(err.Error())
  595. // return err.Error()
  596. // }
  597. //
  598. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  599. //
  600. // client := http.Client{}
  601. // resp, err := client.Do(request)
  602. // if err != nil {
  603. // fmt.Println(err.Error())
  604. // return err.Error()
  605. // }
  606. // respBytes, err := ioutil.ReadAll(resp.Body)
  607. // if err != nil {
  608. // fmt.Println(err.Error())
  609. // return err.Error()
  610. // }
  611. // fmt.Println(string(respBytes))
  612. // str := string(respBytes)
  613. // return str
  614. //}
  615. func SzybML008(doctor string, doctor_code string, fixmedins_code string, basedrug *models.DrugDetail) string {
  616. //生成输入报文
  617. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  618. inputData := make(map[string]interface{})
  619. inputData["listsize"] = 1
  620. inputMessage["transType"] = "ML008" // 交易编码S
  621. feedetail := make([]map[string]interface{}, 0)
  622. feedetailInfo := make(map[string]interface{})
  623. feedetailInfo["ake001"] = basedrug.MedicalInsuranceNumber
  624. feedetailInfo["bkm017"] = basedrug.Code
  625. feedetailInfo["ake005"] = basedrug.Code
  626. feedetailInfo["ake006"] = basedrug.DrugName
  627. feedetailInfo["aka074"] = basedrug.DrugSpec
  628. feedetailInfo["aka070"] = basedrug.DrugDosageName
  629. feedetailInfo["aka067"] = basedrug.MinUnit
  630. feedetailInfo["bka053"] = basedrug.ManufacturerName
  631. feedetailInfo["aka064"] = "1"
  632. feedetailInfo["bka505"] = basedrug.LastPrice
  633. feedetailInfo["bka506"] = basedrug.RetailPrice
  634. feedetailInfo["aae030"], _ = strconv.ParseInt(basedrug.RecordDate, 10, 64)
  635. feedetailInfo["aae013"] = basedrug.LimitRemark
  636. feedetail = append(feedetail, feedetailInfo)
  637. inputData["inputlist"] = feedetail
  638. inputMessage["transBody"] = inputData
  639. bytesData, err := json.Marshal(inputMessage)
  640. fmt.Println(string(bytesData))
  641. if err != nil {
  642. fmt.Println(err.Error())
  643. return err.Error()
  644. }
  645. reader := bytes.NewReader(bytesData)
  646. url := beego.AppConfig.String("url")
  647. request, err := http.NewRequest("POST", url, reader)
  648. if err != nil {
  649. fmt.Println(err.Error())
  650. return err.Error()
  651. }
  652. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  653. client := http.Client{}
  654. resp, err := client.Do(request)
  655. if err != nil {
  656. fmt.Println(err.Error())
  657. return err.Error()
  658. }
  659. respBytes, err := ioutil.ReadAll(resp.Body)
  660. if err != nil {
  661. fmt.Println(err.Error())
  662. return err.Error()
  663. }
  664. fmt.Println(string(respBytes))
  665. str := string(respBytes)
  666. return str
  667. }
  668. // 生成基础报文
  669. func SetSZDrugMessage(doctor string, doctor_code string, fixmedins_code string) map[string]interface{} {
  670. month := time.Unix(1557042972, 0).Format("1")
  671. year := time.Now().Format("2006")
  672. month = time.Now().Format("01")
  673. day := time.Now().Format("02")
  674. hour := time.Now().Format("15")
  675. min := time.Now().Format("04")
  676. sec := time.Now().Format("05")
  677. msec := time.Now().Format("000")
  678. //生成输入报文
  679. inputMessage := make(map[string]interface{})
  680. //
  681. inputMessage["cardArea"] = "440300" // 发卡地行政区划代码
  682. inputMessage["extendDeviceId"] = ""
  683. inputMessage["extendSerialNumber"] = ""
  684. inputMessage["extendUserId"] = ""
  685. inputMessage["hospitalCode"] = fixmedins_code // 协议机构编码
  686. inputMessage["operatorCode"] = doctor_code // 操作员编码
  687. inputMessage["operatorName"] = doctor // 操作员名字
  688. inputMessage["operatorPass"] = "" // 定点协议机构操作人员编码
  689. inputMessage["serialNumber"] = fixmedins_code + year + month + day +
  690. fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  691. //inputMessage["serialNumber"] = "G554020210406" + fmt.Sprintf("%07v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(10000000)) // 定点协议机构编码(5位)+日期(8位)+流水号(7位)
  692. inputMessage["verifyCode"] = "000000|8ec5b7745a5cc45b631f23b4bf1e417e"
  693. inputMessage["transReturnCode"] = "" //
  694. inputMessage["transReturnMessage"] = "" //
  695. inputMessage["transTime"] = year + month + day + hour + min + sec + ":" + msec //
  696. inputMessage["transVersion"] = "V0.2" // //
  697. inputMessage["transChannel"] = "10" //
  698. return inputMessage
  699. }
  700. func SzybML009(doctor string, doctor_code string, fixmedins_code string, pro *models.MyHisProject) string {
  701. //timeLayout := "20060102"
  702. //record_date := time.Unix(pro.RecordDate, 0).Format(timeLayout)
  703. //recordDate, _ := strconv.ParseInt(record_date, 10, 64)
  704. //生成输入报文
  705. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  706. month := time.Unix(1557042972, 0).Format("1")
  707. year := time.Now().Format("2006")
  708. month = time.Now().Format("01")
  709. day := time.Now().Format("02")
  710. inputData := make(map[string]interface{})
  711. inputData["listsize"] = 1
  712. inputMessage["transType"] = "ML009" // 交易编码
  713. feedetail := make([]map[string]interface{}, 0)
  714. feedetailInfo := make(map[string]interface{})
  715. feedetailInfo["ake001"] = pro.MedicalCode //社保目录编码
  716. feedetailInfo["ake005"] = pro.MedicalCode //协议机构内部目录编码
  717. feedetailInfo["ake006"] = pro.ProjectName // 协议机构内部目录名称
  718. feedetailInfo["bkf131"] = pro.Category //协议机构项目类别
  719. feedetailInfo["bkm062"] = strconv.FormatInt(pro.SpecailProject, 10) // 门诊特检项目标识
  720. feedetailInfo["bka506"] = pro.Price // 协议机构内部项目收费价格
  721. feedetailInfo["aae030"] = year + month + day // 备案日期
  722. feedetailInfo["aae013"] = pro.Remark // 备注
  723. feedetail = append(feedetail, feedetailInfo)
  724. inputData["inputlist"] = feedetail
  725. inputMessage["transBody"] = inputData
  726. bytesData, err := json.Marshal(inputMessage)
  727. fmt.Println(string(bytesData))
  728. if err != nil {
  729. fmt.Println(err.Error())
  730. return err.Error()
  731. }
  732. reader := bytes.NewReader(bytesData)
  733. url := beego.AppConfig.String("url")
  734. request, err := http.NewRequest("POST", url, reader)
  735. if err != nil {
  736. fmt.Println(err.Error())
  737. return err.Error()
  738. }
  739. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  740. client := http.Client{}
  741. resp, err := client.Do(request)
  742. if err != nil {
  743. fmt.Println(err.Error())
  744. return err.Error()
  745. }
  746. respBytes, err := ioutil.ReadAll(resp.Body)
  747. if err != nil {
  748. fmt.Println(err.Error())
  749. return err.Error()
  750. }
  751. fmt.Println(string(respBytes))
  752. str := string(respBytes)
  753. return str
  754. }
  755. //func SzybML009(doctor string, doctor_code string, fixmedins_code string, datas []*models.ProjectDetail) string {
  756. // //生成输入报文
  757. // inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  758. //
  759. // inputData := make(map[string]interface{})
  760. //
  761. // inputData["listsize"] = len(datas)
  762. // inputMessage["transType"] = "ML009" // 交易编码
  763. // feedetail := make([]map[string]interface{}, 0)
  764. //
  765. // for _, item := range datas {
  766. // feedetailInfo := make(map[string]interface{})
  767. // feedetailInfo["ake001"] = item.SocialSecurityDirectoryCode //社保目录编码
  768. // feedetailInfo["ake005"] = item.SocialSecurityDirectoryCode //协议机构内部目录编码
  769. // feedetailInfo["ake006"] = item.ProjectName // 协议机构内部目录名称
  770. // feedetailInfo["bkf131"] = item.Category //协议机构项目类别
  771. // feedetailInfo["bkm062"] = "0" // 门诊特检项目标识
  772. // feedetailInfo["bka506"] = item.Price // 协议机构内部项目收费价格
  773. // feedetailInfo["aae030"] = 20210407 // 备案日期
  774. // feedetailInfo["aae013"] = item.Remark // 备注
  775. // feedetail = append(feedetail, feedetailInfo)
  776. // }
  777. // fmt.Println("feeedDetal2333333333", feedetail)
  778. // inputData["inputlist"] = feedetail
  779. // inputMessage["transBody"] = inputData
  780. //
  781. // bytesData, err := json.Marshal(inputMessage)
  782. // fmt.Println(string(bytesData))
  783. // if err != nil {
  784. // fmt.Println(err.Error())
  785. // return err.Error()
  786. // }
  787. // reader := bytes.NewReader(bytesData)
  788. // //url := "http://192.168.1.99:10000"
  789. // url := "http://192.168.1.228:17001/szsi-portal/transData"
  790. //
  791. // request, err := http.NewRequest("POST", url, reader)
  792. // if err != nil {
  793. // fmt.Println(err.Error())
  794. // return err.Error()
  795. // }
  796. //
  797. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  798. //
  799. // client := http.Client{}
  800. // resp, err := client.Do(request)
  801. // if err != nil {
  802. // fmt.Println(err.Error())
  803. // return err.Error()
  804. // }
  805. // respBytes, err := ioutil.ReadAll(resp.Body)
  806. // if err != nil {
  807. // fmt.Println(err.Error())
  808. // return err.Error()
  809. // }
  810. // fmt.Println(string(respBytes))
  811. // str := string(respBytes)
  812. // return str
  813. //
  814. //}
  815. func SzybML010(doctor string, doctor_code string, fixmedins_code string, datas []*models.DrugDetail, typeId int64) string {
  816. //生成输入报文
  817. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  818. inputData := make(map[string]interface{})
  819. inputData["listsize"] = len(datas)
  820. inputMessage["transType"] = "ML010" // 交易编码
  821. feedetail := make([]map[string]interface{}, 0)
  822. for _, item := range datas {
  823. feedetailInfo := make(map[string]interface{})
  824. feedetailInfo["ake003"] = strconv.FormatInt(typeId, 10)
  825. feedetailInfo["ake001"] = item.SocialSecurityDirectoryCode //社保目录编码
  826. feedetailInfo["ake005"] = item.SocialSecurityDirectoryCode //协议机构内部目录编码
  827. feedetail = append(feedetail, feedetailInfo)
  828. }
  829. inputData["inputlist"] = feedetail
  830. inputMessage["transBody"] = inputData
  831. bytesData, err := json.Marshal(inputMessage)
  832. fmt.Println(string(bytesData))
  833. if err != nil {
  834. fmt.Println(err.Error())
  835. return err.Error()
  836. }
  837. reader := bytes.NewReader(bytesData)
  838. url := beego.AppConfig.String("url")
  839. request, err := http.NewRequest("POST", url, reader)
  840. if err != nil {
  841. fmt.Println(err.Error())
  842. return err.Error()
  843. }
  844. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  845. client := http.Client{}
  846. resp, err := client.Do(request)
  847. if err != nil {
  848. fmt.Println(err.Error())
  849. return err.Error()
  850. }
  851. respBytes, err := ioutil.ReadAll(resp.Body)
  852. if err != nil {
  853. fmt.Println(err.Error())
  854. return err.Error()
  855. }
  856. fmt.Println(string(respBytes))
  857. str := string(respBytes)
  858. return str
  859. }
  860. func SzybYS001(doctor string, doctor_code string, fixmedins_code string, doc *models.DocDetail) string {
  861. //生成输入报文
  862. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  863. inputData := make(map[string]interface{})
  864. inputData["listsize"] = 1
  865. inputMessage["transType"] = "YS001" // 交易编码
  866. feedetail := make([]map[string]interface{}, 0)
  867. feedetailInfo := make(map[string]interface{})
  868. feedetailInfo["aac003"] = doc.UserName //医护人员姓名
  869. feedetailInfo["bka633"] = "1" //医护人员类别
  870. feedetailInfo["aac004"] = doc.Sex //性别
  871. switch doc.CardType {
  872. }
  873. if doc.CardType == "1" {
  874. feedetailInfo["aac058"] = "01"
  875. } else if doc.CardType == "2" {
  876. feedetailInfo["aac058"] = "02"
  877. } else if doc.CardType == "4" {
  878. feedetailInfo["aac058"] = "04"
  879. } else if doc.CardType == "6" {
  880. feedetailInfo["aac058"] = "06"
  881. } else if doc.CardType == "8" {
  882. feedetailInfo["aac058"] = "08"
  883. } else if doc.CardType == "90" {
  884. feedetailInfo["aac058"] = "90"
  885. }
  886. feedetailInfo["aac147"] = doc.IdCard //证件号码
  887. feedetailInfo["aae005"] = doc.Phone //联系电话
  888. feedetailInfo["bkc322"] = doc.WorkMajorName //现从事专业名称
  889. feedetailInfo["aac005"] = doc.Nation //民族
  890. feedetailInfo["aac006"] = doc.BirthDay //出生日期
  891. feedetailInfo["aac007"] = doc.WorkTime //参加工作日期
  892. feedetailInfo["aac011"] = doc.Education //学历
  893. feedetailInfo["aac183"] = doc.StudyMajorName //所学的专业名称
  894. feedetailInfo["bkc323"] = doc.CertificateCode //医(药)师执业证书编码
  895. feedetailInfo["bke955"] = doc.MedicalCode //医(药)师资格证编码
  896. feedetailInfo["akc055"] = doc.MedicalRangeCode // 医师执业范围代码
  897. feedetailInfo["bcc950"] = doc.MedicalLevel //医生执业资格证中的医师级别
  898. feedetailInfo["bcc955"] = doc.TypeJob //医生执业资格证中的执业类别
  899. feedetailInfo["bka503"] = doc.DoctorNumber //医保医师编号
  900. feedetailInfo["bkc324"] = doc.Licensing //多点执业标志
  901. feedetailInfo["bkc326"] = doc.DoctorServiceStatus //医师医保服务资格状态
  902. feedetailInfo["bkc328"] = doc.MonitoringLevel //监控等级
  903. feedetailInfo["bkc329"] = doc.DrugPsychotropicSubstances //毒麻精神药品资格
  904. feedetailInfo["bke801"] = doc.HealthCareCode //母婴保健技术考核合格证书编号
  905. feedetailInfo["bkc330"] = doc.PlanningTechnicalServiceCode //bkc330 计划生育技术服务人员合格证编号
  906. feedetailInfo["bkc332"] = doc.PharmacistType //药师类别
  907. feedetailInfo["bkc333"] = doc.PharmacistPracticeCategory //药师执业类别
  908. feedetailInfo["bkc334"] = doc.PharmacistsLicensing //药师执业范围
  909. feedetailInfo["bkc335"] = doc.PharmacistRegistrationNumber //执业药师注册证编号
  910. feedetailInfo["akf001"] = doc.OfficeCode //所属科室编码
  911. feedetailInfo["acc501"] = doc.JobNumber //工号
  912. feedetailInfo["ahc451"] = doc.PostName //职务名称
  913. feedetailInfo["aaf009"] = doc.TechnicalJobLevelCode //专业技术职务级别编码
  914. feedetailInfo["bkc321"] = doc.IsActive //在职与否
  915. feedetailInfo["ckc302"] = doc.PrescriptionQualificationIdentification //处方资格标识
  916. feedetailInfo["bkc325"] = doc.IdentificationOutpatients //门诊大病医师 标识
  917. feedetailInfo["ckc304"] = doc.OutpatientIllnessCategory //门诊大病类别
  918. feedetailInfo["aae030"] = doc.StartTime //开始日期
  919. feedetail = append(feedetail, feedetailInfo)
  920. inputData["inputlist"] = feedetail
  921. inputMessage["transBody"] = inputData
  922. bytesData, err := json.Marshal(inputMessage)
  923. fmt.Println(string(bytesData))
  924. if err != nil {
  925. fmt.Println(err.Error())
  926. return err.Error()
  927. }
  928. reader := bytes.NewReader(bytesData)
  929. url := beego.AppConfig.String("url")
  930. request, err := http.NewRequest("POST", url, reader)
  931. if err != nil {
  932. fmt.Println(err.Error())
  933. return err.Error()
  934. }
  935. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  936. client := http.Client{}
  937. resp, err := client.Do(request)
  938. if err != nil {
  939. fmt.Println(err.Error())
  940. return err.Error()
  941. }
  942. respBytes, err := ioutil.ReadAll(resp.Body)
  943. if err != nil {
  944. fmt.Println(err.Error())
  945. return err.Error()
  946. }
  947. fmt.Println(string(respBytes))
  948. str := string(respBytes)
  949. return str
  950. }
  951. //func SzybYS001(doctor string, doctor_code string, fixmedins_code string, datas []*models.DocDetail) string {
  952. // //生成输入报文
  953. // inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  954. //
  955. // inputData := make(map[string]interface{})
  956. //
  957. // inputData["listsize"] = len(datas)
  958. // inputMessage["transType"] = "YS001" // 交易编码
  959. // feedetail := make([]map[string]interface{}, 0)
  960. //
  961. // for _, item := range datas {
  962. // fmt.Println("item222222", item.RoleId)
  963. // feedetailInfo := make(map[string]interface{})
  964. // feedetailInfo["aac003"] = item.UserName
  965. // feedetailInfo["bka633"] = "1"
  966. // feedetailInfo["aac004"] = item.Sex
  967. // feedetailInfo["aac058"] = item.CardType
  968. // feedetailInfo["aac147"] = item.IdCard
  969. // feedetailInfo["aae005"] = item.Phone
  970. // feedetailInfo["bkc322"] = item.WorkMajorName
  971. // feedetailInfo["aac005"] = item.Nation
  972. // feedetailInfo["aac006"] = item.BirthDay
  973. // feedetailInfo["aac007"] = item.WorkTime
  974. // feedetailInfo["aac011"] = item.Education
  975. // feedetailInfo["aac183"] = item.StudyMajorName
  976. // feedetailInfo["bkc323"] = item.CertificateCode
  977. // feedetailInfo["bke955"] = item.MedicalCode
  978. // feedetailInfo["akc055"] = item.MedicalRangeCode
  979. // feedetailInfo["bcc950"] = item.MedicalLevel
  980. // feedetailInfo["bcc955"] = item.TypeJob
  981. // feedetailInfo["bka503"] = item.DoctorNumber
  982. // feedetailInfo["bkc324"] = item.Licensing
  983. // feedetailInfo["bkc326"] = item.DoctorServiceStatus
  984. // feedetailInfo["bkc328"] = item.MonitoringLevel
  985. // feedetailInfo["bkc329"] = item.DrugPsychotropicSubstances
  986. // feedetailInfo["bke801"] = item.HealthCareCode
  987. // feedetailInfo["bkc330"] = item.PlanningTechnicalServiceCode
  988. // feedetailInfo["bkc332"] = item.PharmacistType
  989. // feedetailInfo["bkc333"] = item.PharmacistPracticeCategory
  990. // feedetailInfo["bkc334"] = item.PharmacistsLicensing
  991. // feedetailInfo["bkc335"] = item.PharmacistRegistrationNumber
  992. // feedetailInfo["akf001"] = item.OfficeCode
  993. // feedetailInfo["acc501"] = item.JobNumber
  994. // feedetailInfo["ahc451"] = item.PostName
  995. // feedetailInfo["aaf009"] = item.TechnicalJobLevelCode
  996. // feedetailInfo["bkc321"] = item.IsActive
  997. // feedetailInfo["ckc302"] = item.PrescriptionQualificationIdentification
  998. // feedetailInfo["bkc325"] = item.IdentificationOutpatients
  999. // feedetailInfo["ckc304"] = item.OutpatientIllnessCategory
  1000. // feedetailInfo["aae030"] = item.StartTime
  1001. // feedetail = append(feedetail, feedetailInfo)
  1002. // }
  1003. //
  1004. // inputData["inputlist"] = feedetail
  1005. // inputMessage["transBody"] = inputData
  1006. //
  1007. // bytesData, err := json.Marshal(inputMessage)
  1008. // fmt.Println(string(bytesData))
  1009. // if err != nil {
  1010. // fmt.Println(err.Error())
  1011. // return err.Error()
  1012. // }
  1013. // reader := bytes.NewReader(bytesData)
  1014. // //url := "http://192.168.1.99:10000"
  1015. // url := "http://192.168.1.228:17001/szsi-portal/transData"
  1016. //
  1017. // request, err := http.NewRequest("POST", url, reader)
  1018. // if err != nil {
  1019. // fmt.Println(err.Error())
  1020. // return err.Error()
  1021. // }
  1022. //
  1023. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1024. //
  1025. // client := http.Client{}
  1026. // resp, err := client.Do(request)
  1027. // if err != nil {
  1028. // fmt.Println(err.Error())
  1029. // return err.Error()
  1030. // }
  1031. // respBytes, err := ioutil.ReadAll(resp.Body)
  1032. // if err != nil {
  1033. // fmt.Println(err.Error())
  1034. // return err.Error()
  1035. // }
  1036. // fmt.Println(string(respBytes))
  1037. // str := string(respBytes)
  1038. // return str
  1039. //
  1040. //}
  1041. func SzybYS002(doctor string, doctor_code string, fixmedins_code string, datas *models.DocDetail) string {
  1042. //生成输入报文
  1043. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  1044. inputData := make(map[string]interface{})
  1045. inputData["listsize"] = 1
  1046. inputMessage["transType"] = "YS002" // 交易编码
  1047. feedetail := make([]map[string]interface{}, 0)
  1048. feedetailInfo := make(map[string]interface{})
  1049. feedetailInfo["bkc320"] = datas.DoctorNumber
  1050. feedetailInfo["bke155"] = "4"
  1051. feedetail = append(feedetail, feedetailInfo)
  1052. inputData["inputlist"] = feedetail
  1053. inputMessage["transBody"] = inputData
  1054. bytesData, err := json.Marshal(inputMessage)
  1055. fmt.Println(string(bytesData))
  1056. if err != nil {
  1057. fmt.Println(err.Error())
  1058. return err.Error()
  1059. }
  1060. reader := bytes.NewReader(bytesData)
  1061. url := beego.AppConfig.String("url")
  1062. request, err := http.NewRequest("POST", url, reader)
  1063. if err != nil {
  1064. fmt.Println(err.Error())
  1065. return err.Error()
  1066. }
  1067. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1068. client := http.Client{}
  1069. resp, err := client.Do(request)
  1070. if err != nil {
  1071. fmt.Println(err.Error())
  1072. return err.Error()
  1073. }
  1074. respBytes, err := ioutil.ReadAll(resp.Body)
  1075. if err != nil {
  1076. fmt.Println(err.Error())
  1077. return err.Error()
  1078. }
  1079. fmt.Println(string(respBytes))
  1080. str := string(respBytes)
  1081. return str
  1082. }
  1083. func SzybYS003(doctor string, doctor_code string, fixmedins_code string, datas []*models.DocDetail) string {
  1084. //生成输入报文
  1085. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  1086. inputData := make(map[string]interface{})
  1087. inputData["listsize"] = len(datas)
  1088. inputMessage["transType"] = "YS003" // 交易编码
  1089. feedetail := make([]map[string]interface{}, 0)
  1090. for _, item := range datas {
  1091. feedetailInfo := make(map[string]interface{})
  1092. feedetailInfo["bkc320"] = item.StaffCode
  1093. feedetailInfo["aac003"] = item.UserName
  1094. feedetailInfo["bka633"] = item.RoleId
  1095. feedetailInfo["aac004"] = item.Sex
  1096. feedetailInfo["aac058"] = item.CardType
  1097. feedetailInfo["aac147"] = item.IdCard
  1098. feedetailInfo["aae005"] = item.Phone
  1099. feedetailInfo["bkc322"] = item.WorkMajorName
  1100. feedetailInfo["aac005"] = item.Nation
  1101. feedetailInfo["aac006"] = item.BirthDay
  1102. feedetailInfo["aac007"] = item.WorkTime
  1103. feedetailInfo["aac011"] = item.Education
  1104. feedetailInfo["aac183"] = item.StudyMajorName
  1105. feedetailInfo["bkc323"] = item.CertificateCode
  1106. feedetailInfo["bke955"] = item.MedicalCode
  1107. feedetailInfo["akc055"] = item.MedicalRangeCode
  1108. feedetailInfo["bcc950"] = item.MedicalLevel
  1109. feedetailInfo["bcc955"] = item.TypeJob
  1110. feedetailInfo["bka503"] = item.DoctorNumber
  1111. feedetailInfo["bkc324"] = item.Licensing
  1112. feedetailInfo["bkc326"] = item.DoctorServiceStatus
  1113. feedetailInfo["bkc328"] = item.MonitoringLevel
  1114. feedetailInfo["bkc329"] = item.DrugPsychotropicSubstances
  1115. feedetailInfo["bke801"] = item.HealthCareCode
  1116. feedetailInfo["bkc330"] = item.PlanningTechnicalServiceCode
  1117. feedetailInfo["bkc332"] = item.PharmacistType
  1118. feedetailInfo["bkc333"] = item.PharmacistPracticeCategory
  1119. feedetailInfo["bkc334"] = item.PharmacistsLicensing
  1120. feedetailInfo["bkc335"] = item.PharmacistRegistrationNumber
  1121. feedetailInfo["akf001"] = item.OfficeCode
  1122. feedetailInfo["acc501"] = item.JobNumber
  1123. feedetailInfo["ahc451"] = item.PostName
  1124. feedetailInfo["aaf009"] = item.TechnicalJobLevelCode
  1125. feedetailInfo["bkc321"] = item.IsActive
  1126. feedetailInfo["ckc302"] = item.PrescriptionQualificationIdentification
  1127. feedetailInfo["bkc325"] = item.IdentificationOutpatients
  1128. feedetailInfo["ckc304"] = item.OutpatientIllnessCategory
  1129. feedetailInfo["aae030"] = item.StartTime
  1130. feedetailInfo["aae031"] = item.EndTime
  1131. feedetail = append(feedetail, feedetailInfo)
  1132. }
  1133. inputData["inputlist"] = feedetail
  1134. inputMessage["transBody"] = inputData
  1135. bytesData, err := json.Marshal(inputMessage)
  1136. fmt.Println(string(bytesData))
  1137. if err != nil {
  1138. fmt.Println(err.Error())
  1139. return err.Error()
  1140. }
  1141. reader := bytes.NewReader(bytesData)
  1142. url := beego.AppConfig.String("url")
  1143. request, err := http.NewRequest("POST", url, reader)
  1144. if err != nil {
  1145. fmt.Println(err.Error())
  1146. return err.Error()
  1147. }
  1148. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1149. client := http.Client{}
  1150. resp, err := client.Do(request)
  1151. if err != nil {
  1152. fmt.Println(err.Error())
  1153. return err.Error()
  1154. }
  1155. respBytes, err := ioutil.ReadAll(resp.Body)
  1156. if err != nil {
  1157. fmt.Println(err.Error())
  1158. return err.Error()
  1159. }
  1160. fmt.Println(string(respBytes))
  1161. str := string(respBytes)
  1162. return str
  1163. }
  1164. func SzybYML007(doctor string, doctor_code string, fixmedins_code string, infor *models.XtGoodInformation) string {
  1165. //生成输入报文
  1166. inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  1167. inputData := make(map[string]interface{})
  1168. inputData["listsize"] = 1
  1169. inputMessage["transType"] = "ML007" // 交易编码
  1170. feedetail := make([]map[string]interface{}, 0)
  1171. feedetailInfo := make(map[string]interface{})
  1172. feedetailInfo["ake001"] = infor.SocialSecurityDirectoryCode // 社保目录编码
  1173. feedetailInfo["ake005"] = infor.SocialSecurityDirectoryCode //协议机构内部目录编码
  1174. feedetailInfo["ake006"] = infor.GoodName //医药机构内部目录名称
  1175. feedetailInfo["bka053"] = infor.ManufacturerName //生产厂家
  1176. feedetailInfo["ake004"] = infor.ProductionType //生产地类别
  1177. feedetailInfo["ckf261"] = infor.SpecialMedical //特殊医用材料标识
  1178. feedetailInfo["aka067"] = "支" //计价单位
  1179. feedetailInfo["aka074"] = infor.SpecificationName //规格
  1180. feedetailInfo["bka505"] = infor.BuyPrice //进货价
  1181. feedetailInfo["bka506"] = infor.SellPrice // 收获价
  1182. feedetailInfo["aae013"] = infor.Remark //备注
  1183. feedetail = append(feedetail, feedetailInfo)
  1184. inputData["inputlist"] = feedetail
  1185. inputMessage["transBody"] = inputData
  1186. bytesData, err := json.Marshal(inputMessage)
  1187. fmt.Println(string(bytesData))
  1188. if err != nil {
  1189. fmt.Println(err.Error())
  1190. return err.Error()
  1191. }
  1192. reader := bytes.NewReader(bytesData)
  1193. url := beego.AppConfig.String("url")
  1194. request, err := http.NewRequest("POST", url, reader)
  1195. if err != nil {
  1196. fmt.Println(err.Error())
  1197. return err.Error()
  1198. }
  1199. request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1200. client := http.Client{}
  1201. resp, err := client.Do(request)
  1202. if err != nil {
  1203. fmt.Println(err.Error())
  1204. return err.Error()
  1205. }
  1206. respBytes, err := ioutil.ReadAll(resp.Body)
  1207. if err != nil {
  1208. fmt.Println(err.Error())
  1209. return err.Error()
  1210. }
  1211. fmt.Println(string(respBytes))
  1212. str := string(respBytes)
  1213. return str
  1214. }
  1215. //func SzybYML007(doctor string, doctor_code string, fixmedins_code string, datas []*models.GoodDetail) string {
  1216. //
  1217. // //生成输入报文
  1218. // inputMessage := SetSZDrugMessage(doctor, doctor_code, fixmedins_code)
  1219. //
  1220. // inputData := make(map[string]interface{})
  1221. //
  1222. // inputData["listsize"] = len(datas)
  1223. // inputMessage["transType"] = "ML007" // 交易编码
  1224. // feedetail := make([]map[string]interface{}, 0)
  1225. //
  1226. // for _, item := range datas {
  1227. // fmt.Println("item222222222", item.BuyPrice)
  1228. // feedetailInfo := make(map[string]interface{})
  1229. // feedetailInfo["ake001"] = item.SocialSecurityDirectoryCode // 社保目录编码
  1230. // //feedetailInfo["ake001"] = "3333333333" // 社保目录编码
  1231. // feedetailInfo["ake005"] = item.SocialSecurityDirectoryCode //协议机构内部目录编码
  1232. // //feedetailInfo["ake006"] = item.GoodName //医药机构内部目录名称
  1233. // feedetailInfo["ake006"] = "222222" //医药机构内部目录名称
  1234. // feedetailInfo["bka053"] = item.ManufacturerName //生产厂家
  1235. // feedetailInfo["ake004"] = "1" //生产地类别
  1236. // feedetailInfo["ckf261"] = "1" //特殊医用材料标识
  1237. // feedetailInfo["aka067"] = "支" //计价单位
  1238. // feedetailInfo["aka074"] = "ftp" //规格
  1239. // feedetailInfo["bka505"] = item.BuyPrice //进货价
  1240. // feedetailInfo["bka506"] = item.SellPrice // 收获价
  1241. // feedetailInfo["aae013"] = item.Remark //备注
  1242. // feedetail = append(feedetail, feedetailInfo)
  1243. // }
  1244. //
  1245. // inputData["inputlist"] = feedetail
  1246. // inputMessage["transBody"] = inputData
  1247. //
  1248. // bytesData, err := json.Marshal(inputMessage)
  1249. // fmt.Println(string(bytesData))
  1250. // if err != nil {
  1251. // fmt.Println(err.Error())
  1252. // return err.Error()
  1253. // }
  1254. // reader := bytes.NewReader(bytesData)
  1255. // //url := "http://192.168.1.99:10000"
  1256. // url := "http://192.168.1.228:17001/szsi-portal/transData"
  1257. //
  1258. // request, err := http.NewRequest("POST", url, reader)
  1259. // if err != nil {
  1260. // fmt.Println(err.Error())
  1261. // return err.Error()
  1262. // }
  1263. //
  1264. // request.Header.Set("Content-Type", "application/json;charset=UTF-8")
  1265. //
  1266. // client := http.Client{}
  1267. // resp, err := client.Do(request)
  1268. // if err != nil {
  1269. // fmt.Println(err.Error())
  1270. // return err.Error()
  1271. // }
  1272. // respBytes, err := ioutil.ReadAll(resp.Body)
  1273. // if err != nil {
  1274. // fmt.Println(err.Error())
  1275. // return err.Error()
  1276. // }
  1277. // fmt.Println(string(respBytes))
  1278. // str := string(respBytes)
  1279. // return str
  1280. //}
  1281. func GetDoseCode(dose_id int64, user_org_id int64) (error, string) {
  1282. var data models.DictDataconfig
  1283. err := readDb.Model(&models.DictDataconfig{}).Where(" (org_id = ? Or org_id = 0) AND parent_id = 4 AND module = 'system' AND status = 1 AND value = ?", user_org_id, dose_id).First(&data).Error
  1284. return err, data.Code
  1285. }
  1286. func UpdataOrderStatusSZ(id int64, number string, user_org_id int64) (err error) {
  1287. err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0}).Error
  1288. err = writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"order_status": 1, "mtime": time.Now().Unix()}).Error
  1289. err = writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND batch_number = ? AND user_org_id = ?", number, user_org_id).Updates(map[string]interface{}{"prescription_status": 1, "mtime": time.Now().Unix()}).Error
  1290. return
  1291. }
  1292. func UpdataHisStatusSZ(user_org_id int64, his_mz_number string, his_number string, result string, his_patient_id int64) (err error) {
  1293. err = writeDb.Model(&models.HisPatient{}).Where("status = 1 AND user_org_id = ? AND mz_number = ? AND number = ?", user_org_id, his_mz_number, his_number).Updates(map[string]interface{}{"status": 0, "mtime": time.Now().Unix(), "refund_detail": result}).Error
  1294. writeDb.Model(&models.HisPrescription{}).Where("status = 1 AND user_org_id = ? AND his_patient_id = ?", user_org_id, his_patient_id).Updates(map[string]interface{}{"his_patient_id": 0, "mtime": time.Now().Unix()})
  1295. writeDb.Model(&models.HisPrescriptionInfo{}).Where("status = 1 AND user_org_id = ? AND his_patient_id = ?", user_org_id, his_patient_id).Updates(map[string]interface{}{"his_patient_id": 0, "mtime": time.Now().Unix()})
  1296. return
  1297. }
  1298. func UpdataOrderlog(id int64, user_org_id int64, refund_log string) (err error) {
  1299. err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"order_status": 3, "mtime": time.Now().Unix(), "status": 0, "refund_log": refund_log}).Error
  1300. return
  1301. }
  1302. func UpdateBaseDrugById(id int64) (models.XtBaseDrug, error) {
  1303. drug := models.XtBaseDrug{}
  1304. err := XTWriteDB().Model(&drug).Where("id = ?", id).Updates(map[string]interface{}{"is_mark": 1}).Error
  1305. return drug, err
  1306. }
  1307. func UpdateDrugByIdDetail(id int64) (models.XtBaseDrug, error) {
  1308. drug := models.XtBaseDrug{}
  1309. err := XTWriteDB().Model(&drug).Where("id = ?", id).Updates(map[string]interface{}{"is_mark": 0}).Error
  1310. return drug, err
  1311. }
  1312. func UpdateGoodInformaitonByDetail(id int64) (models.MyGoodInformation, error) {
  1313. information := models.MyGoodInformation{}
  1314. err := XTWriteDB().Model(&information).Where("id=?", id).Updates(map[string]interface{}{"is_mark": 1}).Error
  1315. return information, err
  1316. }
  1317. func UpdateGoodInfoById(id int64) (models.MyGoodInformation, error) {
  1318. information := models.MyGoodInformation{}
  1319. err := XTWriteDB().Model(&information).Where("id=?", id).Updates(map[string]interface{}{"is_mark": 0}).Error
  1320. return information, err
  1321. }
  1322. func UpdateProjectById(id int64) (models.MyHisProject, error) {
  1323. project := models.MyHisProject{}
  1324. err := XTWriteDB().Model(&project).Where("id = ?", id).Updates(map[string]interface{}{"is_mark": 1}).Error
  1325. return project, err
  1326. }
  1327. func UpdateMyProjectById(id int64) (models.MyHisProject, error) {
  1328. project := models.MyHisProject{}
  1329. err := XTWriteDB().Model(&project).Where("id = ?", id).Updates(map[string]interface{}{"is_mark": 0}).Error
  1330. return project, err
  1331. }
  1332. func UpdateAdminUserRoleById(id int64, orgid int64) (models.MySgjUserAdminRole, error) {
  1333. role := models.MySgjUserAdminRole{}
  1334. err = UserWriteDB().Model(&role).Where("admin_user_id = ? and org_id = ?", id, orgid).Updates(map[string]interface{}{"is_mark = ?": 1}).Error
  1335. return role, err
  1336. }
  1337. func UpdataOrderInfoStatus(id int64, number string, user_org_id int64) {
  1338. err = writeDb.Model(&models.HisOrder{}).Where("status = 1 AND id = ? AND user_org_id = ?", id, user_org_id).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
  1339. err = writeDb.Model(&models.HisOrderInfo{}).Where("status = 1 AND user_org_id = ? AND order_number = ?", user_org_id, number).Updates(map[string]interface{}{"mtime": time.Now().Unix(), "status": 0}).Error
  1340. return
  1341. }