Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
87b5ac2449
|
@ -179,9 +179,16 @@ public class FhirTerser {
|
|||
switch (theDefinition.getChildType()) {
|
||||
case PRIMITIVE_XHTML:
|
||||
case PRIMITIVE_DATATYPE:
|
||||
case RESOURCE_REF:
|
||||
// These are primitive types
|
||||
break;
|
||||
case RESOURCE_REF:
|
||||
ResourceReferenceDt resRefDt = (ResourceReferenceDt)theElement;
|
||||
if (resRefDt.getReference().getValue() == null && resRefDt.getResource() != null) {
|
||||
IResource theResource = resRefDt.getResource();
|
||||
BaseRuntimeElementCompositeDefinition<?> def = myContext.getResourceDefinition(theResource);
|
||||
visit(theResource, null, def, theCallback);
|
||||
}
|
||||
break;
|
||||
case RESOURCE_BLOCK:
|
||||
case COMPOSITE_DATATYPE:
|
||||
case RESOURCE: {
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
package ca.uhn.fhir.rest.server.audit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.AdverseReaction;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectSensitivityEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectTypeEnum;
|
||||
|
||||
public class AdverseReactionAuditor implements IResourceAuditor<AdverseReaction> {
|
||||
|
||||
private AdverseReaction myResource = null;
|
||||
|
||||
@Override
|
||||
public AdverseReaction getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResource(AdverseReaction resource) {
|
||||
myResource = resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuditable() {
|
||||
return myResource != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if(myResource == null) return null;
|
||||
return "AdverseReaction:" + myResource.getIdentifierFirstRep().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseIdentifierDt getIdentifier() {
|
||||
if(myResource == null) return null;
|
||||
return myResource.getIdentifierFirstRep();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectTypeEnum getType() {
|
||||
return SecurityEventObjectTypeEnum.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetail() {
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
details.put("subject", myResource.getSubject().getReference().getValue());
|
||||
details.put("version", myResource.getId().getVersionIdPart());
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectSensitivityEnum getSensitivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -78,6 +78,7 @@ public class DiagnosticReportAuditor implements IResourceAuditor<DiagnosticRepor
|
|||
Map<String, String> details = new HashMap<String, String>();
|
||||
details.put("dateIssued", myDiagnosticReport.getIssued().getValueAsString());
|
||||
details.put("version", myDiagnosticReport.getId().getVersionIdPart());
|
||||
details.put("subject", myDiagnosticReport.getSubject().getReference().getValue());
|
||||
return details;
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,7 @@ public class EncounterAuditor implements IResourceAuditor<Encounter> {
|
|||
details.put("service", myEncounter.getServiceProvider().getDisplay().getValue());
|
||||
details.put("type", myEncounter.getTypeFirstRep().getText().getValue());
|
||||
details.put("status", myEncounter.getStatus().getValueAsString());
|
||||
details.put("subject", myEncounter.getSubject().getReference().getValue());
|
||||
return details;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ public class MedicationPrescriptionAuditor implements IResourceAuditor<Medicatio
|
|||
|
||||
@Override
|
||||
public Map<String, String> getDetail() {
|
||||
return null; //no additional details required for audit?
|
||||
return null; //no additional details required for audit
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package ca.uhn.fhir.rest.server.audit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectSensitivityEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectTypeEnum;
|
||||
|
||||
public class ObservationAuditor implements IResourceAuditor<Observation> {
|
||||
|
||||
private Observation myResource = null;
|
||||
|
||||
@Override
|
||||
public Observation getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResource(Observation resource) {
|
||||
myResource = resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuditable() {
|
||||
return myResource != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if(myResource == null) return null;
|
||||
return "Observation:" + myResource.getName().getCodingFirstRep().getCode().getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseIdentifierDt getIdentifier() {
|
||||
return myResource.getIdentifier();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectTypeEnum getType() {
|
||||
return SecurityEventObjectTypeEnum.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetail() {
|
||||
if(myResource == null) return null;
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
details.put("dateIssued", myResource.getIssued().getValueAsString());
|
||||
details.put("version", myResource.getId().getVersionIdPart());
|
||||
details.put("subject", myResource.getSubject().getReference().getValue());
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectSensitivityEnum getSensitivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package ca.uhn.fhir.rest.server.audit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Procedure;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectSensitivityEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.SecurityEventObjectTypeEnum;
|
||||
|
||||
public class ProcedureAuditor implements IResourceAuditor<Procedure> {
|
||||
|
||||
private Procedure myResource = null;
|
||||
|
||||
@Override
|
||||
public Procedure getResource() {
|
||||
return myResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResource(Procedure resource) {
|
||||
myResource = resource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuditable() {
|
||||
return myResource != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if(myResource == null) return null;
|
||||
return "Procedure:" + myResource.getId().getIdPart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseIdentifierDt getIdentifier() {
|
||||
if(myResource == null) return null;
|
||||
return new IdentifierDt(myResource.getId().getResourceType(), myResource.getId().getIdPart());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectTypeEnum getType() {
|
||||
return SecurityEventObjectTypeEnum.OTHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDetail() {
|
||||
if(myResource == null) return null;
|
||||
Map<String, String> details = new HashMap<String, String>();
|
||||
details.put("subject", myResource.getSubject().getReference().getValue());
|
||||
return details;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SecurityEventObjectSensitivityEnum getSensitivity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -12,13 +12,20 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.model.api.Bundle;
|
||||
import ca.uhn.fhir.model.api.IResource;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodeableConceptDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.CodingDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
|
||||
import ca.uhn.fhir.model.dstu.composite.ResourceReferenceDt;
|
||||
import ca.uhn.fhir.model.dstu.resource.Composition;
|
||||
import ca.uhn.fhir.model.dstu.resource.Composition.Section;
|
||||
import ca.uhn.fhir.model.dstu.resource.Condition;
|
||||
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
|
||||
import ca.uhn.fhir.model.dstu.resource.Observation;
|
||||
import ca.uhn.fhir.model.dstu.resource.Patient;
|
||||
import ca.uhn.fhir.model.dstu.resource.Practitioner;
|
||||
import ca.uhn.fhir.model.dstu.valueset.AdministrativeGenderCodesEnum;
|
||||
|
@ -26,6 +33,7 @@ import ca.uhn.fhir.model.dstu.valueset.ConditionStatusEnum;
|
|||
import ca.uhn.fhir.model.dstu.valueset.NameUseEnum;
|
||||
import ca.uhn.fhir.model.dstu.valueset.PractitionerRoleEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
import ca.uhn.fhir.rest.server.RestfulServer;
|
||||
|
||||
/**
|
||||
* Initially contributed by Alexander Kley for bug #29
|
||||
|
@ -155,5 +163,84 @@ public class ContainedResourceEncodingTest {
|
|||
Assert.assertArrayEquals(expectedCompXml.getBytes(), actualCompXml.getBytes());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBundleWithContained() {
|
||||
|
||||
DiagnosticReport dr = new DiagnosticReport();
|
||||
dr.setId(new IdDt("DiagnosticReport","123"));
|
||||
|
||||
Observation observation = new Observation();
|
||||
|
||||
CodeableConceptDt obsName = new CodeableConceptDt();
|
||||
obsName.setText("name");
|
||||
observation.setName(obsName);
|
||||
|
||||
ResourceReferenceDt result = dr.addResult();
|
||||
result.setResource(observation);
|
||||
|
||||
ArrayList<ResourceReferenceDt> performers = new ArrayList<ResourceReferenceDt>();
|
||||
ResourceReferenceDt performer = new ResourceReferenceDt();
|
||||
|
||||
Practitioner p = new Practitioner();
|
||||
p.setId(new IdDt(UUID.randomUUID().toString()));
|
||||
p.addIdentifier().setSystem("DoctorID").setValue("4711");
|
||||
p.addRole(PractitionerRoleEnum.DOCTOR);
|
||||
p.setName(new HumanNameDt().addFamily("Mueller").addGiven("Klaus").addPrefix("Prof. Dr."));
|
||||
|
||||
performer.setResource(p);
|
||||
performers.add(performer);
|
||||
observation.setPerformer(performers);
|
||||
|
||||
|
||||
List<IResource> list = new ArrayList<IResource>();
|
||||
list.add(dr);
|
||||
Bundle bundle = RestfulServer.createBundleFromResourceList(new FhirContext(), null, list, null, null, 0);
|
||||
|
||||
IParser parser = this.ctx.newXmlParser().setPrettyPrint(true);
|
||||
String xml = parser.encodeBundleToString(bundle);
|
||||
Assert.assertTrue(xml.contains("Mueller"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBundleWithContainedWithNoIdDt() {
|
||||
|
||||
DiagnosticReport dr = new DiagnosticReport();
|
||||
dr.setId(new IdDt("DiagnosticReport","123"));
|
||||
|
||||
Observation observation = new Observation();
|
||||
|
||||
CodeableConceptDt obsName = new CodeableConceptDt();
|
||||
obsName.setText("name");
|
||||
observation.setName(obsName);
|
||||
|
||||
ResourceReferenceDt result = dr.addResult();
|
||||
result.setResource(observation);
|
||||
|
||||
ArrayList<ResourceReferenceDt> performers = new ArrayList<ResourceReferenceDt>();
|
||||
ResourceReferenceDt performer = new ResourceReferenceDt();
|
||||
|
||||
Practitioner p = new Practitioner();
|
||||
// no idDt on practitioner p
|
||||
p.addIdentifier().setSystem("DoctorID").setValue("4711");
|
||||
p.addRole(PractitionerRoleEnum.DOCTOR);
|
||||
p.setName(new HumanNameDt().addFamily("Mueller").addGiven("Klaus").addPrefix("Prof. Dr."));
|
||||
|
||||
performer.setResource(p);
|
||||
performers.add(performer);
|
||||
observation.setPerformer(performers);
|
||||
|
||||
|
||||
List<IResource> list = new ArrayList<IResource>();
|
||||
list.add(dr);
|
||||
Bundle bundle = RestfulServer.createBundleFromResourceList(new FhirContext(), null, list, null, null, 0);
|
||||
|
||||
IParser parser = this.ctx.newXmlParser().setPrettyPrint(true);
|
||||
String xml = parser.encodeBundleToString(bundle);
|
||||
Assert.assertTrue(xml.contains("Mueller"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue