parent
6abfed603e
commit
d5a1b0cdf3
|
@ -348,7 +348,7 @@ public final class TerserUtil {
|
|||
public static void clearField(FhirContext theFhirContext, IBaseResource theResource, String theFieldName) {
|
||||
BaseRuntimeChildDefinition childDefinition =
|
||||
getBaseRuntimeChildDefinition(theFhirContext, theFieldName, theResource);
|
||||
clear(childDefinition.getAccessor().getValues(theResource));
|
||||
childDefinition.getMutator().setValue(theResource, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,6 +4,7 @@ import ca.uhn.fhir.context.FhirContext;
|
|||
import ca.uhn.fhir.context.RuntimeResourceDefinition;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
|
||||
import org.hl7.fhir.r4.model.Address;
|
||||
import org.hl7.fhir.r4.model.Claim;
|
||||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
import org.hl7.fhir.r4.model.DateType;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
|
@ -13,6 +14,7 @@ import org.hl7.fhir.r4.model.Identifier;
|
|||
import org.hl7.fhir.r4.model.Organization;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.PrimitiveType;
|
||||
import org.hl7.fhir.r4.model.Reference;
|
||||
import org.hl7.fhir.r4.model.StringType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -570,6 +572,25 @@ class TerserUtilTest {
|
|||
assertEquals("Test", p1.getAddress().get(1).getCity());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRemoveByFhirPath() {
|
||||
// arrange
|
||||
Claim claimWithReferences = createClaim();
|
||||
claimWithReferences.setPatient(new Reference("Patient/123"));
|
||||
String fhirPath = "patient";
|
||||
assertTrue(claimWithReferences.hasPatient());
|
||||
//act
|
||||
TerserUtil.clearFieldByFhirPath(ourFhirContext, claimWithReferences, fhirPath);
|
||||
//assert
|
||||
assertFalse(claimWithReferences.hasPatient());
|
||||
}
|
||||
|
||||
static Claim createClaim() {
|
||||
Claim claim = new Claim();
|
||||
claim.setStatus(Claim.ClaimStatus.ACTIVE);
|
||||
return claim;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetField() {
|
||||
Patient p1 = new Patient();
|
||||
|
|
Loading…
Reference in New Issue