Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Customized id conversion to use getIdPart instead of getValue.
Browse files Browse the repository at this point in the history
  • Loading branch information
bashir2 committed Feb 23, 2021
1 parent ee65d1b commit febbef9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import ca.uhn.fhir.context.BaseRuntimeChildDefinition;
import ca.uhn.fhir.context.BaseRuntimeElementDefinition;
import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.IPrimitiveType;

public abstract class PrimitiveConverter<T> extends HapiConverter<T> {
Expand Down Expand Up @@ -54,13 +55,19 @@ public void toHapi(Object input, IPrimitiveType primitive) {
primitive.setValue(input);
}

protected Object fromHapi(IIdType id) {
return id.getIdPart();
}

protected Object fromHapi(IPrimitiveType primitive) {
return primitive.getValue();
}

@Override
public Object fromHapi(Object input) {

if (input instanceof IIdType) {
return fromHapi((IIdType) input);
}
return fromHapi((IPrimitiveType) input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ private void checkPatients(Dataset<Row> patients, SparkRowConverter patientConve
Assert.assertEquals(3, patientIds.size());

List<String> expectedIds = ImmutableList.of(
"Patient/6666001",
"Patient/1032702",
"Patient/9995679");
"6666001",
"1032702",
"9995679");

Assert.assertTrue(patientIds.containsAll(expectedIds));
}
Expand All @@ -158,11 +158,11 @@ private void checkConditions(Dataset<Row> conditions, SparkRowConverter conditio
Assert.assertEquals(5, conditionIds.size());

List<String> expectedIds = ImmutableList.of(
"Condition/119",
"Condition/120",
"Condition/121",
"Condition/122",
"Condition/123");
"119",
"120",
"121",
"122",
"123");

Assert.assertTrue(conditionIds.containsAll(expectedIds));
}
Expand Down

0 comments on commit febbef9

Please sign in to comment.