add Questionnaire example for #1062

This commit is contained in:
Grahame Grieve 2019-09-17 00:02:11 +10:00
parent 75af914631
commit 3a5c2eea2c
4 changed files with 132 additions and 12 deletions

View File

@ -28,6 +28,7 @@ import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.elementmodel.Element;
import org.hl7.fhir.r5.elementmodel.Manager.FhirFormat;
import org.hl7.fhir.r5.elementmodel.ObjectConverter;
import org.hl7.fhir.r5.formats.JsonParser;
import org.hl7.fhir.r5.formats.XmlParser;
import org.hl7.fhir.r5.model.Base;
import org.hl7.fhir.r5.model.CodeSystem;
@ -202,18 +203,33 @@ public class ValidationTestSuite implements IEvaluationContext, IValidatorResour
}
public Resource loadResource(String filename, String v) throws IOException, FHIRFormatError, FileNotFoundException, FHIRException, DefinitionException {
if (Constants.VERSION.equals(v) || "5.0".equals(v))
return new XmlParser().parse(new FileInputStream(filename));
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(v) || "3.0".equals(v))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(new FileInputStream(filename)), false);
else if (org.hl7.fhir.dstu2016may.model.Constants.VERSION.equals(v) || "1.4".equals(v))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.dstu2.model.Constants.VERSION.equals(v) || "1.0".equals(v))
return new VersionConvertor_10_50(null).convertResource(new org.hl7.fhir.dstu2.formats.XmlParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.r4.model.Constants.VERSION.equals(v) || "4.0".equals(v))
return VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.XmlParser().parse(new FileInputStream(filename)));
else
throw new FHIRException("unknown version "+v);
if (filename.contains(".json")) {
if (Constants.VERSION.equals(v) || "5.0".equals(v))
return new JsonParser().parse(new FileInputStream(filename));
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(v) || "3.0".equals(v))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.JsonParser().parse(new FileInputStream(filename)), false);
else if (org.hl7.fhir.dstu2016may.model.Constants.VERSION.equals(v) || "1.4".equals(v))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.JsonParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.dstu2.model.Constants.VERSION.equals(v) || "1.0".equals(v))
return new VersionConvertor_10_50(null).convertResource(new org.hl7.fhir.dstu2.formats.JsonParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.r4.model.Constants.VERSION.equals(v) || "4.0".equals(v))
return VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.JsonParser().parse(new FileInputStream(filename)));
else
throw new FHIRException("unknown version "+v);
} else {
if (Constants.VERSION.equals(v) || "5.0".equals(v))
return new XmlParser().parse(new FileInputStream(filename));
else if (org.hl7.fhir.dstu3.model.Constants.VERSION.equals(v) || "3.0".equals(v))
return VersionConvertor_30_50.convertResource(new org.hl7.fhir.dstu3.formats.XmlParser().parse(new FileInputStream(filename)), false);
else if (org.hl7.fhir.dstu2016may.model.Constants.VERSION.equals(v) || "1.4".equals(v))
return VersionConvertor_14_50.convertResource(new org.hl7.fhir.dstu2016may.formats.XmlParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.dstu2.model.Constants.VERSION.equals(v) || "1.0".equals(v))
return new VersionConvertor_10_50(null).convertResource(new org.hl7.fhir.dstu2.formats.XmlParser().parse(new FileInputStream(filename)));
else if (org.hl7.fhir.r4.model.Constants.VERSION.equals(v) || "4.0".equals(v))
return VersionConvertor_40_50.convertResource(new org.hl7.fhir.r4.formats.XmlParser().parse(new FileInputStream(filename)));
else
throw new FHIRException("unknown version "+v);
}
}
private void checkOutcomes(List<ValidationMessage> errors, JsonObject focus) {

View File

@ -186,6 +186,11 @@
"errors-for-debugging" : ["ERROR: Medication.extension[2].valueCodeableConcept.coding: The code \"N02AA\" is not valid in the system http://www.whocc.no/atc; The code provided (http://www.whocc.no/atc#N02AA) is not valid in the value set All codes known to the system"],
"allowed-extension-domain": "https://api-v8-r4.hspconsortium.org/DrugFormulary0/open"
},
"qr-ex.json": {
"questionnaire": "q-ex.json",
"version" : "3.0",
"errorCount": 0
},
"bp.json": {
"errorCount": 0,
"profile": {

View File

@ -0,0 +1,55 @@
{
"resourceType": "Questionnaire",
"id": "Questionnaire-openChoice",
"meta": {
"profile": [
"http://phr.kanta.fi/StructureDefinition/fiphr-sd-questionnaire-stu3-Annantesti2"
]
},
"language": "fi",
"url": "http://phr.kanta.fi/Questionnaire/Questionnaire-openChoice",
"identifier": [
{
"system": "urn:ietf:rfc:3986",
"value": "daa60638-251b-4d53-9ee9-6f16c0e6074b"
}
],
"version": "0.1",
"name": "Questionnaire-openChoice",
"title": "Questionnaire-openChoice",
"status": "draft",
"experimental": true,
"date": "2018-07-25T14:00:00Z",
"description": "Questionnaire-openChoice",
"code": [
{
"system": "http://phr.kanta.fi/CodeSystem/fiphr-cs-questionnairecode",
"code": "DAN-PSS-1"
}
],
"item": [
{
"linkId": "1",
"text": "Question1",
"type": "boolean",
"required": true,
"repeats": false
},
{
"linkId": "2",
"text": "Question2",
"type": "open-choice",
"required": true,
"repeats": true,
"option": [
{
"valueCoding": {
"id": "1",
"code": "B",
"display": "B"
}
}
]
}
]
}

View File

@ -0,0 +1,44 @@
{
"resourceType": "QuestionnaireResponse",
"meta": {
"profile": [
"http://phr.kanta.fi/StructureDefinition/fiphr-sd-questionnaireresponse-stu3-Annantesti2"
]
},
"language": "en",
"identifier": {
"system": "urn:ietf:rfc:3986",
"value": "3ea24a84-c3b3-4673-a7ed-de8254a3eb25"
},
"questionnaire": {
"reference": "Questionnaire/d8e04bb5-f121-4908-8215-44d01179e2cd"
},
"status": "completed",
"subject": {
"reference": "Patient/25a53703-27f9-4354-8f1b-a8b2f8f3ee86"
},
"authored": "2018-07-25T13:44:16Z",
"source": {
"reference": "Patient/25a53703-27f9-4354-8f1b-a8b2f8f3ee86"
},
"item": [
{
"linkId": "1",
"text": "Question1",
"answer": [
{
"valueBoolean": false
}
]
},
{
"linkId": "2",
"text": "Question2",
"answer": [
{
"valueString": "Open answer"
}
]
}
]
}