feat(osi): 实现 JKDA 档案 Create/Update 与创建请求契约(T-206)
- contract/jkda.go 补创建请求结构体(healthRecord + manageInfo + 既往史节点) - osi/jkda.go 新增 CreateHealthRecord/UpdateHealthRecord - osi/codes.go 登记 JKDA00001 create / JKDA00003 update serviceId 与路径 - mapping 映射创建路径(真实字典快照反查主数据) - 代码与单测完成;真实 create 待安全测试档案与写入授权(见 tasks.md T-206 BLOCKED) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -97,3 +97,49 @@ type FamilyMiddle struct {
|
||||
LivestockColumn string `json:"livestockColumn,omitempty"`
|
||||
IsFillSHHJ string `json:"isFillShhj,omitempty"`
|
||||
}
|
||||
|
||||
type HealthRecordCreate struct {
|
||||
BaseInfo HealthRecordBaseInfo `json:"baseInfo,omitempty"`
|
||||
ManageInfo ManageInfo `json:"manageInfo"`
|
||||
HealthRecord HealthRecordCreateInfo `json:"healthRecord"`
|
||||
PastHistory *PastHistory `json:"pastHistory,omitempty"`
|
||||
PastDiseases []PastDisease `json:"jwsjb,omitempty"`
|
||||
PastSurgeries []PastSurgery `json:"jwsss,omitempty"`
|
||||
PastTraumas []PastTrauma `json:"jwsws,omitempty"`
|
||||
PastTransfusions []PastBloodTx `json:"jwssx,omitempty"`
|
||||
FamilyMiddle *FamilyMiddle `json:"familyMiddle,omitempty"`
|
||||
}
|
||||
|
||||
type HealthRecordBaseInfo struct {
|
||||
IDCard string `json:"idCard,omitempty"`
|
||||
PersonName string `json:"personName,omitempty"`
|
||||
PHRID string `json:"phrId,omitempty"`
|
||||
}
|
||||
|
||||
type HealthRecordCreateInfo struct {
|
||||
CheckID string `json:"checkId,omitempty"`
|
||||
IDCard string `json:"idCard,omitempty"`
|
||||
PersonName string `json:"personName,omitempty"`
|
||||
SexCode string `json:"sexCode,omitempty"`
|
||||
Birthday string `json:"birthday,omitempty"`
|
||||
PhrID string `json:"phrId,omitempty"`
|
||||
MobileNumber string `json:"mobileNumber,omitempty"`
|
||||
RegionCode string `json:"regionCode,omitempty"`
|
||||
ManaDoctorID string `json:"manaDoctorId,omitempty"`
|
||||
ManaUnitID string `json:"manaUnitId,omitempty"`
|
||||
CreateUser string `json:"createUser,omitempty"`
|
||||
CreateUnit string `json:"createUnit,omitempty"`
|
||||
NationCode string `json:"nationCode,omitempty"`
|
||||
EducationCode string `json:"educationCode,omitempty"`
|
||||
WorkCode string `json:"workCode,omitempty"`
|
||||
MaritalStatusCode string `json:"maritalStatusCode,omitempty"`
|
||||
BloodTypeCode string `json:"bloodTypeCode,omitempty"`
|
||||
RhBloodCode string `json:"rhBloodCode,omitempty"`
|
||||
InsuranceCode string `json:"insuranceCode,omitempty"`
|
||||
AddressNumber string `json:"addressNumber,omitempty"`
|
||||
}
|
||||
|
||||
type HealthRecordSaveResult struct {
|
||||
PhrID string `json:"phrId"`
|
||||
CreateUnit string `json:"createUnit,omitempty"`
|
||||
}
|
||||
|
||||
@@ -135,3 +135,47 @@ func TestFindHealthRecordResponseDeserializesDataArray(t *testing.T) {
|
||||
t.Fatalf("checkId = %#v, want nil", response.Data[0].HealthRecord.CheckID)
|
||||
}
|
||||
}
|
||||
func TestHealthRecordCreateSerializesCreateFieldNames(t *testing.T) {
|
||||
req := HealthRecordCreate{
|
||||
BaseInfo: HealthRecordBaseInfo{
|
||||
IDCard: "440000********1234",
|
||||
PersonName: "测试人员",
|
||||
},
|
||||
HealthRecord: HealthRecordCreateInfo{
|
||||
CheckID: "CHK2026070700000001",
|
||||
IDCard: "440000********1234",
|
||||
PersonName: "测试人员",
|
||||
SexCode: "1",
|
||||
Birthday: "1970-01-01",
|
||||
MobileNumber: "13900000000",
|
||||
RegionCode: "441625000000",
|
||||
ManaDoctorID: "doc-001",
|
||||
ManaUnitID: "123456789",
|
||||
AddressNumber: "101号",
|
||||
},
|
||||
PastHistory: &PastHistory{YWGMS: "0101"},
|
||||
}
|
||||
|
||||
raw, err := json.Marshal(req)
|
||||
if err != nil {
|
||||
t.Fatalf("Marshal: %v", err)
|
||||
}
|
||||
var got map[string]any
|
||||
if err := json.Unmarshal(raw, &got); err != nil {
|
||||
t.Fatalf("Unmarshal: %v", err)
|
||||
}
|
||||
healthRecord := got["healthRecord"].(map[string]any)
|
||||
if healthRecord["checkId"] != "CHK2026070700000001" {
|
||||
t.Fatalf("healthRecord = %#v", healthRecord)
|
||||
}
|
||||
if healthRecord["addressNumber"] != "101号" {
|
||||
t.Fatalf("addressNumber missing: %#v", healthRecord)
|
||||
}
|
||||
if _, ok := healthRecord["adressNumber"]; ok {
|
||||
t.Fatalf("create request used response typo adressNumber: %#v", healthRecord)
|
||||
}
|
||||
baseInfo := got["baseInfo"].(map[string]any)
|
||||
if baseInfo["idCard"] != "440000********1234" || baseInfo["personName"] != "测试人员" {
|
||||
t.Fatalf("baseInfo = %#v", baseInfo)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user