|
| 1 | +package org.opencds.cqf.cql.ls.server.command; |
| 2 | + |
| 3 | +import java.util.Collections; |
| 4 | +import java.util.List; |
| 5 | +import java.util.Map; |
| 6 | +import java.util.Set; |
| 7 | + |
| 8 | +import org.hl7.fhir.instance.model.api.IBaseBundle; |
| 9 | +import org.hl7.fhir.instance.model.api.IBaseParameters; |
| 10 | +import org.hl7.fhir.instance.model.api.IBaseResource; |
| 11 | +import org.hl7.fhir.instance.model.api.IIdType; |
| 12 | +import org.opencds.cqf.fhir.api.Repository; |
| 13 | + |
| 14 | +import ca.uhn.fhir.context.FhirContext; |
| 15 | +import ca.uhn.fhir.context.api.BundleInclusionRule; |
| 16 | +import ca.uhn.fhir.model.api.IQueryParameterType; |
| 17 | +import ca.uhn.fhir.model.valueset.BundleTypeEnum; |
| 18 | +import ca.uhn.fhir.rest.api.MethodOutcome; |
| 19 | +import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; |
| 20 | + |
| 21 | +public class NoOpRepository implements Repository { |
| 22 | + |
| 23 | + private final FhirContext fhirContext; |
| 24 | + |
| 25 | + public NoOpRepository(FhirContext fhirContext) { |
| 26 | + this.fhirContext = fhirContext; |
| 27 | + } |
| 28 | + |
| 29 | + @Override |
| 30 | + public <T extends IBaseResource> MethodOutcome create(T arg0, Map<String, String> arg1) { |
| 31 | + throw new UnsupportedOperationException("Unimplemented method 'create'"); |
| 32 | + } |
| 33 | + |
| 34 | + @Override |
| 35 | + public <T extends IBaseResource, I extends IIdType> MethodOutcome delete(Class<T> arg0, I arg1, |
| 36 | + Map<String, String> arg2) { |
| 37 | + throw new UnsupportedOperationException("Unimplemented method 'delete'"); |
| 38 | + } |
| 39 | + |
| 40 | + @Override |
| 41 | + public FhirContext fhirContext() { |
| 42 | + return this.fhirContext; |
| 43 | + } |
| 44 | + |
| 45 | + @Override |
| 46 | + public <R extends IBaseResource, P extends IBaseParameters, T extends IBaseResource> R invoke(Class<T> arg0, |
| 47 | + String arg1, P arg2, Class<R> arg3, Map<String, String> arg4) { |
| 48 | + throw new UnsupportedOperationException("Unimplemented method 'invoke'"); |
| 49 | + } |
| 50 | + |
| 51 | + @Override |
| 52 | + public <R extends IBaseResource, P extends IBaseParameters, I extends IIdType> R invoke(I arg0, String arg1, P arg2, |
| 53 | + Class<R> arg3, Map<String, String> arg4) { |
| 54 | + throw new UnsupportedOperationException("Unimplemented method 'invoke'"); |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public <T extends IBaseResource, I extends IIdType> T read(Class<T> arg0, I arg1, Map<String, String> arg2) { |
| 59 | + throw new ResourceNotFoundException(arg1); |
| 60 | + } |
| 61 | + |
| 62 | + @SuppressWarnings("unchecked") |
| 63 | + @Override |
| 64 | + public <B extends IBaseBundle, T extends IBaseResource> B search(Class<B> arg0, Class<T> arg1, |
| 65 | + Map<String, List<IQueryParameterType>> arg2, Map<String, String> arg3) { |
| 66 | + var factory = this.fhirContext.newBundleFactory(); |
| 67 | + factory.addResourcesToBundle(Collections.emptyList(), BundleTypeEnum.SEARCHSET, "", BundleInclusionRule.BASED_ON_INCLUDES, Set.of()); |
| 68 | + return (B)factory.getResourceBundle(); |
| 69 | + } |
| 70 | + |
| 71 | + @Override |
| 72 | + public <T extends IBaseResource> MethodOutcome update(T arg0, Map<String, String> arg1) { |
| 73 | + throw new UnsupportedOperationException("Unimplemented method 'update'"); |
| 74 | + } |
| 75 | + |
| 76 | +} |
0 commit comments