standardhealth / shr-es6-export

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

Duplicate constants in fromFHIR #55

Open dehall opened 5 years ago

dehall commented 5 years ago

Duplicate constants observed based on generating DSTU2 for shr_spec tag v0.9.0 and branch 5.x on all other shr toolchain projects

Ex: in onco/core/CancerRelatedRadiationProcedure.js:

    if (fhir['request'] != null) {
      inst.relatedRequest = inst.relatedRequest || FHIRHelper.createInstanceFromFHIR('shr.core.RelatedRequest', {}, null, shrId);
      const entryId = fhir['request']['reference'];
      if (!mappedResources[entryId]) {
        const referencedEntry = allEntries.find(e => e.fullUrl === entryId);
        if (referencedEntry) {
          mappedResources[entryId] = FHIRHelper.createInstanceFromFHIR('shr.core.ProcedureRequest', referencedEntry['resource'], 'undefined', shrId, allEntries, mappedResources, referencesOut);
        }
      }
      if (mappedResources[entryId]) {
        inst.relatedRequest.value = FHIRHelper.createReference(mappedResources[entryId], referencesOut);
      }
      else {
        const entryType = 'http://standardhealthrecord.org/spec/shr/core/ProcedureRequest';
        inst.relatedRequest.value = FHIRHelper.createReferenceWithoutObject(shrId, entryId, entryType);
      }
      inst.relatedRequest = inst.relatedRequest || FHIRHelper.createInstanceFromFHIR('shr.core.RelatedRequest', {}, null, shrId);
      const entryId = fhir['request']['reference'];
      if (!mappedResources[entryId]) {
        const referencedEntry = allEntries.find(e => e.fullUrl === entryId);
        if (referencedEntry) {
          mappedResources[entryId] = FHIRHelper.createInstanceFromFHIR('shr.core.ProcedureRequest', referencedEntry['resource'], 'undefined', shrId, allEntries, mappedResources, referencesOut);
        }
      }
      if (mappedResources[entryId]) {
        inst.relatedRequest.value = FHIRHelper.createReference(mappedResources[entryId], referencesOut);
      }
      else {
        const entryType = 'http://standardhealthrecord.org/spec/shr/core/ProcedureRequest';
        inst.relatedRequest.value = FHIRHelper.createReferenceWithoutObject(shrId, entryId, entryType);
      }
      inst.relatedRequest = inst.relatedRequest || FHIRHelper.createInstanceFromFHIR('shr.core.RelatedRequest', {}, null, shrId);
      const entryId = fhir['request']['reference'];
      if (!mappedResources[entryId]) {
        const referencedEntry = allEntries.find(e => e.fullUrl === entryId);
        if (referencedEntry) {
          mappedResources[entryId] = FHIRHelper.createInstanceFromFHIR('shr.core.ProcedureRequest', referencedEntry['resource'], 'undefined', shrId, allEntries, mappedResources, referencesOut);
        }
      }
      if (mappedResources[entryId]) {
        inst.relatedRequest.value = FHIRHelper.createReference(mappedResources[entryId], referencesOut);
      }
      else {
        const entryType = 'http://standardhealthrecord.org/spec/shr/core/ProcedureRequest';
        inst.relatedRequest.value = FHIRHelper.createReferenceWithoutObject(shrId, entryId, entryType);
      }
    }

Note associated FHIR mapping:

      {
        "id": "Procedure.request",
        "path": "Procedure.request",
        "short": "A request for this procedure",
        "definition": "A reference to a resource that contains details of the request for this procedure.",
        "min": 0,
        "max": "1",
        "base": {
          "path": "Procedure.request",
          "min": 0,
          "max": "1"
        },
        "type": [
          {
            "code": "Reference",
            "profile": [
              "http://hl7.org/fhir/us/shr/DSTU2/StructureDefinition/shr-core-ProcedureRequest"
            ]
          }
        ],
        "maxLength": 0,
        "mustSupport": false,
        "isModifier": false,
        "isSummary": false,
        "mapping": [
          {
            "identity": "shr",
            "map": "<shr.core.RelatedRequest>.<shr.core.MedicationRequest>"
          },
          {
            "identity": "shr",
            "map": "<shr.core.RelatedRequest>.<shr.core.ProcedureRequest>"
          },
          {
            "identity": "shr",
            "map": "<shr.core.RelatedRequest>.<shr.core.ReferralRequest>"
          }
        ]
      },