use of org.hl7.fhir.r4.model.Questionnaire in project cqf-ruler by DBCG.
the class ExtractProvider method createObservationBundle.
private Bundle createObservationBundle(QuestionnaireResponse questionnaireResponse) {
Bundle newBundle = new Bundle();
Date authored = questionnaireResponse.getAuthored();
Identifier bundleId = new Identifier();
bundleId.setValue("QuestionnaireResponse/" + questionnaireResponse.getIdElement().getIdPart());
newBundle.setType(Bundle.BundleType.TRANSACTION);
newBundle.setIdentifier(bundleId);
String questionnaireCanonical = questionnaireResponse.getQuestionnaire();
if (questionnaireCanonical == null || questionnaireCanonical.isEmpty()) {
throw new IllegalArgumentException("The QuestionnaireResponse must have the source Questionnaire specified to do extraction");
}
Map<String, Coding> questionnaireCodeMap = getQuestionnaireCodeMap(questionnaireCanonical);
questionnaireResponse.getItem().stream().forEach(item -> {
processItems(item, authored, questionnaireResponse, newBundle, questionnaireCodeMap);
});
return newBundle;
}
use of org.hl7.fhir.r4.model.Questionnaire in project cqf-ruler by DBCG.
the class ExtractProvider method getQuestionnaireCodeMap.
private Map<String, Coding> getQuestionnaireCodeMap(String questionnaireUrl) {
String url = mySdcProperties.getExtract().getEndpoint();
if (null == url || url.length() < 1) {
throw new IllegalArgumentException("Unable to GET Questionnaire. No observation.endpoint defined in sdc properties.");
}
String user = mySdcProperties.getExtract().getUsername();
String password = mySdcProperties.getExtract().getPassword();
IGenericClient client = Clients.forUrl(myFhirContext, url);
Clients.registerBasicAuth(client, user, password);
Questionnaire questionnaire = client.read().resource(Questionnaire.class).withUrl(questionnaireUrl).execute();
if (questionnaire == null) {
throw new IllegalArgumentException("Unable to find resource by URL " + questionnaireUrl);
}
return createCodeMap(questionnaire);
}
use of org.hl7.fhir.r4.model.Questionnaire in project cqf-ruler by DBCG.
the class ExtractProviderIT method testExtract_noQuestionnaireReference_throwsException.
@Test
public void testExtract_noQuestionnaireReference_throwsException() throws IOException {
QuestionnaireResponse test = (QuestionnaireResponse) getFhirContext().newJsonParser().parseResource(stringFromResource("mypain-questionnaire-response-no-url.json"));
Parameters params = new Parameters();
params.addParameter().setName("questionnaireResponse").setResource(test);
assertThrows(InternalErrorException.class, () -> {
getClient().operation().onType(QuestionnaireResponse.class).named("$extract").withParameters(params).returnResourceType(Bundle.class).execute();
});
}
use of org.hl7.fhir.r4.model.Questionnaire in project cqf-ruler by DBCG.
the class CanonicalsTest method partialCanonicalType.
@Test
public void partialCanonicalType() {
CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example");
assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
assertEquals("Questionnaire", Canonicals.getResourceType(testUrl));
assertEquals("example", Canonicals.getIdPart(testUrl));
assertNull(Canonicals.getVersion(testUrl));
assertNull(Canonicals.getFragment(testUrl));
}
use of org.hl7.fhir.r4.model.Questionnaire in project cqf-ruler by DBCG.
the class CanonicalsTest method fullCanonicalType.
@Test
public void fullCanonicalType() {
CanonicalType testUrl = new CanonicalType("http://fhir.acme.com/Questionnaire/example|1.0#vs1");
assertEquals("http://fhir.acme.com/Questionnaire/example", Canonicals.getUrl(testUrl));
assertEquals("example", Canonicals.getIdPart(testUrl));
assertEquals("1.0", Canonicals.getVersion(testUrl));
assertEquals("vs1", Canonicals.getFragment(testUrl));
}
Aggregations