Search in sources :

Example 11 with Questionnaire

use of org.hl7.fhir.dstu3.model.Questionnaire in project integration-adaptor-111 by nhsconnect.

the class QuestionnaireMapperTest method shouldMapQuestionnairePublisherSkillSet.

@Test
public void shouldMapQuestionnairePublisherSkillSet() {
    String skillSet = "T6";
    when(xmlUtils.getSingleNodeAsString(any(), anyString())).thenReturn(skillSet);
    Questionnaire questionnaire = questionnaireMapper.mapQuestionnaire(pathwaysCase, triageLine);
    assertThat(questionnaire.getPublisher()).isEqualTo(String.format("User skill set: '%s'", skillSet));
}
Also used : Questionnaire(org.hl7.fhir.dstu3.model.Questionnaire) IsoDateTimeFormatter.toIsoDateTimeString(uk.nhs.adaptors.oneoneone.cda.report.util.IsoDateTimeFormatter.toIsoDateTimeString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 12 with Questionnaire

use of org.hl7.fhir.dstu3.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireQuestionnaireItemOptionComponent.

protected void composeQuestionnaireQuestionnaireItemOptionComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemOptionComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "option", name, element, index);
    if (element.hasValue())
        composeType(t, "Questionnaire", "value", element.getValue(), -1);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 13 with Questionnaire

use of org.hl7.fhir.dstu3.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class Tester method main.

public static void main(String[] args) throws Exception {
    IWorkerContext context = SimpleWorkerContext.fromPack(Utilities.path("C:\\work\\org.hl7.fhir\\build\\publish", "validation-min.xml.zip"));
    int t = 0;
    int ok = 0;
    for (String f : new File("C:\\work\\org.hl7.fhir\\build\\publish").list()) {
        if (f.endsWith(".xml") && !f.endsWith(".canonical.xml") && !f.contains("profile") && !f.contains("questionnaire") && new File("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl")).exists()) {
            // if (f.equals("account-questionnaire.xml")) {
            System.out.print("convert " + f);
            // Manager.convert(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+f), FhirFormat.XML,
            // new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")), FhirFormat.JSON, OutputStyle.PRETTY);
            // String src = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".mm.json")));
            // String tgt = normalise(TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\"+Utilities.changeFileExt(f, ".json")));
            Element e = Manager.parse(context, new FileInputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + f), FhirFormat.XML);
            Manager.compose(context, e, new FileOutputStream("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl")), FhirFormat.TURTLE, OutputStyle.PRETTY, null);
            Manager.compose(context, e, new FileOutputStream(Utilities.path("[tmp]", "resource.xml")), FhirFormat.XML, OutputStyle.PRETTY, null);
            String src = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".mm.ttl"));
            String tgt = TextFile.fileToString("C:\\work\\org.hl7.fhir\\build\\publish\\" + Utilities.changeFileExt(f, ".ttl"));
            t++;
            if (src.equals(tgt)) {
                System.out.println(".. ok");
                ok++;
            } else
                System.out.println(".. fail");
        }
    // }
    }
    System.out.println("done - " + Integer.toString(t) + " files, " + Integer.toString(ok) + " ok");
}
Also used : IWorkerContext(org.hl7.fhir.dstu2016may.utils.IWorkerContext) JsonElement(com.google.gson.JsonElement) FileOutputStream(java.io.FileOutputStream) File(java.io.File) TextFile(org.hl7.fhir.utilities.TextFile) FileInputStream(java.io.FileInputStream)

Example 14 with Questionnaire

use of org.hl7.fhir.dstu3.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireQuestionnaireItemComponent.

