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

Customized id conversion to use getIdPart instead of getValue. #111

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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