You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for this nice package.
I was wondering why is there pointer on each generated resources' properties?
My objective here is to read fhir data from a bigquery. But the type mapping is not possible because of properties generated with pointer I know this is not the purpose of this package to let us map fhir data from bigquery.
For example :
func (rRequest) EncounteredPatients(practitionerIdstring) ([]fhir.Patient, error) {
it, err:=r.Raw(fmt.Sprintf(`SELECT * FROM <gcp_project_id>.<bigquery_datasets>.Patient patient INNER JOIN ( SELECT DISTINCT subject.patientId FROM bios-innov.metamedical.Encounter as encounter, UNNEST(encounter.participant) as participant WHERE participant.individual.practitionerId = '%v') encounters ON patient.id = encounters.PatientId`, practitionerId))
iferr!=nil {
return []fhir.Patient{}, fmt.Errorf("EncounteredPatients failed for %v: %w", practitionerId, err)
}
patients:=make([]fhir.Patient, 0, 0)
for {
varpatient fhir.Patienterr:=it.Next(&patient)
iferr==iterator.Done {
break
}
iferr!=nil {
returnpatients, fmt.Errorf("Failed to read result : %w", err) // TODO: Handle error.
}
// fmt.Println(row)patients=append(patients, patient)
}
returnpatients, nil
}
Will lead to an error bigquery: schema field active of type BOOLEAN is not assignable to struct field Active of type *bool
But doing this
func (rRequest) EncounteredPatients(practitionerIdstring) ([]fhir.Patient, error) {
it, err:=r.Raw(fmt.Sprintf(`SELECT * FROM <gcp_project_id>.<bigquery_datasets>.Patient patient INNER JOIN ( SELECT DISTINCT subject.patientId FROM bios-innov.metamedical.Encounter as encounter, UNNEST(encounter.participant) as participant WHERE participant.individual.practitionerId = '%v') encounters ON patient.id = encounters.PatientId`, practitionerId))
iferr!=nil {
return []fhir.Patient{}, fmt.Errorf("EncounteredPatients failed for %v: %w", practitionerId, err)
}
patients:=make([]fhir.Patient, 0, 0)
for {
varpatient fhir.Patientvarrowmap[string]bigquery.Valueerr:=it.Next(&row)
iferr==iterator.Done {
break
}
iferr!=nil {
returnpatients, fmt.Errorf("Failed to read result : %w", err) // TODO: Handle error.
}
jsonRaw, errJson:=json.Marshal(row)
iferrJson!=nil {
returnpatients, fmt.Errorf("Failed to marshal result : %w", errJson)
}
errReDecode:=json.Unmarshal(jsonRaw, &patient)
iferrReDecode!=nil {
returnpatients, fmt.Errorf("Failed to Unmarshal result : %w", errReDecode)
}
// fmt.Println(row)patients=append(patients, patient)
}
returnpatients, nil
}
Will succeed.
The text was updated successfully, but these errors were encountered:
Hello,
Thanks for this nice package.
I was wondering why is there pointer on each generated resources' properties?
My objective here is to read fhir data from a bigquery. But the type mapping is not possible because of properties generated with pointer
I know this is not the purpose of this package to let us map fhir data from bigquery.
For example :
Will lead to an error
bigquery: schema field active of type BOOLEAN is not assignable to struct field Active of type *bool
But doing this
Will succeed.
The text was updated successfully, but these errors were encountered: