hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.05k stars 1.34k forks source link

Hapi-fhir-cli upload-igpack supports FHIR version R4+ #1474

Open shansamlu opened 5 years ago

shansamlu commented 5 years ago

Describe the issue Please continue to support upload-igpack for FHIR version R4.

sams-work-mbp:hapi-fhir-4.0.0-cli sl9$ ./hapi-fhir-cli upload-igpack -v r4 -t http://localhost:8080/hapi-fhir-jpaserver/fhir/ -u http://build.fhir.org/ig/HL7/genomics-reporting/package.tgz
------------------------------------------------------------
🔥  HAPI FHIR 4.0.0 - Command Line Tool
------------------------------------------------------------
Process ID                      : 9136@sams-work-mbp.ad.bcm.edu
Max configured JVM memory (Xmx) : 3.6GB
Detected Java version           : 1.8.0_121
------------------------------------------------------------
2019-09-05 15:12:07.435 [main] INFO  c.u.f.c.BaseCommand Downloading from remote url: http://build.fhir.org/ig/HL7/genomics-reporting/package.tgz
393 KB [*****************************************         ]
2019-09-05 15:12:07.499 [main] INFO  c.u.f.c.BaseCommand Successfully Loaded example pack (473 KB)
Invalid command options for command: upload-igpack
  This command does not support FHIR version R4

Usage:
  hapi-fhir-cli upload-igpack [options]

Uploads an Implementation Guide Validation Pack

Options:
  -t,--target <arg>            Base URL for the target server (e.g. "http://example.com/fhir")
  -u,--url <arg>               The URL to the validation.pack file, e.g. http://hl7.org/fhir/us/core/validator.pack
  -v,--fhir-version <version>  The FHIR version being used. Valid values: dstu2, dstu3, r4, r5

2019-09-05 15:12:07.508 [Thread-0] INFO  ca.uhn.fhir.cli.App HAPI FHIR is shutting down...

Environment (please complete the following information):

krileyInfor commented 4 years ago

Same problem... any suggestions...

psavva commented 4 years ago

Hi @jamesagnew

I have also faced this same issue, and have looked into the implementation. As per the hapi-fhir-cli, it should support: -v,--fhir-version The FHIR version being used. Valid values: dstu2, dstu3, r4, r5

However, as per the implementation, it only supports "DSTU3" https://github.com/jamesagnew/hapi-fhir/blob/22413911bff4fc9de814982e74facdfd5509b0f2/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/IgPackUploader.java#L91

for (File nextFile : files) {
            FhirContext ctx = getFhirContext();
            switch (ctx.getVersion().getVersion()) {
                case DSTU3:
                    IgPackParserDstu3 packParser = new IgPackParserDstu3(ctx);
                    IValidationSupport ig = null;
                    try {
                        ig = packParser.parseIg(new FileInputStream(nextFile), nextFile.getName());
                    } catch (FileNotFoundException e) {
                        throw new CommandFailureException(e);
                    }
                    Iterable<IBaseResource> conformanceResources = ig.fetchAllConformanceResources();
                    for (IBaseResource nextResource : conformanceResources) {
                        String nextResourceUrl = ((IPrimitiveType<?>)ctx.newTerser().getSingleValueOrNull(nextResource, "url")).getValueAsString();
                        ourLog.info("Uploading resource: {}", nextResourceUrl);
                        client
                            .update()
                            .resource(nextResource)
                            .conditional()
                            .and(StructureDefinition.URL.matches().value(nextResourceUrl))
                            .execute();
                    }
                    break;
                default:
                    throw new ParseException("This command does not support FHIR version " + ctx.getVersion().getVersion());
            }
nd-siouxfan commented 2 years ago

Any idea/workaround on this? Seems like a pretty big gap IMHO.....