standardhealth / shr-es6-export

ES6 library for exporting SHR models to ES6 classes
Apache License 2.0
3 stars 0 forks source link

fromFHIR extension.valueReference not handled correctly #57

Open dehall opened 5 years ago

dehall commented 5 years ago

Observed in classes generated from v0.9.0 of the spec, for instance onco.core.PrimaryCancerCondition:

    if (asExtension) {
      inst.value = fhir['valueReference'];
    }

valueReference is a FHIR Reference, so setting a value to it isn't going to produce anything useful. In other fields this is handled correctly, more like this:

    if (fhir['encounter'] != null) {
      const entryId = fhir['encounter']['reference'];
      if (!mappedResources[entryId]) {
        const referencedEntry = allEntries.find(e => e.fullUrl === entryId);
        if (referencedEntry) {
          mappedResources[entryId] = FHIRHelper.createInstanceFromFHIR('shr.core.Encounter', referencedEntry['resource'], 'undefined', shrId, allEntries, mappedResources, referencesOut);
        }
      }
      inst.careContext = mappedResources[entryId];
    }