protected void composeQuestionnaireQuestionnaireItemComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "item", name, element, index);
    if (element.hasLinkIdElement())
        composeString(t, "Questionnaire", "linkId", element.getLinkIdElement(), -1);
    for (int i = 0; i < element.getConcept().size(); i++) composeCoding(t, "Questionnaire", "concept", element.getConcept().get(i), i);
    if (element.hasPrefixElement())
        composeString(t, "Questionnaire", "prefix", element.getPrefixElement(), -1);
    if (element.hasTextElement())
        composeString(t, "Questionnaire", "text", element.getTextElement(), -1);
    if (element.hasTypeElement())
        composeEnum(t, "Questionnaire", "type", element.getTypeElement(), -1);
    for (int i = 0; i < element.getEnableWhen().size(); i++) composeQuestionnaireQuestionnaireItemEnableWhenComponent(t, "Questionnaire", "enableWhen", element.getEnableWhen().get(i), i);
    if (element.hasRequiredElement())
        composeBoolean(t, "Questionnaire", "required", element.getRequiredElement(), -1);
    if (element.hasRepeatsElement())
        composeBoolean(t, "Questionnaire", "repeats", element.getRepeatsElement(), -1);
    if (element.hasReadOnlyElement())
        composeBoolean(t, "Questionnaire", "readOnly", element.getReadOnlyElement(), -1);
    if (element.hasMaxLengthElement())
        composeInteger(t, "Questionnaire", "maxLength", element.getMaxLengthElement(), -1);
    if (element.hasOptions())
        composeReference(t, "Questionnaire", "options", element.getOptions(), -1);
    for (int i = 0; i < element.getOption().size(); i++) composeQuestionnaireQuestionnaireItemOptionComponent(t, "Questionnaire", "option", element.getOption().get(i), i);
    if (element.hasInitial())
        composeType(t, "Questionnaire", "initial", element.getInitial(), -1);
    for (int i = 0; i < element.getItem().size(); i++) composeQuestionnaireQuestionnaireItemComponent(t, "Questionnaire", "item", element.getItem().get(i), i);
}
Also used : Complex(org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)

Example 15 with Questionnaire

use of org.hl7.fhir.dstu3.model.Questionnaire in project org.hl7.fhir.core by hapifhir.

the class RdfParser method composeQuestionnaireQuestionnaireItemEnableWhenComponent.

protected void composeQuestionnaireQuestionnaireItemEnableWhenComponent(Complex parent, String parentType, String name, Questionnaire.QuestionnaireItemEnableWhenComponent element, int index) {
    if (element == null)
        return;
    Complex t;
    if (Utilities.noString(parentType))
        t = parent;
    else {
        t = parent.predicate("fhir:" + parentType + '.' + name);
    }
    composeBackboneElement(t, "enableWhen", name, element, index);
    if (element.hasQuestionElement())
        composeString(t, "Questionnaire", "question", element.getQuestionElement(), -1);
    if (element.hasHasAnswerElement())
        composeBoolean(t, "Questionnaire", "hasAnswer", element.getHasAnswerElement(), -1);
    if (element.hasAnswer())
        composeType(t, "Questionnaire", "answer", element.getAnswer(), -1);
}
Also used : Complex(org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)

Aggregations

XhtmlNode (org.hl7.fhir.utilities.xhtml.XhtmlNode)18 ArrayList (java.util.ArrayList)15 Questionnaire (org.hl7.fhir.r4.model.Questionnaire)14 DefinitionException (org.hl7.fhir.exceptions.DefinitionException)13 QuestionnaireResponse (org.hl7.fhir.r4.model.QuestionnaireResponse)12 QuestionnaireItemComponent (org.hl7.fhir.r4b.model.Questionnaire.QuestionnaireItemComponent)11 QuestionnaireItemComponent (org.hl7.fhir.r5.model.Questionnaire.QuestionnaireItemComponent)11 File (java.io.File)10 TextFile (org.hl7.fhir.utilities.TextFile)10 Test (org.junit.jupiter.api.Test)10 FileOutputStream (java.io.FileOutputStream)9 Questionnaire (org.hl7.fhir.dstu3.model.Questionnaire)9 FHIRException (org.hl7.fhir.exceptions.FHIRException)8 QuestionnaireItemComponent (org.hl7.fhir.r4.model.Questionnaire.QuestionnaireItemComponent)8 IOException (java.io.IOException)7 Bundle (org.hl7.fhir.r4.model.Bundle)7 CanonicalType (org.hl7.fhir.r4.model.CanonicalType)7 ValueSet (org.hl7.fhir.r5.model.ValueSet)7 FileNotFoundException (java.io.FileNotFoundException)6 Extension (org.hl7.fhir.r4.model.Extension)6