use of org.hl7.v3.II in project kindling by HL7.
the class CDAGenerator method processAttribute.
private void processAttribute(List<Element> classes, List<ElementDefinition> diff, List<ElementDefinition> snapshot, Element cclss, String path, Element attr) throws FHIRFormatError {
String n = attr.getAttribute("name");
ElementDefinition ed = new ElementDefinition();
ed.setPath(path + "." + n);
ed.setMin(Integer.parseInt(attr.getAttribute("minimumMultiplicity")));
ed.setMax(attr.getAttribute("maximumMultiplicity"));
if (ed.getMax().equals("0"))
return;
seePath(ed);
if (!Utilities.noString(attr.getAttribute("namespace")))
ed.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-namespace").setValue(new UriType(attr.getAttribute("namespace")));
String type = getType(attr);
if ("true".equals(attr.getAttribute("isImmutable"))) {
if (primitiveTypes.containsKey(type))
type = primitiveTypes.get(type);
else
throw new Error("Immutable attribute that is not a primitive type");
ed.addRepresentation(PropertyRepresentation.XMLATTR);
}
if ("GTS".equals(type)) {
ed.setMax("*");
ed.addRepresentation(PropertyRepresentation.TYPEATTR);
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/IVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/PIVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS");
ed.addExtension().setUrl("http://hl7.org/fhir/StructureDefinition/elementdefinition-defaulttype").setValue(new StringType("SXPR_TS"));
} else if ("ANY".equals(type)) {
ed.addRepresentation(PropertyRepresentation.TYPEATTR);
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/BL");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/ED");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/ST");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CD");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CV");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/CE");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/SC");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/II");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/TEL");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/AD");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/EN");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/INT");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/REAL");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/PQ");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/MO");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/IVL_PQ");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/IVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/PIVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/EIVL_TS");
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/SXPR_TS");
} else if (isPrimitive(type))
ed.addType().setCode(type);
else if (Utilities.existsInList(type, "PN"))
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/EN");
else if (Utilities.existsInList(type, "ON"))
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/ST");
else if (Utilities.existsInList(type, "NARRATIVE")) {
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/StrucDoc.Text");
ed.addRepresentation(PropertyRepresentation.CDATEXT);
} else
ed.addType().setCode("http://hl7.org/fhir/cda/StructureDefinition/" + type);
if ("R".equals(attr.getAttribute("conformance")))
ed.setMustSupport(true);
if (attr.hasAttribute("defaultValue"))
ed.setDefaultValue(buildValue(attr.getAttribute("defaultValue"), type, ed.getPath()));
List<Element> enums = new ArrayList<Element>();
XMLUtil.getNamedChildren(attr, "enumerationValue", enums);
if (enums.size() == 1)
ed.setFixed(buildValue(enums.get(0).getTextContent(), type, ed.getPath()));
if (enums.size() > 1) {
// throw new Error("todo: enums on "+ed.getPath());
} else if (XMLUtil.getNamedChild(attr, "vocabulary") != null) {
// <vocabulary codingStrength="CWE"><conceptDomain name="ActClass"/></vocabulary>
Element vocab = XMLUtil.getNamedChild(attr, "vocabulary");
String cs = vocab.getAttribute("codingStrength");
String cd = XMLUtil.getNamedChildAttribute(vocab, "conceptDomain", "name");
ElementDefinitionBindingComponent bd = ed.getBinding();
bd.setStrength(cs.equals("CNE") ? BindingStrength.REQUIRED : BindingStrength.EXTENSIBLE);
bd.setValueSet("http://terminology.hl7.org/ValueSet/v3-" + cd);
v3vs.add(cd);
}
diff.add(ed);
snapshot.add(popBase(ed));
}
use of org.hl7.v3.II in project kindling by HL7.
the class Publisher method generateConformanceStatement.
private void generateConformanceStatement(boolean full, String name, boolean register) throws Exception {
pgen = new ProfileGenerator(page.getDefinitions(), page.getWorkerContext(), page, page.getGenDate(), page.getVersion(), dataElements, fpUsages, page.getFolders().rootDir, page.getUml(), page.getRc());
CapabilityStatement cpbs = new CapabilityStatement();
cpbs.setId(FormatUtilities.makeId(name));
cpbs.setUrl("http://hl7.org/fhir/CapabilityStatement/" + name);
cpbs.setVersion(page.getVersion().toCode());
cpbs.setName("Base FHIR Capability Statement " + (full ? "(Full)" : "(Empty)"));
cpbs.setStatus(PublicationStatus.DRAFT);
cpbs.setExperimental(true);
cpbs.setDate(page.getGenDate().getTime());
cpbs.setPublisher("FHIR Project Team");
cpbs.addContact().getTelecom().add(Factory.newContactPoint(ContactPointSystem.URL, "http://hl7.org/fhir"));
cpbs.setKind(CapabilityStatementKind.CAPABILITY);
cpbs.setSoftware(new CapabilityStatementSoftwareComponent());
cpbs.getSoftware().setName("Insert your software name here...");
cpbs.setFhirVersion(page.getVersion());
cpbs.getFormat().add(Factory.newCode("xml"));
cpbs.getFormat().add(Factory.newCode("json"));
CapabilityStatementRestComponent rest = new CapabilityStatement.CapabilityStatementRestComponent();
cpbs.getRest().add(rest);
rest.setMode(RestfulCapabilityMode.SERVER);
if (full) {
rest.setDocumentation("All the functionality defined in FHIR");
cpbs.setDescription("This is the base Capability Statement for FHIR. It represents a server that provides the full set of functionality defined by FHIR. It is provided to use as a template for system designers to build their own Capability Statements from");
} else {
rest.setDocumentation("An empty Capability Statement");
cpbs.setDescription("This is the base Capability Statement for FHIR. It represents a server that provides the none of the functionality defined by FHIR. It is provided to use as a template for system designers to build their own Capability Statements from. A capability statement has to contain something, so this contains a read of a Capability Statement");
}
rest.setSecurity(new CapabilityStatementRestSecurityComponent());
rest.getSecurity().setCors(true);
rest.getSecurity().addService().setText("See http://docs.smarthealthit.org/").addCoding().setSystem("http://terminology.hl7.org/CodeSystem/restful-security-service").setCode("SMART-on-FHIR").setDisplay("SMART-on-FHIR");
rest.getSecurity().setDescription("This is the Capability Statement to declare that the server supports SMART-on-FHIR. See the SMART-on-FHIR docs for the extension that would go with such a server");
if (full) {
for (String rn : page.getDefinitions().sortedResourceNames()) {
ResourceDefn rd = page.getDefinitions().getResourceByName(rn);
CapabilityStatementRestResourceComponent res = new CapabilityStatement.CapabilityStatementRestResourceComponent();
rest.getResource().add(res);
res.setType(rn);
res.setProfile("http://hl7.org/fhir/StructureDefinition/" + rn);
genConfInteraction(cpbs, res, TypeRestfulInteraction.READ, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.VREAD, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.UPDATE, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.DELETE, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.HISTORYINSTANCE, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.HISTORYTYPE, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.CREATE, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, res, TypeRestfulInteraction.SEARCHTYPE, "Implemented per the specification (or Insert other doco here)");
res.setConditionalCreate(true);
res.setConditionalUpdate(true);
res.setConditionalDelete(ConditionalDeleteStatus.MULTIPLE);
res.addReferencePolicy(ReferenceHandlingPolicy.LITERAL);
res.addReferencePolicy(ReferenceHandlingPolicy.LOGICAL);
for (SearchParameterDefn i : rd.getSearchParams().values()) {
res.getSearchParam().add(makeSearchParam(rn, i));
if (i.getType().equals(SearchType.reference))
res.getSearchInclude().add(new StringType(rn + "." + i.getCode()));
}
for (String rni : page.getDefinitions().sortedResourceNames()) {
ResourceDefn rdi = page.getDefinitions().getResourceByName(rni);
for (SearchParameterDefn ii : rdi.getSearchParams().values()) {
if (ii.getType().equals(SearchType.reference) && ii.getTargets().contains(rn))
res.getSearchRevInclude().add(new StringType(rni + "." + ii.getCode()));
}
}
}
genConfInteraction(cpbs, rest, SystemRestfulInteraction.TRANSACTION, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, rest, SystemRestfulInteraction.BATCH, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, rest, SystemRestfulInteraction.HISTORYSYSTEM, "Implemented per the specification (or Insert other doco here)");
genConfInteraction(cpbs, rest, SystemRestfulInteraction.SEARCHSYSTEM, "Implemented per the specification (or Insert other doco here)");
for (ResourceDefn rd : page.getDefinitions().getBaseResources().values()) {
for (SearchParameterDefn i : rd.getSearchParams().values()) rest.getSearchParam().add(makeSearchParam(rd.getName(), i));
rest.getSearchParam().add(makeSearchParam("something", SearchParamType.STRING, "id", "some doco"));
rest.getSearchParam().add(makeSearchParam("_list", SearchParamType.TOKEN, "Resource-list", "Retrieval of resources that are referenced by a List resource"));
rest.getSearchParam().add(makeSearchParam("_has", SearchParamType.COMPOSITE, "Resource-has", "Provides support for reverse chaining"));
rest.getSearchParam().add(makeSearchParam("_type", SearchParamType.TOKEN, "Resource-type", "Type of resource (when doing cross-resource search"));
rest.getSearchParam().add(makeSearchParam("_sort", SearchParamType.TOKEN, "Resource-source", "How to sort the resources when returning"));
rest.getSearchParam().add(makeSearchParam("_count", SearchParamType.NUMBER, "Resource-count", "How many resources to return"));
rest.getSearchParam().add(makeSearchParam("_include", SearchParamType.TOKEN, "Resource-include", "Control over returning additional resources (see spec)"));
rest.getSearchParam().add(makeSearchParam("_revinclude", SearchParamType.TOKEN, "Resource-revinclude", "Control over returning additional resources (see spec)"));
rest.getSearchParam().add(makeSearchParam("_summary", SearchParamType.TOKEN, "Resource-summary", "What kind of information to return"));
rest.getSearchParam().add(makeSearchParam("_elements", SearchParamType.STRING, "Resource-elements", "What kind of information to return"));
rest.getSearchParam().add(makeSearchParam("_contained", SearchParamType.TOKEN, "Resource-contained", "Managing search into contained resources"));
rest.getSearchParam().add(makeSearchParam("_containedType", SearchParamType.TOKEN, "Resource-containedType", "Managing search into contained resources"));
for (Operation op : rd.getOperations()) rest.addOperation().setName(op.getName()).setDefinition("http://hl7.org/fhir/OperationDefinition/" + rd.getName().toLowerCase() + "-" + op.getName());
}
for (String rn : page.getDefinitions().sortedResourceNames()) {
ResourceDefn r = page.getDefinitions().getResourceByName(rn);
for (Operation op : r.getOperations()) rest.addOperation().setName(op.getName()).setDefinition("http://hl7.org/fhir/OperationDefinition/" + r.getName().toLowerCase() + "-" + op.getName());
}
} else {
// don't add anything - the metadata operation is implicit
// CapabilityStatementRestResourceComponent res = new CapabilityStatement.CapabilityStatementRestResourceComponent();
// rest.getResource().add(res);
// res.setType("CapabilityStatement");
// genConfInteraction(cpbs, res, TypeRestfulInteraction.READ, "Read CapabilityStatement Resource");
}
if (register) {
RenderingContext lrc = page.getRc().copy().setLocalPrefix("").setTooCostlyNoteEmpty(PageProcessor.TOO_MANY_CODES_TEXT_EMPTY).setTooCostlyNoteNotEmpty(PageProcessor.TOO_MANY_CODES_TEXT_NOT_EMPTY);
RendererFactory.factory(cpbs, lrc).render(cpbs);
FileOutputStream s = new FileOutputStream(page.getFolders().dstDir + "capabilitystatement-" + name + ".xml");
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpbs);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + "capabilitystatement-" + name + ".canonical.xml");
new XmlParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, cpbs);
s.close();
cloneToXhtml("capabilitystatement-" + name + "", "Basic Capability Statement", true, "resource-instance:CapabilityStatement", "Capability Statement", null, wg("fhir"));
s = new FileOutputStream(page.getFolders().dstDir + "capabilitystatement-" + name + ".json");
new JsonParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpbs);
s.close();
s = new FileOutputStream(page.getFolders().dstDir + "capabilitystatement-" + name + ".canonical.json");
new JsonParser().setOutputStyle(OutputStyle.CANONICAL).compose(s, cpbs);
s.close();
jsonToXhtml("capabilitystatement-" + name, "Base Capability Statement", resource2Json(cpbs), "resource-instance:CapabilityStatement", "Capability Statement", null, wg("fhir"));
s = new FileOutputStream(page.getFolders().dstDir + "capabilitystatement-" + name + ".ttl");
new RdfParser().setOutputStyle(OutputStyle.PRETTY).compose(s, cpbs);
s.close();
ttlToXhtml("capabilitystatement-" + name, "Base Capability Statement", resource2Ttl(cpbs), "resource-instance:CapabilityStatement", "Capability Statement", null, wg("fhir"));
Utilities.copyFile(new CSFile(page.getFolders().dstDir + "capabilitystatement-" + name + ".xml"), new CSFile(page.getFolders().dstDir + "examples" + File.separator + "capabilitystatement-" + name + ".xml"));
}
if (buildFlags.get("all")) {
RenderingContext lrc = page.getRc().copy().setLocalPrefix("");
RendererFactory.factory(cpbs, lrc).render(cpbs);
deletefromFeed(ResourceType.CapabilityStatement, name, page.getResourceBundle());
addToResourceFeed(cpbs, page.getResourceBundle());
}
}
use of org.hl7.v3.II in project org.hl7.fhir.core by hapifhir.
the class InstanceValidator method buildFixedExpression.
private void buildFixedExpression(ElementDefinition ed, StringBuilder expression, String discriminator, ElementDefinition criteriaElement) throws DefinitionException {
DataType fixed = criteriaElement.getFixed();
if (fixed instanceof CodeableConcept) {
CodeableConcept cc = (CodeableConcept) fixed;
expression.append(" and ");
buildCodeableConceptExpression(ed, expression, discriminator, cc);
} else if (fixed instanceof Identifier) {
Identifier ii = (Identifier) fixed;
expression.append(" and ");
buildIdentifierExpression(ed, expression, discriminator, ii);
} else if (fixed instanceof Coding) {
Coding c = (Coding) fixed;
expression.append(" and ");
buildCodingExpression(ed, expression, discriminator, c);
} else {
expression.append(" and (");
if (fixed instanceof StringType) {
Gson gson = new Gson();
String json = gson.toJson((StringType) fixed);
String escapedString = json.substring(json.indexOf(":") + 2);
escapedString = escapedString.substring(0, escapedString.indexOf(",\"myStringValue") - 1);
expression.append("'" + escapedString + "'");
} else if (fixed instanceof UriType) {
expression.append("'" + ((UriType) fixed).asStringValue() + "'");
} else if (fixed instanceof IntegerType) {
expression.append(((IntegerType) fixed).asStringValue());
} else if (fixed instanceof DecimalType) {
expression.append(((IntegerType) fixed).asStringValue());
} else if (fixed instanceof BooleanType) {
expression.append(((BooleanType) fixed).asStringValue());
} else
throw new DefinitionException(context.formatMessage(I18nConstants.UNSUPPORTED_FIXED_VALUE_TYPE_FOR_DISCRIMINATOR_FOR_SLICE__, discriminator, ed.getId(), fixed.getClass().getName()));
expression.append(" in " + discriminator + ")");
}
}
use of org.hl7.v3.II in project org.hl7.fhir.core by hapifhir.
the class InstanceValidator method buildPattternExpression.
private void buildPattternExpression(ElementDefinition ed, StringBuilder expression, String discriminator, ElementDefinition criteriaElement) throws DefinitionException {
DataType pattern = criteriaElement.getPattern();
if (pattern instanceof CodeableConcept) {
CodeableConcept cc = (CodeableConcept) pattern;
expression.append(" and ");
buildCodeableConceptExpression(ed, expression, discriminator, cc);
} else if (pattern instanceof Coding) {
Coding c = (Coding) pattern;
expression.append(" and ");
buildCodingExpression(ed, expression, discriminator, c);
} else if (pattern instanceof BooleanType || pattern instanceof IntegerType || pattern instanceof DecimalType) {
expression.append(" and ");
buildPrimitiveExpression(ed, expression, discriminator, pattern, false);
} else if (pattern instanceof PrimitiveType) {
expression.append(" and ");
buildPrimitiveExpression(ed, expression, discriminator, pattern, true);
} else if (pattern instanceof Identifier) {
Identifier ii = (Identifier) pattern;
expression.append(" and ");
buildIdentifierExpression(ed, expression, discriminator, ii);
} else if (pattern instanceof HumanName) {
HumanName name = (HumanName) pattern;
expression.append(" and ");
buildHumanNameExpression(ed, expression, discriminator, name);
} else if (pattern instanceof Address) {
Address add = (Address) pattern;
expression.append(" and ");
buildAddressExpression(ed, expression, discriminator, add);
} else {
throw new DefinitionException(context.formatMessage(I18nConstants.UNSUPPORTED_FIXED_PATTERN_TYPE_FOR_DISCRIMINATOR_FOR_SLICE__, discriminator, ed.getId(), pattern.fhirType()));
}
}
use of org.hl7.v3.II in project nia-patient-switching-standard-adaptor by NHSDigital.
the class ConsultationListMapperTest method setUpCompoundStatement.
private RCMRMT030101UK04CompoundStatement setUpCompoundStatement(String originalText, String display, String availabilityTime, boolean nullFlavorCode) {
RCMRMT030101UK04CompoundStatement compoundStatement = new RCMRMT030101UK04CompoundStatement();
II id = new II();
id.setRoot(COMPOUND_STATEMENT_ID);
CD cd = new CD();
if (nullFlavorCode) {
cd.setNullFlavor(CsNullFlavor.UNK);
} else {
cd.setOriginalText(originalText);
cd.setDisplayName(display);
cd.setCodeSystem("2.16.840.1.113883.2.1.6.2");
cd.setCode("14L..00");
}
TS ts = new TS();
if (availabilityTime != null) {
ts.setValue(availabilityTime);
} else {
ts.setNullFlavor(CsNullFlavor.NI);
}
compoundStatement.setAvailabilityTime(ts);
compoundStatement.getId().add(id);
compoundStatement.setCode(cd);
return compoundStatement;
}
Aggregations