feat(osi): 优化人群分类查询接口(T-209)

This commit is contained in:
ila
2026-07-09 20:38:27 +08:00
parent ca16f61263
commit 561cd839e7
10 changed files with 108 additions and 16 deletions
+31
View File
@@ -51,6 +51,37 @@ func (h *HealthRecordHandler) Find(w http.ResponseWriter, r *http.Request) {
writeJSONError(w, http.StatusBadGateway, "empty response from OSI")
}
// Crowd 处理 GET /api/health-record/crowd?idCard=..|phrid=..
// 原样回写 JKDA00005 人群分类与子档案标记响应。
func (h *HealthRecordHandler) Crowd(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
writeJSONError(w, http.StatusMethodNotAllowed, "only GET is supported")
return
}
q := r.URL.Query()
query := osi.FindRqbjQuery{
IDCard: q.Get("idCard"),
PHRID: q.Get("phrid"),
}
if query.IDCard == "" && query.PHRID == "" {
writeJSONError(w, http.StatusBadRequest, "provide one of: idCard, phrid")
return
}
_, result, err := h.client.FindRqbj(r.Context(), query)
if len(result.Raw) > 0 {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
_, _ = w.Write(result.Raw)
return
}
if err != nil {
writeJSONError(w, http.StatusBadGateway, err.Error())
return
}
writeJSONError(w, http.StatusBadGateway, "empty response from OSI")
}
func writeJSONError(w http.ResponseWriter, status int, msg string) {
w.Header().Set("Content-Type", "application/json; charset=utf-8")
w.WriteHeader(status)