Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate contained resource #814

Closed
franktao2008 opened this issue Dec 27, 2017 · 4 comments
Closed

Duplicate contained resource #814

franktao2008 opened this issue Dec 27, 2017 · 4 comments

Comments

@franktao2008
Copy link
Contributor

@franktao2008 franktao2008 commented Dec 27, 2017

MedicationDispenseTester.zip

A MedicationDispense references to a Medication and a MedicationRequest, the MedicationRequest references to the same Medication. When the Medication resource is added as contained resource in the MedicationDispense, the Medication resource is listed twice as a contained resource. The issue appears on HAPI 2.5, 3.0.0 and 3.1.0. Here is the json output. The sample code is attached.
{
"resourceType": "MedicationDispense",
"id": "1234567890",
"meta": {
"lastUpdated": "2017-12-27T10:33:29.978-05:00"
},
"contained": [
{
"resourceType": "Medication",
"id": "Medication1"

},
{
"resourceType": "MedicationRequest",
"id": "MedRequest1",
"identifier": [
{
"value": "MedRequest1"
}
],
"intent": "order",
"medicationReference": {
"reference": "#Medication1"
}
},
{
"resourceType": "Medication",
"id": "Medication1"

}
],
"identifier": [
{
"value": "1234567890"
}
],
"status": "completed",
"medicationReference": {
"reference": "#Medication1"
},
"authorizingPrescription": [
{
"reference": "#MedRequest1"
}
]
}

Frank Tao

@franktao2008
Copy link
Contributor Author

@franktao2008 franktao2008 commented Dec 27, 2017

The issue is at hapi-fhir-base/BaseParser.java recursive call at line 220
containResourcesForEncoding(theContained, potentialTarget, theTarget);

jamesagnew added a commit that referenced this issue Feb 12, 2018
@jamesagnew
Copy link
Collaborator

@jamesagnew jamesagnew commented Feb 12, 2018

Hi @franktao2008 - I have added two test cases, and I am not able to reproduce this issue. Would you mind to look at 84dcd51 to compare it to your setup to see if there is anything obvious that I'm doing wrong?

Tastelezz pushed a commit to Tastelezz/hapi-fhir that referenced this issue Feb 20, 2018
@franktao2008
Copy link
Contributor Author

@franktao2008 franktao2008 commented Feb 28, 2018

@jamesagnew
it's reproduced by modify your second test case testDuplicateContainedResourcesNotOutputtedTwiceWithManualIds of #814

  1. Create a medRef object and assign the id
  2. md.setMedication to the medRef instead of new Reference(med) which creates a different object ref
  3. add to the contained resource, here is modified code.

   MedicationDispense md = new MedicationDispense();
   MedicationRequest mr = new MedicationRequest();
    mr.setId("#MR");
    md.addAuthorizingPrescription().setResource(mr);

    Medication med = new Medication();
    med.setId("#MED");
    
    Reference medRef = new Reference();
    medRef.setReference("#MED");
            
    md.setMedication(medRef);
    mr.setMedication(medRef);

    md.getContained().add(mr);
    md.getContained().add(med);

.......

@franktao2008
Copy link
Contributor Author

@franktao2008 franktao2008 commented Mar 2, 2018

Closed with a mistake

@jamesagnew jamesagnew closed this in 0c0b9bd Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.