use of org.hl7.fhir.r4.model.DomainResource in project cqf-ruler by DBCG.
the class ActivityDefinitionApplyProviderIT method testActivityDefinitionApply.
@Test
public void testActivityDefinitionApply() throws Exception {
DomainResource activityDefinition = (DomainResource) activityDefinitions.get("opioidcds-risk-assessment-request");
// Patient First
Map<String, IBaseResource> resources = uploadTests("test/activitydefinition/Patient");
IBaseResource patient = resources.get("ExamplePatient");
Resource applyResult = activityDefinitionApplyProvider.apply(new SystemRequestDetails(), activityDefinition.getIdElement(), patient.getIdElement().getIdPart(), null, null, null, null, null, null, null, null);
assertTrue(applyResult instanceof ProcedureRequest);
assertEquals("454281000124100", ((ProcedureRequest) applyResult).getCode().getCoding().get(0).getCode());
}
use of org.hl7.fhir.r4.model.DomainResource in project quality-measure-and-cohort-service by Alvearie.
the class CDMMeasureEvaluationTest method testDefinesOnMeasureReport.
@Test
public void testDefinesOnMeasureReport() {
MeasureReport report = new MeasureReport();
Map<VersionedIdentifier, Map<String, Object>> expectedResults = setupTestExpectedResultsContext();
CDMContext defineContext = setupTestDefineContext(expectedResults);
CDMMeasureEvaluation.addDefineEvaluationToReport(report, defineContext, DefineReturnOptions.ALL);
assertEquals(5, report.getExtension().size());
int index = 0;
for (Entry<VersionedIdentifier, Map<String, Object>> expectedLibraryResults : expectedResults.entrySet()) {
for (Entry<String, Object> defineResult : expectedLibraryResults.getValue().entrySet()) {
Extension extension = report.getExtension().get(index++);
assertEquals(MeasureEvidenceHelper.createEvidenceKey(expectedLibraryResults.getKey(), defineResult.getKey()), extension.getExtensionByUrl(CDMConstants.EVIDENCE_TEXT_URL).getValue().primitiveValue());
// hack because Type does not return equals for 2 identical objects :(
Type returnType = extension.getExtensionByUrl(CDMConstants.EVIDENCE_VALUE_URL).getValue();
if (defineResult.getValue() instanceof Boolean) {
assertTrue(returnType.isBooleanPrimitive());
assertEquals(defineResult.getValue(), ((BooleanType) returnType).booleanValue());
} else if (defineResult.getValue() instanceof String) {
assertTrue(returnType.isPrimitive());
assertEquals(defineResult.getValue(), returnType.primitiveValue());
} else if (defineResult.getValue() instanceof DomainResource) {
assertTrue(returnType instanceof Reference);
}
}
}
}
use of org.hl7.fhir.r4.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class CCDAConverter method addReference.
protected String addReference(DomainResource r, String title, String id) throws Exception {
if (r.getText() == null)
r.setText(new Narrative());
if (r.getText().getDiv() == null) {
r.getText().setStatus(NarrativeStatus.GENERATED);
new NarrativeGenerator("", "", context).generate(r);
}
r.setMeta(new Meta().setLastUpdatedElement(InstantType.now()));
r.setId(id);
feed.getEntry().add(new BundleEntryComponent().setResource(r));
return id;
}
use of org.hl7.fhir.r4.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class ArgonautConverter method saveResource.
private void saveResource(Resource resource, String extraType) throws Exception {
if (!WANT_SAVE)
return;
DomainResource dr = null;
if (resource instanceof DomainResource) {
dr = (DomainResource) resource;
if (!dr.hasText()) {
NarrativeGenerator generator = new NarrativeGenerator("", "", context);
generator.generate(dr);
}
}
XmlParser xparser = new XmlParser();
xparser.setOutputStyle(OutputStyle.PRETTY);
JsonParser jparser = new JsonParser();
jparser.setOutputStyle(OutputStyle.PRETTY);
ByteArrayOutputStream ba = new ByteArrayOutputStream();
xparser.compose(ba, resource);
ba.close();
byte[] srcX = ba.toByteArray();
ba = new ByteArrayOutputStream();
jparser.compose(ba, resource);
ba.close();
byte[] srcJ = ba.toByteArray();
String rn = resource.getResourceType().toString();
if (extraType != null)
rn = rn + extraType;
zipX.addBytes(resource.getId() + ".xml", srcX, false);
zipJ.addBytes(resource.getId() + ".json", srcJ, false);
if (!zipsX.containsKey(rn)) {
zipsX.put(rn, new ZipGenerator(Utilities.path(destFolder, "xml/type", rn + ".xml.zip")));
zipsJ.put(rn, new ZipGenerator(Utilities.path(destFolder, "json/type", rn + ".json.zip")));
stats.put(rn, new Stats());
}
zipsJ.get(rn).addBytes(resource.getId() + ".json", srcJ, false);
zipsX.get(rn).addBytes(resource.getId() + ".xml", srcX, false);
Stats ss = stats.get(rn);
ss.setInstances(ss.getInstances() + 1);
String profile = resource.getUserString("profile");
validate(srcX, profile, resource, ss);
}
use of org.hl7.fhir.r4.model.DomainResource in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generateDocumentNarrative.
public XhtmlNode generateDocumentNarrative(Bundle feed) {
/*
When the document is presented for human consumption, applications must present the collated narrative portions of the following resources in order:
* The Composition resource
* The Subject resource
* Resources referenced in the section.content
*/
XhtmlNode root = new XhtmlNode(NodeType.Element, "div");
Composition comp = (Composition) feed.getEntry().get(0).getResource();
root.getChildNodes().add(comp.getText().getDiv());
Resource subject = ResourceUtilities.getById(feed, null, comp.getSubject().getReference());
if (subject != null && subject instanceof DomainResource) {
root.addTag("hr");
root.getChildNodes().add(((DomainResource) subject).getText().getDiv());
}
List<SectionComponent> sections = comp.getSection();
renderSections(feed, root, sections, 1);
return root;
}
Aggregations