生成的消息中有重复的 'contained' 个元素 - HAPI FHIR DSTU2HL7Org

Duplicate 'contained' elements in generated message - HAPI FHIR DSTU2HL7Org

我正在使用 HAPI FHIR DSTU2HL7Org 在远程服务器中创建 MedicationOrders。对象构造如下

MedicationOrder[] medicationOrder = null;
MedicationOrderDataWrapper[] medicationOrderWrapper = new MedicationOrderDataToolkit().getMedicationOrderDataWrapper(wrapper);

if(medicationOrderWrapper != null)
{
  medicationOrder = new MedicationOrder[medicationOrderWrapper.length];
  for(int i=0; i<medicationOrderWrapper.length; i++)
  {
    medicationOrder[i] = new MedicationOrder();
    MedicationOrderDosageInstructionComponent dosageInstruction = new MedicationOrderDosageInstructionComponent().setDose(medicationOrderWrapper[i].getDoseQuantity()).
        setTiming(medicationOrderWrapper[i].getTiming()).setAdditionalInstructions(medicationOrderWrapper[i].getAdditionalInstruction());

    medicationOrder[i].addDosageInstruction(dosageInstruction).setEncounterTarget(medicationOrderWrapper[i].getEncounter()).
    setMedication(medicationOrderWrapper[i].getMedicationCodeableConcept()).setPatientTarget(medicationOrderWrapper[i].getPatient()).setPrescriberTarget(medicationOrderWrapper[i].getPractitioner())
    .addExtension(medicationOrderWrapper[i].getExtension());

    medicationOrder[i].getContained().add(medicationOrder[i].getEncounterTarget());
    medicationOrder[i].getContained().add(medicationOrderWrapper[i].getOrganization());
    medicationOrder[i].getContained().add(medicationOrderWrapper[i].getLocation());
    medicationOrder[i].getContained().add(medicationOrder[i].getPatientTarget());
    medicationOrder[i].getContained().add(medicationOrder[i].getPrescriberTarget());

    medicationOrder[i].setEncounter(new Reference("#" + medicationOrder[i].getEncounterTarget().getId()))
    .setPatient(new Reference("#" + medicationOrder[i].getPatientTarget().getId()).setDisplay(medicationOrder[i].getPatientTarget().getName().get(0).getText()))
    .setPrescriber(new Reference("#" + medicationOrder[i].getPrescriberTarget().getId()).setDisplay(medicationOrder[i].getPrescriberTarget().getName().getText()))
    .setReason(medicationOrderWrapper[i].getReasonCodeableConcept()).addIdentifier(medicationOrderWrapper[i].getCosmicIdentifier());

但是此代码会导致生成的 xml 消息中包含重复的元素。 Organization 和 Location 元素分别出现了 3 次和 2 次,而 Patient、Practitioner 和 Encounter 只出现了一次。

有人可以解释一下吗?

这实际上听起来像是一个错误。您介意在 GitHub 问题跟踪器上提交报告吗?