package graph_test import ( "encoding/json" "fmt" "testing" "gogs.uu.mdfitnesscao.com/cuiguohai/sdk" "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/graph" "gogs.uu.mdfitnesscao.com/cuiguohai/sdk/utils" ) func TestList(t *testing.T) { t.Run("test", func(t *testing.T) { sdk.InitConfig(&sdk.ClientConfig{ AlgorApiDomain: "https://api.mdfitnesscao.com", AppDebug: true, }) response, err := graph.ListNode([]string{ "4:b8fbfa26-3437-4bbb-8349-96abd14851ea:1378", }, []string{}) if err != nil { t.Errorf("err: %v", err) } list := response.Data.List node := list[0] fmt.Println(node.Properties.Tags) t.Logf("list len: %v", utils.JsonEncode(list)) }) } func TestListTemplate(t *testing.T) { t.Run("test", func(t *testing.T) { sdk.InitConfig(&sdk.ClientConfig{ AlgorApiDomain: "https://api.mdfitnesscao.com", AppDebug: true, }) templates, err := graph.ListNodeToQuestionTemplate([]string{ "4:b8fbfa26-3437-4bbb-8349-96abd14851ea:989", "4:b8fbfa26-3437-4bbb-8349-96abd14851ea:93", }, false) if err != nil { t.Errorf("err: %v", err) } t.Logf("list len: %d", len(templates)) t.Logf("list: %s", utils.JsonEncode(templates)) }) } func TestGetNodeRelationShip(t *testing.T) { t.Run("test", func(t *testing.T) { sdk.InitConfig(&sdk.ClientConfig{ AlgorApiDomain: "https://api.hhmdtech.com", AppDebug: true, }) relationResponse, relationErr := graph.GetNodeRelationd("4:aad18a76-6ee3-48a0-bec9-4f7e0bb822dc:357", "可检测", "") if relationErr == nil && len(relationResponse.Data) > 0 { bloodPressureItemGroupId := relationResponse.Data[0]["id"].(string) bloodPressureItemGroupName := relationResponse.Data[0]["properties"].(map[string]any)["name"].(string) fmt.Println(bloodPressureItemGroupId, bloodPressureItemGroupName) } }) } func TestFilterArchivesValues(t *testing.T) { t.Run("test", func(t *testing.T) { sdk.InitConfig(&sdk.ClientConfig{ AlgorApiDomain: "https://api.mdfitnesscao.com", AppDebug: true, }) var jsonStr = `[ { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:value", "value": [ "111" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:value", "type": "input" }, "extraType": 4 }, { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:range", "value": [ "" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:range", "type": "input" }, "extraType": 4 }, { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:unit", "value": [ "" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:unit", "type": "input" }, "extraType": 4 }, { "answer": { "answer": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:time", "value": "" }, "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": null, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:189:time", "type": "date" }, "extraType": 4 }, { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:value", "value": [ "66" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:value", "type": "input" }, "extraType": 4 }, { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:range", "value": [ "" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:range", "type": "input" }, "extraType": 4 }, { "answer": { "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:unit", "value": [ "" ] }, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:unit", "type": "input" }, "extraType": 4 }, { "answer": { "answer": { "key": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:time", "value": "" }, "checkboxAnswers": null, "groupAnswers": null, "inputAnswers": null, "linkAnswers": null, "matrixAnswers": null, "multipleAnswers": false, "questionNo": "b8fbfa26.indicator:4:b8fbfa26-3437-4bbb-8349-96abd14851ea:190:time", "type": "date" }, "extraType": 4 } ]` var values []*sdk.ArchivesValues json.Unmarshal([]byte(jsonStr), &values) unit, rangeValues := graph.FilterArchivesValues( values, ) t.Log("list", utils.JsonEncode(unit)) t.Log("list", utils.JsonEncode(rangeValues)) }) }