feat(osi): 实现老年人自理能力查询(T-303)
This commit is contained in:
+16
-14
@@ -15,25 +15,27 @@ const (
|
||||
ServiceIDDrugs = "YPML00001"
|
||||
ServiceIDOrgs = "CXJG00002"
|
||||
|
||||
ServiceIDJKTJLast = "JKTJLSJL00002" // 最近一次体检(实测可用)
|
||||
ServiceIDJKTJQuery = "JKTJ00002" // 某人全部体检(实测可用,返回数组)
|
||||
ServiceIDJKTJList = "JKTJLIST00002" // 已检/待检人员名单(实测可用)
|
||||
ServiceIDJKTJLast = "JKTJLSJL00002" // 最近一次体检(实测可用)
|
||||
ServiceIDJKTJQuery = "JKTJ00002" // 某人全部体检(实测可用,返回数组)
|
||||
ServiceIDJKTJList = "JKTJLIST00002" // 已检/待检人员名单(实测可用)
|
||||
ServiceIDLNRSelfCareQuery = "LNRZLPG00002" // 老年人生活自理能力评估查询(待联调确认)
|
||||
)
|
||||
|
||||
const codeRetryableTimeout = "405"
|
||||
|
||||
var servicePaths = map[string]string{
|
||||
ServiceIDJKDACreate: "/jkda/create",
|
||||
ServiceIDJKDAFind: "/auto/jkda/find",
|
||||
ServiceIDJKDAUpdate: "/jkda/update",
|
||||
ServiceIDJKDAFindRqbj: "/auto/jkda/findrqbj",
|
||||
ServiceIDGridAddress: "/auto/wgdzcx/query",
|
||||
ServiceIDDoctors: "/auto/zryscx/query",
|
||||
ServiceIDDrugs: "/auto/ypmlcx/query",
|
||||
ServiceIDOrgs: "/auto/cxjg/query",
|
||||
ServiceIDJKTJLast: "/auto/jktjlscx/query",
|
||||
ServiceIDJKTJQuery: "/auto/jktj/query",
|
||||
ServiceIDJKTJList: "/auto/jktjlist/query",
|
||||
ServiceIDJKDACreate: "/jkda/create",
|
||||
ServiceIDJKDAFind: "/auto/jkda/find",
|
||||
ServiceIDJKDAUpdate: "/jkda/update",
|
||||
ServiceIDJKDAFindRqbj: "/auto/jkda/findrqbj",
|
||||
ServiceIDGridAddress: "/auto/wgdzcx/query",
|
||||
ServiceIDDoctors: "/auto/zryscx/query",
|
||||
ServiceIDDrugs: "/auto/ypmlcx/query",
|
||||
ServiceIDOrgs: "/auto/cxjg/query",
|
||||
ServiceIDJKTJLast: "/auto/jktjlscx/query",
|
||||
ServiceIDJKTJQuery: "/auto/jktj/query",
|
||||
ServiceIDJKTJList: "/auto/jktjlist/query",
|
||||
ServiceIDLNRSelfCareQuery: "/auto/lnr/query",
|
||||
}
|
||||
|
||||
func PathOf(serviceID string) (string, error) {
|
||||
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package osi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"chis_osi/contract"
|
||||
)
|
||||
|
||||
// ElderlySelfCareQuery 是 LNRZLPG00002 的查询条件。
|
||||
// 厂家文档要求 idCard,phrId 和 checkId 为可选定位条件。
|
||||
type ElderlySelfCareQuery struct {
|
||||
IDCard string
|
||||
PHRID string
|
||||
CheckID string
|
||||
}
|
||||
|
||||
// QueryElderlySelfCare 查询老年人生活自理能力评估记录。
|
||||
func (c *Client) QueryElderlySelfCare(ctx context.Context, query ElderlySelfCareQuery) ([]contract.ElderlySelfCareAssessment, Result, error) {
|
||||
baseInfo, err := query.baseInfo()
|
||||
if err != nil {
|
||||
return nil, Result{}, err
|
||||
}
|
||||
var rows []contract.ElderlySelfCareAssessment
|
||||
result, err := c.Call(ctx, ServiceIDLNRSelfCareQuery, baseInfo, &rows)
|
||||
return rows, result, err
|
||||
}
|
||||
|
||||
func (q ElderlySelfCareQuery) baseInfo() (map[string]string, error) {
|
||||
if q.IDCard == "" {
|
||||
return nil, fmt.Errorf("query elderly self care requires idCard")
|
||||
}
|
||||
baseInfo := map[string]string{"idCard": q.IDCard}
|
||||
if q.PHRID != "" {
|
||||
baseInfo["phrId"] = q.PHRID
|
||||
}
|
||||
if q.CheckID != "" {
|
||||
baseInfo["checkId"] = q.CheckID
|
||||
}
|
||||
return baseInfo, nil
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package osi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestQueryElderlySelfCareUsesDocumentedContract(t *testing.T) {
|
||||
var seenPath string
|
||||
var seenBody map[string]any
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seenPath = r.URL.Path
|
||||
if err := json.NewDecoder(r.Body).Decode(&seenBody); err != nil {
|
||||
t.Fatalf("decode request: %v", err)
|
||||
}
|
||||
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[{"phrId":"PHR-1","checkId":"LNR-1","jc":"1","jcdj":"1","jcpf":"10","zp":"1","zpdj":"1","zpfs":"100","createDate":"2026-01-01"}]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
client := newTestJKDAClient(t, server.URL)
|
||||
rows, result, err := client.QueryElderlySelfCare(context.Background(), ElderlySelfCareQuery{
|
||||
IDCard: "TEST-ID",
|
||||
PHRID: "PHR-1",
|
||||
CheckID: "LNR-1",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("QueryElderlySelfCare: %v", err)
|
||||
}
|
||||
if seenPath != "/osi/api/auto/lnr/query" {
|
||||
t.Fatalf("path = %q", seenPath)
|
||||
}
|
||||
if seenBody["serviceId"] != ServiceIDLNRSelfCareQuery {
|
||||
t.Fatalf("serviceId = %v", seenBody["serviceId"])
|
||||
}
|
||||
baseInfo := seenBody["uploadinfo"].(map[string]any)["baseInfo"].(map[string]any)
|
||||
if baseInfo["idCard"] != "TEST-ID" || baseInfo["phrId"] != "PHR-1" || baseInfo["checkId"] != "LNR-1" {
|
||||
t.Fatalf("baseInfo = %#v", baseInfo)
|
||||
}
|
||||
if !result.Success || len(rows) != 1 {
|
||||
t.Fatalf("rows=%d result=%#v", len(rows), result)
|
||||
}
|
||||
if rows[0].Meal != "1" || rows[0].TotalScore != "100" || rows[0].CheckID != "LNR-1" {
|
||||
t.Fatalf("row = %#v", rows[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestElderlySelfCareQueryRequiresIDCard(t *testing.T) {
|
||||
if _, err := (ElderlySelfCareQuery{PHRID: "PHR-1"}).baseInfo(); err == nil {
|
||||
t.Fatal("missing idCard should error")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user