From 345ce880ce6ef5bbb3233b59c00c3da2f244c811 Mon Sep 17 00:00:00 2001 From: Diederik Muylwyk Date: Fri, 2 Aug 2019 14:45:59 -0400 Subject: [PATCH] Address review comments. --- .../fhir/cli/UploadTerminologyCommand.java | 32 ++++--------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java index 0c7a9e240e2..eca0cf6da8d 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java @@ -20,7 +20,6 @@ package ca.uhn.fhir.cli; * #L% */ -import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; @@ -29,7 +28,6 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; import org.hl7.fhir.instance.model.api.IBaseParameters; -import org.hl7.fhir.r4.model.CodeSystem; import static org.apache.commons.lang3.StringUtils.isBlank; @@ -66,7 +64,6 @@ public class UploadTerminologyCommand extends BaseCommand { @Override public void run(CommandLine theCommandLine) throws ParseException { parseFhirContext(theCommandLine); - FhirContext ctx = getFhirContext(); String termUrl = theCommandLine.getOptionValue("u"); if (isBlank(termUrl)) { @@ -94,30 +91,15 @@ public class UploadTerminologyCommand extends BaseCommand { ourLog.info("Beginning upload - This may take a while..."); - IBaseParameters response; - switch (myFhirCtx.getVersion().getVersion()) { - case DSTU3: - response = client - .operation() - .onType(org.hl7.fhir.dstu3.model.CodeSystem.class) - .named(UPLOAD_EXTERNAL_CODE_SYSTEM) - .withParameters(inputParameters) - .execute(); - break; - case R4: - response = client - .operation() - .onType(CodeSystem.class) - .named(UPLOAD_EXTERNAL_CODE_SYSTEM) - .withParameters(inputParameters) - .execute(); - break; - default: - throw new UnsupportedOperationException("This command does not currently support " + myFhirCtx.getVersion().getVersion()); - } + IBaseParameters response = client + .operation() + .onType(myFhirCtx.getResourceDefinition("CodeSystem").getImplementingClass()) + .named(UPLOAD_EXTERNAL_CODE_SYSTEM) + .withParameters(inputParameters) + .execute(); ourLog.info("Upload complete!"); - ourLog.info("Response:\n{}", ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); + ourLog.info("Response:\n{}", myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); } }