Skip to content

Commit

Permalink
Resolve many TODOs. More refactoring and renaming. Better testing. Ja…
Browse files Browse the repository at this point in the history
…vadoc. Spotless.
  • Loading branch information
lukedegruchy committed Jan 22, 2025
1 parent 169a10d commit 7e2ce77
Show file tree
Hide file tree
Showing 11 changed files with 516 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ static Object[] tryBuildMethodParams(Method theMethod, Object[] theMethodParams)
theMethod, parameterTypeWithOperationEmbeddedParam, theMethodParams);
}

// LUKETODO: UNIT TEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
private static Object[] determineMethodParamsForOperationEmbeddedParams(
Method theMethod, Class<?> theParameterTypeWithOperationEmbeddedParam, Object[] theMethodParams)
throws InvocationTargetException, IllegalAccessException, InstantiationException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class EmbeddedParameterConverter {
private final FhirContext myContext;
private final Method myMethod;
private final Operation myOperation;
// LUKETODO: warning?
private final Class<?>[] myParameterTypes;
private final Class<?> myOperationEmbeddedType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ public static List<IParameter> getResourceParameters(
parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(methodToUse, paramIndex);
declaredParameterType = parameterType;
}
// LUKETODO: as a guard: if this is still a Collection, then throw because something went wrong
if (Collection.class.isAssignableFrom(parameterType)) {
throw new ConfigurationException(
Msg.code(401) + "Argument #" + paramIndex + " of Method '" + methodToUse.getName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
import ca.uhn.fhir.util.FhirTerser;
import ca.uhn.fhir.util.ReflectionUtil;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.*;

Expand Down Expand Up @@ -141,13 +142,23 @@ public String getParamType() {
return myParamType;
}

@VisibleForTesting
public Class<? extends Collection> getInnerCollectionType() {
return myInnerCollectionType;
}

public String getSearchParamType() {
if (mySearchParameterBinding != null) {
return mySearchParameterBinding.getParamType().getCode();
}
return null;
}

@VisibleForTesting
public String getOperationName() {
return myOperationName;
}

@SuppressWarnings("unchecked")
@Override
public void initializeTypes(
Expand Down Expand Up @@ -197,7 +208,6 @@ public void initializeTypes(
* should probably clean this up..
*/
if (!myParameterType.equals(IBase.class) && !myParameterType.equals(String.class)) {
// LUKETODO: this is where we get the Exception: add an else if
if (IBaseResource.class.isAssignableFrom(myParameterType) && myParameterType.isInterface()) {
myParamType = "Resource";
} else if (IBaseReference.class.isAssignableFrom(myParameterType)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
import ca.uhn.fhir.util.FhirTerser;
import ca.uhn.fhir.util.ReflectionUtil;
import com.google.common.annotations.VisibleForTesting;
import org.apache.commons.lang3.Validate;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseCoding;
Expand Down Expand Up @@ -149,13 +150,23 @@ public String getParamType() {
return myParamType;
}

@VisibleForTesting
public Class<? extends Collection> getInnerCollectionType() {
return myInnerCollectionType;
}

public String getSearchParamType() {
if (mySearchParameterBinding != null) {
return mySearchParameterBinding.getParamType().getCode();
}
return null;
}

@VisibleForTesting
String getOperationName() {
return myOperationName;
}

@SuppressWarnings("unchecked")
@Override
public void initializeTypes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ public CareGapsOperationProvider(
myStringTimePeriodHandler = theStringTimePeriodHandler;
}

// LUKETODO: fix javadoc
/**
* Implements the <a href=
* "http://build.fhir.org/ig/HL7/davinci-deqm/OperationDefinition-care-gaps.html">$care-gaps</a>
Expand All @@ -74,19 +73,7 @@ public CareGapsOperationProvider(
*
* @param theRequestDetails generally auto-populated by the HAPI server
* framework.
* @param thePeriodStart the start of the gaps through period
* @param thePeriodEnd the end of the gaps through period
* @param theSubject a reference to either a Patient or Group for which
* the gaps in care report(s) will be generated
* @param theStatus the status code of gaps in care reports that will be
* included in the result
* @param theMeasureId the id of Measure(s) for which the gaps in care
* report(s) will be calculated
* @param theMeasureIdentifier the identifier of Measure(s) for which the gaps in
* care report(s) will be calculated
* @param theMeasureUrl the canonical URL of Measure(s) for which the gaps
* in care report(s) will be calculated
* @param theNonDocument defaults to 'false' which returns standard 'document' bundle for `$care-gaps`.
* @param theParams Please refer to the javadoc for {@link CareGapsParams} for more information on the parameters.
* If 'true', this will return summarized subject bundle with only detectedIssue resource.
* @return Parameters of bundles of Care Gap Measure Reports
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,50 @@
import org.hl7.fhir.r4.model.CanonicalType;

import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

/**
* Non-RequestDetails parameters for the <a href=
* "http://build.fhir.org/ig/HL7/davinci-deqm/OperationDefinition-care-gaps.html">$care-gaps</a>
* operation found in the
* <a href="http://build.fhir.org/ig/HL7/davinci-deqm/index.html">Da Vinci DEQM
* FHIR Implementation Guide</a> that overrides the <a href=
* "http://build.fhir.org/operation-measure-care-gaps.html">$care-gaps</a>
* operation found in the
* <a href="http://hl7.org/fhir/R4/clinicalreasoning-module.html">FHIR Clinical
* Reasoning Module</a>.
* <p/>
* The operation calculates measures describing gaps in care. For more details,
* reference the <a href=
* "http://build.fhir.org/ig/HL7/davinci-deqm/gaps-in-care-reporting.html">Gaps
* in Care Reporting</a> section of the
* <a href="http://build.fhir.org/ig/HL7/davinci-deqm/index.html">Da Vinci DEQM
* FHIR Implementation Guide</a>.
* <p/>
* A Parameters resource that includes zero to many document bundles that
* include Care Gap Measure Reports will be returned.
* <p/>
* Usage:
* URL: [base]/Measure/$care-gaps
* <p/>
* myRequestDetails generally auto-populated by the HAPI server
* framework.
* myPeriodStart the start of the gaps through period
* myPeriodEnd the end of the gaps through period
* mySubject a reference to either a Patient or Group for which
* the gaps in care report(s) will be generated
* myStatus the status code of gaps in care reports that will be
* included in the result
* myMeasureId the id of Measure(s) for which the gaps in care
* report(s) will be calculated
* myMeasureIdentifier the identifier of Measure(s) for which the gaps in
* care report(s) will be calculated
* myMeasureUrl the canonical URL of Measure(s) for which the gaps
* in care report(s) will be calculated
* myNonDocument defaults to 'false' which returns standard 'document' bundle for `$care-gaps`.
* If 'true', this will return summarized subject bundle with only detectedIssue resource.
*/
public class CareGapsParams {
@OperationEmbeddedParam(name = "periodStart")
private final String myPeriodStart;
Expand Down Expand Up @@ -51,6 +93,17 @@ public CareGapsParams(
this.myNonDocument = myNonDocument;
}

private CareGapsParams(Builder builder) {
this.myPeriodStart = builder.myPeriodStart;
this.myPeriodEnd = builder.myPeriodEnd;
this.mySubject = builder.mySubject;
this.myStatus = builder.myStatus;
this.myMeasureId = builder.myMeasureId;
this.myMeasureIdentifier = builder.myMeasureIdentifier;
this.myMeasureUrl = builder.myMeasureUrl;
this.myNonDocument = builder.myNonDocument;
}

public String getPeriodStart() {
return myPeriodStart;
}
Expand Down Expand Up @@ -83,6 +136,33 @@ public BooleanType getNonDocument() {
return myNonDocument;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
CareGapsParams that = (CareGapsParams) o;
return Objects.equals(myPeriodStart, that.myPeriodStart)
&& Objects.equals(myPeriodEnd, that.myPeriodEnd)
&& Objects.equals(mySubject, that.mySubject)
&& Objects.equals(myStatus, that.myStatus)
&& Objects.equals(myMeasureId, that.myMeasureId)
&& Objects.equals(myMeasureIdentifier, that.myMeasureIdentifier)
&& Objects.equals(myMeasureUrl, that.myMeasureUrl)
&& Objects.equals(myNonDocument, that.myNonDocument);
}

@Override
public int hashCode() {
return Objects.hash(
myPeriodStart,
myPeriodEnd,
mySubject,
myStatus,
myMeasureId,
myMeasureIdentifier,
myMeasureUrl,
myNonDocument);
}

@Override
public String toString() {
return new StringJoiner(", ", CareGapsParams.class.getSimpleName() + "[", "]")
Expand All @@ -96,4 +176,63 @@ public String toString() {
.add("myNonDocument=" + myNonDocument)
.toString();
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String myPeriodStart;
private String myPeriodEnd;
private String mySubject;
private List<String> myStatus;
private List<String> myMeasureId;
private List<String> myMeasureIdentifier;
private List<CanonicalType> myMeasureUrl;
private BooleanType myNonDocument;

public Builder setPeriodStart(String myPeriodStart) {
this.myPeriodStart = myPeriodStart;
return this;
}

public Builder setPeriodEnd(String myPeriodEnd) {
this.myPeriodEnd = myPeriodEnd;
return this;
}

public Builder setSubject(String mySubject) {
this.mySubject = mySubject;
return this;
}

public Builder setStatus(List<String> myStatus) {
this.myStatus = myStatus;
return this;
}

public Builder setMeasureId(List<String> myMeasureId) {
this.myMeasureId = myMeasureId;
return this;
}

public Builder setMeasureIdentifier(List<String> myMeasureIdentifier) {
this.myMeasureIdentifier = myMeasureIdentifier;
return this;
}

public Builder setMeasureUrl(List<CanonicalType> myMeasureUrl) {
this.myMeasureUrl = myMeasureUrl;
return this;
}

public Builder setNonDocument(BooleanType myNonDocument) {
this.myNonDocument = myNonDocument;
return this;
}

public CareGapsParams build() {
return new CareGapsParams(this);
}
}
}
Loading

0 comments on commit 7e2ce77

Please sign in to comment.