Skip to content

Commit

Permalink
make sure reference fields are correctly extracted and stored in the DB.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Aug 13, 2023
1 parent 4f60d0e commit 1f113cd
Show file tree
Hide file tree
Showing 57 changed files with 3,335 additions and 318 deletions.
12 changes: 0 additions & 12 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 33 additions & 3 deletions backend/pkg/models/database/fhir_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,18 @@ func (s *FhirAccount) PopulateAndExtractSearchParameters(resourceRaw json.RawMes
s.Name = []byte(nameResult.String())
}
// extracting Owner
ownerResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'Account.owner'))")
ownerResult, err := vm.RunString(`
OwnerResult = window.fhirpath.evaluate(fhirResource, 'Account.owner')
if(OwnerResult.length == 0) {
"undefined"
}
else {
JSON.stringify(OwnerResult)
}
`)
if err == nil && ownerResult.String() != "undefined" {
s.Owner = []byte(ownerResult.String())
}
// extracting Period
periodResult, err := vm.RunString("window.fhirpath.evaluate(fhirResource, 'Account.servicePeriod')[0]")
Expand All @@ -284,8 +294,18 @@ func (s *FhirAccount) PopulateAndExtractSearchParameters(resourceRaw json.RawMes
}
}
// extracting Profile
profileResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'meta.profile'))")
profileResult, err := vm.RunString(`
ProfileResult = window.fhirpath.evaluate(fhirResource, 'meta.profile')
if(ProfileResult.length == 0) {
"undefined"
}
else {
JSON.stringify(ProfileResult)
}
`)
if err == nil && profileResult.String() != "undefined" {
s.Profile = []byte(profileResult.String())
}
// extracting SourceUri
sourceUriResult, err := vm.RunString("window.fhirpath.evaluate(fhirResource, 'meta.source')[0]")
Expand Down Expand Up @@ -340,8 +360,18 @@ func (s *FhirAccount) PopulateAndExtractSearchParameters(resourceRaw json.RawMes
s.Status = []byte(statusResult.String())
}
// extracting Subject
subjectResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'Account.subject'))")
subjectResult, err := vm.RunString(`
SubjectResult = window.fhirpath.evaluate(fhirResource, 'Account.subject')
if(SubjectResult.length == 0) {
"undefined"
}
else {
JSON.stringify(SubjectResult)
}
`)
if err == nil && subjectResult.String() != "undefined" {
s.Subject = []byte(subjectResult.String())
}
// extracting Tag
tagResult, err := vm.RunString(`
Expand Down
84 changes: 77 additions & 7 deletions backend/pkg/models/database/fhir_adverse_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,20 +339,60 @@ func (s *FhirAdverseEvent) PopulateAndExtractSearchParameters(resourceRaw json.R
}
}
// extracting Location
locationResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.location'))")
locationResult, err := vm.RunString(`
LocationResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.location')
if(LocationResult.length == 0) {
"undefined"
}
else {
JSON.stringify(LocationResult)
}
`)
if err == nil && locationResult.String() != "undefined" {
s.Location = []byte(locationResult.String())
}
// extracting Profile
profileResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'meta.profile'))")
profileResult, err := vm.RunString(`
ProfileResult = window.fhirpath.evaluate(fhirResource, 'meta.profile')
if(ProfileResult.length == 0) {
"undefined"
}
else {
JSON.stringify(ProfileResult)
}
`)
if err == nil && profileResult.String() != "undefined" {
s.Profile = []byte(profileResult.String())
}
// extracting Recorder
recorderResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.recorder'))")
recorderResult, err := vm.RunString(`
RecorderResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.recorder')
if(RecorderResult.length == 0) {
"undefined"
}
else {
JSON.stringify(RecorderResult)
}
`)
if err == nil && recorderResult.String() != "undefined" {
s.Recorder = []byte(recorderResult.String())
}
// extracting Resultingcondition
resultingconditionResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.resultingCondition'))")
resultingconditionResult, err := vm.RunString(`
ResultingconditionResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.resultingCondition')
if(ResultingconditionResult.length == 0) {
"undefined"
}
else {
JSON.stringify(ResultingconditionResult)
}
`)
if err == nil && resultingconditionResult.String() != "undefined" {
s.Resultingcondition = []byte(resultingconditionResult.String())
}
// extracting Seriousness
seriousnessResult, err := vm.RunString(`
Expand Down Expand Up @@ -454,16 +494,46 @@ func (s *FhirAdverseEvent) PopulateAndExtractSearchParameters(resourceRaw json.R
s.SourceUri = sourceUriResult.String()
}
// extracting Study
studyResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.study'))")
studyResult, err := vm.RunString(`
StudyResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.study')
if(StudyResult.length == 0) {
"undefined"
}
else {
JSON.stringify(StudyResult)
}
`)
if err == nil && studyResult.String() != "undefined" {
s.Study = []byte(studyResult.String())
}
// extracting Subject
subjectResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.subject'))")
subjectResult, err := vm.RunString(`
SubjectResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.subject')
if(SubjectResult.length == 0) {
"undefined"
}
else {
JSON.stringify(SubjectResult)
}
`)
if err == nil && subjectResult.String() != "undefined" {
s.Subject = []byte(subjectResult.String())
}
// extracting Substance
substanceResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AdverseEvent.suspectEntity.instance'))")
substanceResult, err := vm.RunString(`
SubstanceResult = window.fhirpath.evaluate(fhirResource, 'AdverseEvent.suspectEntity.instance')
if(SubstanceResult.length == 0) {
"undefined"
}
else {
JSON.stringify(SubstanceResult)
}
`)
if err == nil && substanceResult.String() != "undefined" {
s.Substance = []byte(substanceResult.String())
}
// extracting Tag
tagResult, err := vm.RunString(`
Expand Down
36 changes: 33 additions & 3 deletions backend/pkg/models/database/fhir_allergy_intolerance.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,18 @@ func (s *FhirAllergyIntolerance) PopulateAndExtractSearchParameters(resourceRaw
}
// execute the fhirpath expression for each search parameter
// extracting Asserter
asserterResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AllergyIntolerance.asserter'))")
asserterResult, err := vm.RunString(`
AsserterResult = window.fhirpath.evaluate(fhirResource, 'AllergyIntolerance.asserter')
if(AsserterResult.length == 0) {
"undefined"
}
else {
JSON.stringify(AsserterResult)
}
`)
if err == nil && asserterResult.String() != "undefined" {
s.Asserter = []byte(asserterResult.String())
}
// extracting Category
categoryResult, err := vm.RunString(`
Expand Down Expand Up @@ -588,12 +598,32 @@ func (s *FhirAllergyIntolerance) PopulateAndExtractSearchParameters(resourceRaw
}
}
// extracting Profile
profileResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'meta.profile'))")
profileResult, err := vm.RunString(`
ProfileResult = window.fhirpath.evaluate(fhirResource, 'meta.profile')
if(ProfileResult.length == 0) {
"undefined"
}
else {
JSON.stringify(ProfileResult)
}
`)
if err == nil && profileResult.String() != "undefined" {
s.Profile = []byte(profileResult.String())
}
// extracting Recorder
recorderResult, err := vm.RunString("JSON.stringify(window.fhirpath.evaluate(fhirResource, 'AllergyIntolerance.recorder'))")
recorderResult, err := vm.RunString(`
RecorderResult = window.fhirpath.evaluate(fhirResource, 'AllergyIntolerance.recorder')
if(RecorderResult.length == 0) {
"undefined"
}
else {
JSON.stringify(RecorderResult)
}
`)
if err == nil && recorderResult.String() != "undefined" {
s.Recorder = []byte(recorderResult.String())
}
// extracting Route
routeResult, err := vm.RunString(`
Expand Down

0 comments on commit 1f113cd

Please sign in to comment.