main_test.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. package idc_test
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "testing"
  6. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk"
  7. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/idc"
  8. "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/utils"
  9. )
  10. func TestList(t *testing.T) {
  11. t.Run("test", func(t *testing.T) {
  12. sdk.InitConfig(&sdk.ClientConfig{
  13. ApiDomain: "https://mcapi.mdfitnesscao.com",
  14. AppDebug: true,
  15. })
  16. var jsonStr = `
  17. {
  18. "result":{
  19. "assessmentDate":"2023-09-18",
  20. "calErr":null,
  21. "debugInfo":null,
  22. "examDate":1693152000,
  23. "majorDisease":[
  24. {
  25. "name":"乳腺癌",
  26. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  27. "notificationTime":"365",
  28. "recommendItems":["乳腺彩超"],
  29. "riskDegree":1,
  30. "riskDesc":"低风险",
  31. "classification":1,
  32. "department":["乳腺外科"],
  33. "followUpTime":"每年",
  34. "abnormalDatas":null,
  35. "knownFactors":[
  36. {
  37. "diseaseRelationName":[
  38. "双侧乳腺囊性占位性病变",
  39. "C-BI-RADS分类:2类"
  40. ],
  41. "itemName":"乳房",
  42. "mark":1,
  43. "value":[
  44. "双侧乳腺囊性占位性病变",
  45. "C-BI-RADS分类:2类"
  46. ]
  47. }
  48. ],
  49. "medDatas":null
  50. },
  51. {
  52. "name":"肺癌",
  53. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  54. "notificationTime":"365",
  55. "recommendItems":["胸部CT"],
  56. "riskDegree":0,
  57. "riskDesc":"无法评估",
  58. "classification":1,
  59. "department":["呼吸内科"],
  60. "followUpTime":"近期",
  61. "abnormalDatas":null,
  62. "knownFactors":null,
  63. "medDatas":null
  64. },
  65. {
  66. "name":"结直肠癌",
  67. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  68. "notificationTime":"365",
  69. "recommendItems":["肠镜","粪便隐血试验"],
  70. "riskDegree":0,
  71. "riskDesc":"无法评估",
  72. "classification":1,
  73. "department":["消化内科"],
  74. "followUpTime":"近期",
  75. "abnormalDatas":null,
  76. "knownFactors":null,
  77. "medDatas":null
  78. },
  79. {
  80. "name":"甲状腺癌",
  81. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  82. "notificationTime":"365",
  83. "recommendItems":["甲状腺功能"],
  84. "riskDegree":0,
  85. "riskDesc":"无法评估",
  86. "classification":1,
  87. "department":["内分泌科"],
  88. "followUpTime":"近期",
  89. "abnormalDatas":null,
  90. "knownFactors":null,
  91. "medDatas":null
  92. },
  93. {
  94. "name":"胃癌",
  95. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  96. "notificationTime":"365",
  97. "recommendItems":["胃镜"],
  98. "riskDegree":0,
  99. "riskDesc":"无法评估",
  100. "classification":1,
  101. "department":["消化内科"],
  102. "followUpTime":"近期",
  103. "abnormalDatas":null,
  104. "knownFactors":null,
  105. "medDatas":null
  106. },
  107. {
  108. "name":"宫颈癌",
  109. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  110. "notificationTime":"365",
  111. "recommendItems":["TCT检查","HPV检查"],
  112. "riskDegree":1,
  113. "riskDesc":"低风险",
  114. "classification":1,
  115. "department":["妇科"],
  116. "followUpTime":"每年",
  117. "abnormalDatas":null,
  118. "knownFactors":[
  119. {
  120. "diseaseRelationName":[
  121. "宫颈潴留囊肿"
  122. ],
  123. "itemName":"宫颈",
  124. "mark":1,
  125. "value":[
  126. "宫颈潴留囊肿"
  127. ]
  128. }
  129. ],
  130. "medDatas":null
  131. },
  132. {
  133. "name":"肝癌",
  134. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  135. "notificationTime":"365",
  136. "recommendItems":["肝脏彩超/腹部彩超"],
  137. "riskDegree":1,
  138. "riskDesc":"低风险",
  139. "classification":1,
  140. "department":["消化内科"],
  141. "followUpTime":"每年",
  142. "abnormalDatas":null,
  143. "knownFactors":null,
  144. "medDatas":null
  145. },
  146. {
  147. "name":"子宫内膜癌",
  148. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  149. "notificationTime":"365",
  150. "recommendItems":["子宫附件彩超"],
  151. "riskDegree":1,
  152. "riskDesc":"低风险",
  153. "classification":1,
  154. "department":["妇科"],
  155. "followUpTime":"每年",
  156. "abnormalDatas":null,
  157. "knownFactors":null,
  158. "medDatas":null
  159. },
  160. {
  161. "name":"食管癌",
  162. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  163. "notificationTime":"365",
  164. "recommendItems":["食管内镜/胃镜"],
  165. "riskDegree":0,
  166. "riskDesc":"无法评估",
  167. "classification":1,
  168. "department":["消化内科"],
  169. "followUpTime":"近期",
  170. "abnormalDatas":null,
  171. "knownFactors":null,
  172. "medDatas":null
  173. },
  174. {
  175. "name":"卵巢癌",
  176. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  177. "notificationTime":"365",
  178. "recommendItems":["子宫附件彩超"],
  179. "riskDegree":1,
  180. "riskDesc":"低风险",
  181. "classification":1,
  182. "department":["妇科"],
  183. "followUpTime":"每年",
  184. "abnormalDatas":null,
  185. "knownFactors":null,
  186. "medDatas":null
  187. },
  188. {
  189. "name":"肾癌",
  190. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  191. "notificationTime":"365",
  192. "recommendItems":["肾脏彩超","尿常规"],
  193. "riskDegree":1,
  194. "riskDesc":"低风险",
  195. "classification":1,
  196. "department":["肾内科"],
  197. "followUpTime":"每年",
  198. "abnormalDatas":null,
  199. "knownFactors":null,
  200. "medDatas":null
  201. },
  202. {
  203. "name":"胰腺癌",
  204. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  205. "notificationTime":"365",
  206. "recommendItems":["胰腺彩超"],
  207. "riskDegree":1,
  208. "riskDesc":"低风险",
  209. "classification":1,
  210. "department":["消化内科"],
  211. "followUpTime":"每年",
  212. "abnormalDatas":null,
  213. "knownFactors":null,
  214. "medDatas":null
  215. },
  216. {
  217. "name":"高血压",
  218. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  219. "notificationTime":"365",
  220. "recommendItems":["血压检查","一般检查","同型半胱氨酸检查","心脏彩超"],
  221. "riskDegree":1,
  222. "riskDesc":"低风险",
  223. "classification":3,
  224. "department":["心血管内科"],
  225. "followUpTime":"每年",
  226. "abnormalDatas":null,
  227. "knownFactors":null,
  228. "medDatas":null
  229. },
  230. {
  231. "name":"血脂异常",
  232. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  233. "notificationTime":"365",
  234. "recommendItems":["血脂检查","一般检查"],
  235. "riskDegree":1,
  236. "riskDesc":"低风险",
  237. "classification":3,
  238. "department":["心血管内科"],
  239. "followUpTime":"每年",
  240. "abnormalDatas":null,
  241. "knownFactors":null,
  242. "medDatas":null
  243. },
  244. {
  245. "name":"心律失常",
  246. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  247. "notificationTime":"365",
  248. "recommendItems":["心电图"],
  249. "riskDegree":1,
  250. "riskDesc":"低风险",
  251. "classification":3,
  252. "department":["心血管内科"],
  253. "followUpTime":"每年",
  254. "abnormalDatas":null,
  255. "knownFactors":null,
  256. "medDatas":null
  257. },
  258. {
  259. "name":"慢性阻塞性肺疾病",
  260. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  261. "notificationTime":"365",
  262. "recommendItems":["肺功能"],
  263. "riskDegree":0,
  264. "riskDesc":"无法评估",
  265. "classification":3,
  266. "department":["呼吸内科"],
  267. "followUpTime":"近期",
  268. "abnormalDatas":null,
  269. "knownFactors":null,
  270. "medDatas":null
  271. },
  272. {
  273. "name":"慢性胃炎",
  274. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  275. "notificationTime":"365",
  276. "recommendItems":["胃镜","幽门螺杆菌检查","胃蛋白酶原I","胃蛋白酶原II","胃蛋白酶原比值","胃泌素17"],
  277. "riskDegree":0,
  278. "riskDesc":"无法评估",
  279. "classification":3,
  280. "department":["消化内科"],
  281. "followUpTime":"近期",
  282. "abnormalDatas":null,
  283. "knownFactors":null,
  284. "medDatas":null
  285. },
  286. {
  287. "name":"慢性乙型病毒性肝炎",
  288. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  289. "notificationTime":"365",
  290. "recommendItems":["乙肝两对半"],
  291. "riskDegree":0,
  292. "riskDesc":"无法评估",
  293. "classification":3,
  294. "department":["消化内科"],
  295. "followUpTime":"近期",
  296. "abnormalDatas":null,
  297. "knownFactors":null,
  298. "medDatas":null
  299. },
  300. {
  301. "name":"肝硬化",
  302. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  303. "notificationTime":"365",
  304. "recommendItems":["乙肝两对半","乙肝DNA定量检测","甲胎蛋白","肝脏彩超","肝功能"],
  305. "riskDegree":1,
  306. "riskDesc":"低风险",
  307. "classification":3,
  308. "department":["消化内科"],
  309. "followUpTime":"每年",
  310. "abnormalDatas":null,
  311. "knownFactors":null,
  312. "medDatas":null
  313. },
  314. {
  315. "name":"糖尿病",
  316. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  317. "notificationTime":"365",
  318. "recommendItems":["糖化血红蛋白","糖化血清蛋白","餐后血糖","尿常规"],
  319. "riskDegree":0,
  320. "riskDesc":"无法评估",
  321. "classification":3,
  322. "department":["内分泌科"],
  323. "followUpTime":"近期",
  324. "abnormalDatas":null,
  325. "knownFactors":null,
  326. "medDatas":null
  327. },
  328. {
  329. "name":"肾功能损伤",
  330. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  331. "notificationTime":"365",
  332. "recommendItems":["肾功能检查","尿微量白蛋白","肾脏彩超","尿常规"],
  333. "riskDegree":1,
  334. "riskDesc":"低风险",
  335. "classification":3,
  336. "department":["肾内科"],
  337. "followUpTime":"每年",
  338. "abnormalDatas":null,
  339. "knownFactors":null,
  340. "medDatas":null
  341. },
  342. {
  343. "name":"骨质疏松",
  344. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  345. "notificationTime":"365",
  346. "recommendItems":["骨密度检查"],
  347. "riskDegree":0,
  348. "riskDesc":"无法评估",
  349. "classification":3,
  350. "department":["内分泌科"],
  351. "followUpTime":"近期",
  352. "abnormalDatas":null,
  353. "knownFactors":null,
  354. "medDatas":null
  355. },
  356. {
  357. "name":"冠心病",
  358. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  359. "notificationTime":"365",
  360. "recommendItems":["血压检查","血脂检查","空腹血糖检查","糖化血清蛋白","糖化血红蛋白","颈动脉彩超"],
  361. "riskDegree":1,
  362. "riskDesc":"低风险",
  363. "classification":2,
  364. "department":["心血管内科"],
  365. "followUpTime":"每年",
  366. "abnormalDatas":null,
  367. "knownFactors":null,
  368. "medDatas":null
  369. },
  370. {
  371. "name":"脑卒中",
  372. "nodeId":"4:b8fbfa26-3437-4bbb-8349-96abd14851ea:633",
  373. "notificationTime":"365",
  374. "recommendItems":["血压检查","血脂检查","空腹血糖检查","颈动脉彩超","颅脑CT","颅脑MRI"],
  375. "riskDegree":1,
  376. "riskDesc":"低风险",
  377. "classification":2,
  378. "department":["心血管内科"],
  379. "followUpTime":"每年",
  380. "abnormalDatas":null,
  381. "knownFactors":null,
  382. "medDatas":null
  383. }
  384. ],
  385. "reportConfig":{
  386. "reportCancerCfg":{
  387. "sectionContent":[
  388. {
  389. "note":"",
  390. "rank":1,
  391. "title":"您的疾病与主要风险因素"
  392. },
  393. {
  394. "note":"",
  395. "rank":2,
  396. "title":"疾病风险评估及建议"
  397. },
  398. {
  399. "note":"",
  400. "rank":3,
  401. "title":"该板块疾病主要风险因素及建议"
  402. },
  403. {
  404. "note":"",
  405. "rank":4,
  406. "title":"相关数据结果汇总"
  407. }
  408. ],
  409. "sectionName":"肿瘤风险评估"
  410. },
  411. "reportCardiovascularCfg":{
  412. "sectionContent":[
  413. {
  414. "note":"",
  415. "rank":1,
  416. "title":"您的疾病与主要风险因素"
  417. },
  418. {
  419. "note":"",
  420. "rank":2,
  421. "title":"疾病风险评估及建议"
  422. },
  423. {
  424. "note":"",
  425. "rank":3,
  426. "title":"该板块疾病主要风险因素及建议"
  427. },
  428. {
  429. "note":"",
  430. "rank":4,
  431. "title":"相关数据结果汇总"
  432. }
  433. ],
  434. "sectionName":"急性心脑血管事件风险评估"
  435. },
  436. "reportPersonaliseCfg":{
  437. "sectionContent":[
  438. {
  439. "note":"",
  440. "rank":2,
  441. "title":"疾病风险评估及建议"
  442. },
  443. {
  444. "note":"",
  445. "rank":3,
  446. "title":"该板块疾病主要风险因素及建议"
  447. },
  448. {
  449. "note":"",
  450. "rank":4,
  451. "title":"相关数据结果汇总"
  452. }
  453. ],
  454. "sectionName":"个性化疾病风险评估"
  455. },
  456. "reportPreviewCfg":{
  457. "sectionContent":[
  458. {
  459. "note":"本版块的疾病需要您高度重视,因为他们已经开始或者很快就会开始对您的身体造成严重的伤害,需要您尽快至医院治疗,减少伤害,降低经济损失。注意,进一步的检查项目有助于更详细的知晓您的身体状况,更准确的评估疾病的风险。",
  460. "rank":1,
  461. "title":"建议立即或尽快就医"
  462. },
  463. {
  464. "note":"本版块的疾病需要您密切关注,某些风险因素需要您按照医生建议定期复查,监测他们的变化趋势,同时也要对不良的生化习惯进行调整,降低疾病的发生概率。注意,进一步的检查项目有助于更详细的知晓您的身体状况,更准确的评估疾病的风险。",
  465. "rank":2,
  466. "title":"建议近期就医"
  467. },
  468. {
  469. "note":"以下内容是基于您上传的数据整理出的复查建议,请您定期复查,监测您的风险因素变化或者对低风险疾病进行定期复查",
  470. "rank":3,
  471. "title":"您的复查建议"
  472. }
  473. ],
  474. "sectionName":"重大疾病风险概览"
  475. }
  476. },
  477. "userInfo":{
  478. "currentAge":"",
  479. "examAge":"38",
  480. "gender":"女",
  481. "name":"匿名用户"
  482. }
  483. },
  484. "type":2
  485. }`
  486. var requestJson map[string]any
  487. json.Unmarshal([]byte(jsonStr), &requestJson)
  488. fmt.Println(requestJson)
  489. response, err := idc.CallbackResult("20230828000004", requestJson)
  490. if err != nil {
  491. t.Errorf("err: %v", err)
  492. }
  493. t.Logf("推送结果: %v", response)
  494. })
  495. }
  496. func TestGetAllValues(t *testing.T) {
  497. sdk.InitConfig(&sdk.ClientConfig{
  498. ApiDomain: "https://mcapi.mdfitnesscao.com",
  499. AppDebug: true,
  500. })
  501. m, err := idc.GetMedicalData("Ydm62mB8")
  502. fmt.Println(utils.JsonEncode(m), err)
  503. // r := m.GetArchivesDataByIndicatorId("4:b8fbfa26-3437-4bbb-8349-96abd14851ea:830")
  504. // fmt.Println(utils.JsonEncode(r))
  505. // s := m.GetArchivesDataByQuestionNo("QUshijianxuanze")
  506. // fmt.Println(utils.JsonEncode(s))
  507. }
  508. func TestTotalConfirmByArchivesIds(t *testing.T) {
  509. sdk.InitConfig(&sdk.ClientConfig{
  510. ApiDomain: "https://mcapi.mdfitnesscao.com",
  511. AppDebug: true,
  512. })
  513. m, err := idc.TotalMedicalReportChartsByArchivesIds([]string{"Ydm62mB8", "WNm0dm07", "111"})
  514. fmt.Println(utils.JsonEncode(m), err)
  515. // r := m.GetArchivesDataByIndicatorId("4:b8fbfa26-3437-4bbb-8349-96abd14851ea:830")
  516. // fmt.Println(utils.JsonEncode(r))
  517. // s := m.GetArchivesDataByQuestionNo("QUshijianxuanze")
  518. // fmt.Println(utils.JsonEncode(s))
  519. }
  520. func TestGetLatestMedicalReportByArchivesId(t *testing.T) {
  521. sdk.InitConfig(&sdk.ClientConfig{
  522. ApiDomain: "https://mcapi.mdfitnesscao.com",
  523. AppDebug: true,
  524. })
  525. m, err := idc.GetLatestMedicalReportByArchivesId("GdJGwYJK")
  526. fmt.Println(utils.JsonEncode(m), err)
  527. }
  528. func TestGetCompareReportByArchivesId(t *testing.T) {
  529. sdk.InitConfig(&sdk.ClientConfig{
  530. ApiDomain: "https://mcapi.mdfitnesscao.com",
  531. AppDebug: true,
  532. })
  533. m, _ := idc.GetCompareReportByArchivesId("GdJGwYJK")
  534. fmt.Println(utils.JsonEncode(m))
  535. }
  536. func TestUpdateArchives(t *testing.T) {
  537. sdk.InitConfig(&sdk.ClientConfig{
  538. ApiDomain: "https://mcapi.mdfitnesscao.com",
  539. AppDebug: true,
  540. })
  541. m, _ := idc.UpdateArchives(&sdk.MedicalDataBindArchivesFormByOpenAPI{
  542. ArchivesId: "DRzxXazy",
  543. MedicalDataId: "2024031400040010",
  544. MechanismId: "Xwlg97rP",
  545. })
  546. fmt.Println(utils.JsonEncode(m), "23")
  547. }
  548. func TestQueryIndicatorDataByParams(t *testing.T) {
  549. sdk.InitConfig(&sdk.ClientConfig{
  550. ApiDomain: "https://mcapi.mdfitnesscao.com",
  551. AppDebug: true,
  552. })
  553. m, _ := idc.QueryIndicatorDataByParams(&sdk.QueryIDCIndicatorDataQuery{
  554. ArchivesId: "DRzxXazy",
  555. QueryData: []*sdk.QueryIDCIndicatorDataQueryData{
  556. {
  557. BodyDataId: "4:b8fbfa26-3437-4bbb-8349-96abd14851ea:1142",
  558. },
  559. },
  560. })
  561. fmt.Println(utils.JsonEncode(m), "23")
  562. }
  563. func TestGetArchivesCreatedMapByMemberCardId(t *testing.T) {
  564. sdk.InitConfig(&sdk.ClientConfig{
  565. ApiDomain: "https://mcapi.mdfitnesscao.com",
  566. AppDebug: true,
  567. })
  568. m, _ := idc.GetArchivesCreatedMapByMemberCardId(1)
  569. fmt.Println(utils.JsonEncode(m), "23")
  570. }