You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug .copy() of org.hl7.fhir.dstu3.model.MedicationAdministration does not copy a dosage.extension of type Duration
To Reproduce
Create MedicationAdministration instance which includes a Duration in dosage.extension
Create a copy using .copy()
Expected behavior
The copy is exactly the same.
Environment
HAPI FHIR Version: 7.4.0
JDK: 21
Additional context
The culprit seems to be the missing Duration.copy() implementation. As I understand it, it was fixed for R4 in hapifhir/hapi-fhir#1820, but the issue is still present for STU3
Code to reproduce:
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.parser.IParser;
import org.hl7.fhir.dstu3.model.Duration;
import org.hl7.fhir.dstu3.model.Extension;
import org.hl7.fhir.dstu3.model.MedicationAdministration;
import org.hl7.fhir.dstu3.model.SimpleQuantity;
import java.util.List;
public class MedicationAdministrationCopyDefect {
public static void main(String[] ignoreMe) throws Exception {
IParser parser = FhirContext.forDstu3().newJsonParser().setPrettyPrint(true);
MedicationAdministration beforeCopy = createMedAdminWithDosageDurationExtension();
MedicationAdministration afterCopy = beforeCopy.copy();
System.out.println("---- BEFORE COPY (BEGIN)");
System.out.println(parser.encodeResourceToString(beforeCopy));
System.out.println("---- BEFORE COPY (END)");
System.out.println();
System.out.println("---- AFTER COPY (BEGIN)");
System.out.println(parser.encodeResourceToString(afterCopy));
System.out.println("---- AFTER COPY (END)");
}
private static MedicationAdministration createMedAdminWithDosageDurationExtension() {
MedicationAdministration resource = new MedicationAdministration();
resource.setId("12345");
var dosage = new MedicationAdministration.MedicationAdministrationDosageComponent();
dosage.setDose((SimpleQuantity) new SimpleQuantity().setValue(40))
.setExtension(List.of(new Extension()
.setUrl("http://duration")
.setValue(new Duration().setValue(5340000))));
resource.setDosage(dosage);
return resource;
}
}
Describe the bug
.copy()
oforg.hl7.fhir.dstu3.model.MedicationAdministration
does not copy a dosage.extension of type DurationTo Reproduce
.copy()
Expected behavior
The copy is exactly the same.
Environment
Additional context
The culprit seems to be the missing
Duration.copy()
implementation. As I understand it, it was fixed for R4 in hapifhir/hapi-fhir#1820, but the issue is still present for STU3Code to reproduce:
Output:
The text was updated successfully, but these errors were encountered: