Skip to content
Permalink
Browse files

fhir 4.0.0 support

  • Loading branch information...
mlapshin committed Jan 15, 2019
1 parent f04f771 commit e7da6aeb2a4d924df35a026a197f3bd1da40bed6
Showing with 11,868 additions and 151 deletions.
  1. +16 −5 load.go
  2. +1 −1 main.go
  3. +295 −0 schema/fhirbase-4.0.0.sql.json
  4. +0 −144 schema/fhirbase-dev.sql.json
  5. +11,556 −0 transform/fhirbase-import-4.0.0.json
  6. +0 −1 transform/fhirbase-import-dev.json
21 load.go
@@ -373,19 +373,22 @@ func (b *fhirBundle) Next() (map[string]interface{}, error) {
entryMap, ok := entry.(map[string]interface{})

if !ok {
return nil, fmt.Errorf("got non-object value in the entries array")
fmt.Printf("%s: got non-object value in the entries array, skipping rest of the file\n", b.file.file.Name())
return nil, io.EOF
}

res, ok := entryMap["resource"]

if !ok {
return nil, fmt.Errorf("cannot get entry.resource attribute")
fmt.Printf("%s: cannot get entry.resource attribute, skipping rest of the file\n", b.file.file.Name())
return nil, io.EOF
}

resMap, ok := res.(map[string]interface{})

if !ok {
return nil, fmt.Errorf("got non-object value at entry.resource")
fmt.Printf("%s: got non-object value at entry.resource, skipping rest of the file\n", b.file.file.Name())
return nil, io.EOF
}

return resMap, nil
@@ -442,7 +445,8 @@ func (b *ndjsonBundle) Next() (map[string]interface{}, error) {
}

if iter.WhatIsNext() != jsoniter.ObjectValue {
return nil, fmt.Errorf("Expecting to get JSON object at the root of the resource, got `%s` at line %d", strings.Trim(string(line), "\n"), b.curline)
fmt.Printf("%s: Expecting to get JSON object at the root of the resource, got `%s` at line %d, skipping rest of the file\n", b.file.file.Name(), strings.Trim(string(line), "\n"), b.curline)
return nil, io.EOF
}

b.curline++
@@ -514,7 +518,9 @@ func newMultifileBundle(fileNames []string) (*multifileBundle, error) {
}

if err != nil {
return nil, errors.Wrap(err, "cannot create bundle")
fmt.Printf("%s: cannot create bundle\n%e\n", f.file.Name(), err)
defer f.Close()
bndl = nil
}

if bndl != nil {
@@ -718,6 +724,11 @@ func (l *insertLoader) Load(db *pgx.Conn, bndl bundle, cb loaderCb) error {
}
}

if batch != nil {
batch.Send(context.Background(), nil)
batch.Close()
}

return nil
}

@@ -12,7 +12,7 @@ import (
var AvailableSchemas = []string{
"1.0.2", "1.1.0", "1.4.0",
"1.6.0", "1.8.0", "3.0.1",
"3.2.0", "3.3.0", "dev",
"3.2.0", "3.3.0", "4.0.0",
}

var Version = "unknown"

0 comments on commit e7da6ae

Please sign in to comment.
You can’t perform that action at this time.