feat(handler): 暴露健康档案 upsert 接口(T-204)
This commit is contained in:
@@ -246,6 +246,34 @@ func MapHealthRecordTask(task source.HealthRecordTask, ctx MapContext) (contract
|
||||
return BuildHealthRecordCreate(mapped), errs
|
||||
}
|
||||
|
||||
// ValidateHealthRecordTask performs all local mapping validation without
|
||||
// claiming that the supplied doctor or organization exists in CHIS.
|
||||
func ValidateHealthRecordTask(task source.HealthRecordTask) []ValidationError {
|
||||
_, errs := MapHealthRecordTask(task, MapContext{
|
||||
Dicts: DefaultDictSnapshot(),
|
||||
MasterData: submittedHealthRecordMasterData{
|
||||
doctorID: task.Record.ManaDoctorID,
|
||||
unitID: task.Record.ManaUnitID,
|
||||
},
|
||||
})
|
||||
return errs
|
||||
}
|
||||
|
||||
type submittedHealthRecordMasterData struct {
|
||||
doctorID string
|
||||
unitID string
|
||||
}
|
||||
|
||||
func (m submittedHealthRecordMasterData) RegionCodeByName(string) (string, bool) { return "", false }
|
||||
func (m submittedHealthRecordMasterData) DoctorIDByName(string) (string, bool) { return "", false }
|
||||
func (m submittedHealthRecordMasterData) ManaUnitIDByName(string) (string, bool) { return "", false }
|
||||
func (m submittedHealthRecordMasterData) DoctorIDExists(id string) bool {
|
||||
return strings.TrimSpace(id) != "" && strings.TrimSpace(id) == strings.TrimSpace(m.doctorID)
|
||||
}
|
||||
func (m submittedHealthRecordMasterData) ManaUnitIDExists(id string) bool {
|
||||
return strings.TrimSpace(id) != "" && strings.TrimSpace(id) == strings.TrimSpace(m.unitID)
|
||||
}
|
||||
|
||||
func validateMasterData(src PHISHealthRecord, lookup MasterDataLookup) []ValidationError {
|
||||
if lookup == nil {
|
||||
return []ValidationError{{Field: "masterData", Reason: "CHIS dictionary snapshot is required"}}
|
||||
|
||||
Reference in New Issue
Block a user