Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SimpleWorkerContext in android environment does not load the dependencies of a npm FHIR package built for an IG #1455

Closed
joiskash opened this issue Oct 9, 2023 · 2 comments
Labels
question Further information is requested wontfix This will not be worked on

Comments

@joiskash
Copy link

joiskash commented Oct 9, 2023

We are currently using hapi version 5.6.36 .

We are using the SimpleWorkerContext to load the npm package. The npm package currently has the Resources for the specific implementation guide without any of the core Resources.

Is the SimpleWorkerContext expected to load the dependencies ? if yes how is this provided?

If not, what is the suggested way to implement IWorkerContext / Extend SimpleWorkerContext to make sure that the dependencies are loaded too.

This is how we are loading the npm package in android for the implementation guide.

val immunizationIg =
        "content/general/who-eir/packages/package.r4.tgz"

 val contextR4 =
        SimpleWorkerContext.fromPackage(
          NpmPackage.fromPackage(
            File(
              ClassLoader.getSystemResource(immunizationIg).file
            ).inputStream()),true).apply {
          setExpansionProfile(Parameters())
          isCanRunWithoutTerminology = true
        }

//We then use this context in the TransformSupportServices and StructureMapUtilities class

val transformSupportServices =
      TransformSupportServicesMatchBox(
        contextR4,
        outputs
      )
val structureMapUtilities =
        org.hl7.fhir.r4.utils.StructureMapUtilities(contextR4, transformSupportServices)

Any transformation that involves a target that is a FHIR resrouce from base fhir core r4 and whose StructureDefinition is missing from the package.r4.tgz from the npm package of the specific IG throws an error.
We copied all the files from the home/.fhir/packages/hl7.fhir.r4.core#4.0.1/package/ into the package.r4 folder , compressed it and used it as above. The transformation then passed.

@joiskash joiskash changed the title SimpleWorkerContext in android environment does not load the dependencies SimpleWorkerContext in android environment does not load the dependencies of a npm FHIR package built for an IG Oct 9, 2023
@joiskash
Copy link
Author

joiskash commented Oct 9, 2023

package org.smartregister.fhircore.engine.util.helper;

import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.context.IWorkerContext;
import org.hl7.fhir.r4.context.SimpleWorkerContext;
import org.hl7.fhir.utilities.npm.NpmPackage;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;

public class ComplexWorkerContext extends SimpleWorkerContext {
    public ComplexWorkerContext() throws FileNotFoundException, IOException, FHIRException {

    }
    public void loadFromMultiplePackages(ArrayList<NpmPackage> packages, Boolean allowDuplicates) throws IOException {
        this.setAllowLoadingDuplicates(allowDuplicates);
        for (int i=0;i<packages.size();i++){
            this.loadFromPackage(packages.get(i),null);
        }
    }
}

Is this a good pattern? Seems to work

@dotasek dotasek added the question Further information is requested label Oct 17, 2023
Copy link

stale bot commented Apr 13, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 5 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Apr 13, 2024
@stale stale bot closed this as completed Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants