Address review comments.

This commit is contained in:
Diederik Muylwyk 2019-08-02 14:45:59 -04:00
parent ca01f31ca9
commit 345ce880ce
1 changed files with 7 additions and 25 deletions

View File

@ -20,7 +20,6 @@ package ca.uhn.fhir.cli;
* #L% * #L%
*/ */
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc; import ca.uhn.fhir.jpa.term.IHapiTerminologyLoaderSvc;
import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor; 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.Options;
import org.apache.commons.cli.ParseException; import org.apache.commons.cli.ParseException;
import org.hl7.fhir.instance.model.api.IBaseParameters; import org.hl7.fhir.instance.model.api.IBaseParameters;
import org.hl7.fhir.r4.model.CodeSystem;
import static org.apache.commons.lang3.StringUtils.isBlank; import static org.apache.commons.lang3.StringUtils.isBlank;
@ -66,7 +64,6 @@ public class UploadTerminologyCommand extends BaseCommand {
@Override @Override
public void run(CommandLine theCommandLine) throws ParseException { public void run(CommandLine theCommandLine) throws ParseException {
parseFhirContext(theCommandLine); parseFhirContext(theCommandLine);
FhirContext ctx = getFhirContext();
String termUrl = theCommandLine.getOptionValue("u"); String termUrl = theCommandLine.getOptionValue("u");
if (isBlank(termUrl)) { if (isBlank(termUrl)) {
@ -94,30 +91,15 @@ public class UploadTerminologyCommand extends BaseCommand {
ourLog.info("Beginning upload - This may take a while..."); ourLog.info("Beginning upload - This may take a while...");
IBaseParameters response; IBaseParameters response = client
switch (myFhirCtx.getVersion().getVersion()) {
case DSTU3:
response = client
.operation() .operation()
.onType(org.hl7.fhir.dstu3.model.CodeSystem.class) .onType(myFhirCtx.getResourceDefinition("CodeSystem").getImplementingClass())
.named(UPLOAD_EXTERNAL_CODE_SYSTEM) .named(UPLOAD_EXTERNAL_CODE_SYSTEM)
.withParameters(inputParameters) .withParameters(inputParameters)
.execute(); .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());
}
ourLog.info("Upload complete!"); ourLog.info("Upload complete!");
ourLog.info("Response:\n{}", ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response)); ourLog.info("Response:\n{}", myFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(response));
} }
} }