use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.
the class NarrativeGenerator method generate.
public boolean generate(ResourceContext rcontext, ConceptMap cm) throws FHIRFormatError, DefinitionException, IOException {
XhtmlNode x = new XhtmlNode(NodeType.Element, "div");
x.h2().addText(cm.getName() + " (" + cm.getUrl() + ")");
XhtmlNode p = x.para();
p.tx("Mapping from ");
if (cm.hasSource())
AddVsRef(rcontext, cm.getSource().primitiveValue(), p);
else
p.tx("(not specified)");
p.tx(" to ");
if (cm.hasTarget())
AddVsRef(rcontext, cm.getTarget().primitiveValue(), p);
else
p.tx("(not specified)");
p = x.para();
if (cm.getExperimental())
p.addText(Utilities.capitalize(cm.getStatus().toString()) + " (not intended for production usage). ");
else
p.addText(Utilities.capitalize(cm.getStatus().toString()) + ". ");
p.tx("Published on " + (cm.hasDate() ? cm.getDateElement().toHumanDisplay() : "??") + " by " + cm.getPublisher());
if (!cm.getContact().isEmpty()) {
p.tx(" (");
boolean firsti = true;
for (ContactDetail ci : cm.getContact()) {
if (firsti)
firsti = false;
else
p.tx(", ");
if (ci.hasName())
p.addText(ci.getName() + ": ");
boolean first = true;
for (ContactPoint c : ci.getTelecom()) {
if (first)
first = false;
else
p.tx(", ");
addTelecom(p, c);
}
}
p.tx(")");
}
p.tx(". ");
p.addText(cm.getCopyright());
if (!Utilities.noString(cm.getDescription()))
addMarkdown(x, cm.getDescription());
x.br();
CodeSystem cs = context.fetchCodeSystem("http://hl7.org/fhir/concept-map-equivalence");
String eqpath = cs.getUserString("path");
for (ConceptMapGroupComponent grp : cm.getGroup()) {
String src = grp.getSource();
boolean comment = false;
boolean ok = true;
Map<String, HashSet<String>> sources = new HashMap<String, HashSet<String>>();
Map<String, HashSet<String>> targets = new HashMap<String, HashSet<String>>();
sources.put("code", new HashSet<String>());
targets.put("code", new HashSet<String>());
SourceElementComponent cc = grp.getElement().get(0);
String dst = grp.getTarget();
sources.get("code").add(grp.getSource());
targets.get("code").add(grp.getTarget());
for (SourceElementComponent ccl : grp.getElement()) {
ok = ok && ccl.getTarget().size() == 1 && ccl.getTarget().get(0).getDependsOn().isEmpty() && ccl.getTarget().get(0).getProduct().isEmpty();
for (TargetElementComponent ccm : ccl.getTarget()) {
comment = comment || !Utilities.noString(ccm.getComment());
for (OtherElementComponent d : ccm.getDependsOn()) {
if (!sources.containsKey(d.getProperty()))
sources.put(d.getProperty(), new HashSet<String>());
sources.get(d.getProperty()).add(d.getSystem());
}
for (OtherElementComponent d : ccm.getProduct()) {
if (!targets.containsKey(d.getProperty()))
targets.put(d.getProperty(), new HashSet<String>());
targets.get(d.getProperty()).add(d.getSystem());
}
}
}
String display;
if (ok) {
// simple
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
tr.td().b().tx("Source Code");
tr.td().b().tx("Equivalence");
tr.td().b().tx("Destination Code");
if (comment)
tr.td().b().tx("Comment");
for (SourceElementComponent ccl : grp.getElement()) {
tr = tbl.tr();
XhtmlNode td = tr.td();
td.addText(ccl.getCode());
display = getDisplayForConcept(grp.getSource(), ccl.getCode());
if (display != null && !isSameCodeAndDisplay(ccl.getCode(), display))
td.tx(" (" + display + ")");
TargetElementComponent ccm = ccl.getTarget().get(0);
tr.td().addText(!ccm.hasEquivalence() ? "" : ccm.getEquivalence().toCode());
td = tr.td();
td.addText(ccm.getCode());
display = getDisplayForConcept(grp.getTarget(), ccm.getCode());
if (display != null && !isSameCodeAndDisplay(ccm.getCode(), display))
td.tx(" (" + display + ")");
if (comment)
tr.td().addText(ccm.getComment());
}
} else {
XhtmlNode tbl = x.table("grid");
XhtmlNode tr = tbl.tr();
XhtmlNode td;
tr.td().colspan(Integer.toString(sources.size())).b().tx("Source Concept Details");
tr.td().b().tx("Equivalence");
tr.td().colspan(Integer.toString(targets.size())).b().tx("Destination Concept Details");
if (comment)
tr.td().b().tx("Comment");
tr = tbl.tr();
if (sources.get("code").size() == 1) {
String url = sources.get("code").iterator().next();
renderCSDetailsLink(tr, url);
} else
tr.td().b().tx("Code");
for (String s : sources.keySet()) {
if (!s.equals("code")) {
if (sources.get(s).size() == 1) {
String url = sources.get(s).iterator().next();
renderCSDetailsLink(tr, url);
} else
tr.td().b().addText(getDescForConcept(s));
}
}
tr.td();
if (targets.get("code").size() == 1) {
String url = targets.get("code").iterator().next();
renderCSDetailsLink(tr, url);
} else
tr.td().b().tx("Code");
for (String s : targets.keySet()) {
if (!s.equals("code")) {
if (targets.get(s).size() == 1) {
String url = targets.get(s).iterator().next();
renderCSDetailsLink(tr, url);
} else
tr.td().b().addText(getDescForConcept(s));
}
}
if (comment)
tr.td();
for (int si = 0; si < grp.getElement().size(); si++) {
SourceElementComponent ccl = grp.getElement().get(si);
boolean slast = si == grp.getElement().size() - 1;
boolean first = true;
for (int ti = 0; ti < ccl.getTarget().size(); ti++) {
TargetElementComponent ccm = ccl.getTarget().get(ti);
boolean last = ti == ccl.getTarget().size() - 1;
tr = tbl.tr();
td = tr.td();
if (!first && !last)
td.setAttribute("style", "border-top-style: none; border-bottom-style: none");
else if (!first)
td.setAttribute("style", "border-top-style: none");
else if (!last)
td.setAttribute("style", "border-bottom-style: none");
if (first) {
if (sources.get("code").size() == 1)
td.addText(ccl.getCode());
else
td.addText(grp.getSource() + " / " + ccl.getCode());
display = getDisplayForConcept(grp.getSource(), ccl.getCode());
if (display != null)
td.tx(" (" + display + ")");
}
for (String s : sources.keySet()) {
if (!s.equals("code")) {
td = tr.td();
if (first) {
td.addText(getValue(ccm.getDependsOn(), s, sources.get(s).size() != 1));
display = getDisplay(ccm.getDependsOn(), s);
if (display != null)
td.tx(" (" + display + ")");
}
}
}
first = false;
if (!ccm.hasEquivalence())
tr.td().tx(":" + "(" + ConceptMapEquivalence.EQUIVALENT.toCode() + ")");
else
tr.td().ah(eqpath + "#" + ccm.getEquivalence().toCode()).tx(ccm.getEquivalence().toCode());
td = tr.td();
if (targets.get("code").size() == 1)
td.addText(ccm.getCode());
else
td.addText(grp.getTarget() + " / " + ccm.getCode());
display = getDisplayForConcept(grp.getTarget(), ccm.getCode());
if (display != null)
td.tx(" (" + display + ")");
for (String s : targets.keySet()) {
if (!s.equals("code")) {
td = tr.td();
td.addText(getValue(ccm.getProduct(), s, targets.get(s).size() != 1));
display = getDisplay(ccm.getProduct(), s);
if (display != null)
td.tx(" (" + display + ")");
}
}
if (comment)
tr.td().addText(ccm.getComment());
}
}
}
}
inject(cm, x, NarrativeStatus.GENERATED);
return true;
}
use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.
the class StructureMapUtilities method createProfile.
private PropertyWithType createProfile(StructureMap map, List<StructureDefinition> profiles, PropertyWithType prop, String sliceName, Base ctxt) throws FHIRException {
if (prop.getBaseProperty().getDefinition().getPath().contains("."))
throw new DefinitionException("Unable to process entry point");
String type = prop.getBaseProperty().getDefinition().getPath();
String suffix = "";
if (ids.containsKey(type)) {
int id = ids.get(type);
id++;
ids.put(type, id);
suffix = "-" + id;
} else
ids.put(type, 0);
StructureDefinition profile = new StructureDefinition();
profiles.add(profile);
profile.setDerivation(TypeDerivationRule.CONSTRAINT);
profile.setType(type);
profile.setBaseDefinition(prop.getBaseProperty().getStructure().getUrl());
profile.setName("Profile for " + profile.getType() + " for " + sliceName);
profile.setUrl(map.getUrl().replace("StructureMap", "StructureDefinition") + "-" + profile.getType() + suffix);
// then we can easily assign this profile url for validation later when we actually transform
ctxt.setUserData("profile", profile.getUrl());
profile.setId(map.getId() + "-" + profile.getType() + suffix);
profile.setStatus(map.getStatus());
profile.setExperimental(map.getExperimental());
profile.setDescription("Generated automatically from the mapping by the Java Reference Implementation");
for (ContactDetail c : map.getContact()) {
ContactDetail p = profile.addContact();
p.setName(c.getName());
for (ContactPoint cc : c.getTelecom()) p.addTelecom(cc);
}
profile.setDate(map.getDate());
profile.setCopyright(map.getCopyright());
profile.setFhirVersion(FHIRVersion.fromCode(Constants.VERSION));
profile.setKind(prop.getBaseProperty().getStructure().getKind());
profile.setAbstract(false);
ElementDefinition ed = profile.getDifferential().addElement();
ed.setPath(profile.getType());
prop.setProfileProperty(new Property(worker, ed, profile));
return prop;
}
use of org.hl7.fhir.r4b.model.ContactDetail in project org.hl7.fhir.core by hapifhir.
the class JsonParser method composeType.
protected void composeType(String prefix, DataType type) throws IOException {
if (type == null) {
;
} else if (type instanceof Address) {
composeAddress(prefix + "Address", (Address) type);
} else if (type instanceof Age) {
composeAge(prefix + "Age", (Age) type);
} else if (type instanceof Annotation) {
composeAnnotation(prefix + "Annotation", (Annotation) type);
} else if (type instanceof Attachment) {
composeAttachment(prefix + "Attachment", (Attachment) type);
} else if (type instanceof CodeableConcept) {
composeCodeableConcept(prefix + "CodeableConcept", (CodeableConcept) type);
} else if (type instanceof CodeableReference) {
composeCodeableReference(prefix + "CodeableReference", (CodeableReference) type);
} else if (type instanceof Coding) {
composeCoding(prefix + "Coding", (Coding) type);
} else if (type instanceof ContactDetail) {
composeContactDetail(prefix + "ContactDetail", (ContactDetail) type);
} else if (type instanceof ContactPoint) {
composeContactPoint(prefix + "ContactPoint", (ContactPoint) type);
} else if (type instanceof Contributor) {
composeContributor(prefix + "Contributor", (Contributor) type);
} else if (type instanceof Count) {
composeCount(prefix + "Count", (Count) type);
} else if (type instanceof DataRequirement) {
composeDataRequirement(prefix + "DataRequirement", (DataRequirement) type);
} else if (type instanceof Distance) {
composeDistance(prefix + "Distance", (Distance) type);
} else if (type instanceof Dosage) {
composeDosage(prefix + "Dosage", (Dosage) type);
} else if (type instanceof Duration) {
composeDuration(prefix + "Duration", (Duration) type);
} else if (type instanceof ElementDefinition) {
composeElementDefinition(prefix + "ElementDefinition", (ElementDefinition) type);
} else if (type instanceof Expression) {
composeExpression(prefix + "Expression", (Expression) type);
} else if (type instanceof Extension) {
composeExtension(prefix + "Extension", (Extension) type);
} else if (type instanceof HumanName) {
composeHumanName(prefix + "HumanName", (HumanName) type);
} else if (type instanceof Identifier) {
composeIdentifier(prefix + "Identifier", (Identifier) type);
} else if (type instanceof MarketingStatus) {
composeMarketingStatus(prefix + "MarketingStatus", (MarketingStatus) type);
} else if (type instanceof Meta) {
composeMeta(prefix + "Meta", (Meta) type);
} else if (type instanceof Money) {
composeMoney(prefix + "Money", (Money) type);
} else if (type instanceof Narrative) {
composeNarrative(prefix + "Narrative", (Narrative) type);
} else if (type instanceof ParameterDefinition) {
composeParameterDefinition(prefix + "ParameterDefinition", (ParameterDefinition) type);
} else if (type instanceof Period) {
composePeriod(prefix + "Period", (Period) type);
} else if (type instanceof Population) {
composePopulation(prefix + "Population", (Population) type);
} else if (type instanceof ProdCharacteristic) {
composeProdCharacteristic(prefix + "ProdCharacteristic", (ProdCharacteristic) type);
} else if (type instanceof ProductShelfLife) {
composeProductShelfLife(prefix + "ProductShelfLife", (ProductShelfLife) type);
} else if (type instanceof Quantity) {
composeQuantity(prefix + "Quantity", (Quantity) type);
} else if (type instanceof Range) {
composeRange(prefix + "Range", (Range) type);
} else if (type instanceof Ratio) {
composeRatio(prefix + "Ratio", (Ratio) type);
} else if (type instanceof RatioRange) {
composeRatioRange(prefix + "RatioRange", (RatioRange) type);
} else if (type instanceof Reference) {
composeReference(prefix + "Reference", (Reference) type);
} else if (type instanceof RelatedArtifact) {
composeRelatedArtifact(prefix + "RelatedArtifact", (RelatedArtifact) type);
} else if (type instanceof SampledData) {
composeSampledData(prefix + "SampledData", (SampledData) type);
} else if (type instanceof Signature) {
composeSignature(prefix + "Signature", (Signature) type);
} else if (type instanceof Timing) {
composeTiming(prefix + "Timing", (Timing) type);
} else if (type instanceof TriggerDefinition) {
composeTriggerDefinition(prefix + "TriggerDefinition", (TriggerDefinition) type);
} else if (type instanceof UsageContext) {
composeUsageContext(prefix + "UsageContext", (UsageContext) type);
} else if (type instanceof CodeType) {
composeCodeCore(prefix + "Code", (CodeType) type, false);
composeCodeExtras(prefix + "Code", (CodeType) type, false);
} else if (type instanceof OidType) {
composeOidCore(prefix + "Oid", (OidType) type, false);
composeOidExtras(prefix + "Oid", (OidType) type, false);
} else if (type instanceof CanonicalType) {
composeCanonicalCore(prefix + "Canonical", (CanonicalType) type, false);
composeCanonicalExtras(prefix + "Canonical", (CanonicalType) type, false);
} else if (type instanceof UuidType) {
composeUuidCore(prefix + "Uuid", (UuidType) type, false);
composeUuidExtras(prefix + "Uuid", (UuidType) type, false);
} else if (type instanceof UrlType) {
composeUrlCore(prefix + "Url", (UrlType) type, false);
composeUrlExtras(prefix + "Url", (UrlType) type, false);
} else if (type instanceof UnsignedIntType) {
composeUnsignedIntCore(prefix + "UnsignedInt", (UnsignedIntType) type, false);
composeUnsignedIntExtras(prefix + "UnsignedInt", (UnsignedIntType) type, false);
} else if (type instanceof MarkdownType) {
composeMarkdownCore(prefix + "Markdown", (MarkdownType) type, false);
composeMarkdownExtras(prefix + "Markdown", (MarkdownType) type, false);
} else if (type instanceof IdType) {
composeIdCore(prefix + "Id", (IdType) type, false);
composeIdExtras(prefix + "Id", (IdType) type, false);
} else if (type instanceof PositiveIntType) {
composePositiveIntCore(prefix + "PositiveInt", (PositiveIntType) type, false);
composePositiveIntExtras(prefix + "PositiveInt", (PositiveIntType) type, false);
} else if (type instanceof DateType) {
composeDateCore(prefix + "Date", (DateType) type, false);
composeDateExtras(prefix + "Date", (DateType) type, false);
} else if (type instanceof DateTimeType) {
composeDateTimeCore(prefix + "DateTime", (DateTimeType) type, false);
composeDateTimeExtras(prefix + "DateTime", (DateTimeType) type, false);
} else if (type instanceof StringType) {
composeStringCore(prefix + "String", (StringType) type, false);
composeStringExtras(prefix + "String", (StringType) type, false);
} else if (type instanceof IntegerType) {
composeIntegerCore(prefix + "Integer", (IntegerType) type, false);
composeIntegerExtras(prefix + "Integer", (IntegerType) type, false);
} else if (type instanceof Integer64Type) {
composeInteger64Core(prefix + "Integer64", (Integer64Type) type, false);
composeInteger64Extras(prefix + "Integer64", (Integer64Type) type, false);
} else if (type instanceof UriType) {
composeUriCore(prefix + "Uri", (UriType) type, false);
composeUriExtras(prefix + "Uri", (UriType) type, false);
} else if (type instanceof InstantType) {
composeInstantCore(prefix + "Instant", (InstantType) type, false);
composeInstantExtras(prefix + "Instant", (InstantType) type, false);
} else if (type instanceof BooleanType) {
composeBooleanCore(prefix + "Boolean", (BooleanType) type, false);
composeBooleanExtras(prefix + "Boolean", (BooleanType) type, false);
} else if (type instanceof Base64BinaryType) {
composeBase64BinaryCore(prefix + "Base64Binary", (Base64BinaryType) type, false);
composeBase64BinaryExtras(prefix + "Base64Binary", (Base64BinaryType) type, false);
} else if (type instanceof TimeType) {
composeTimeCore(prefix + "Time", (TimeType) type, false);
composeTimeExtras(prefix + "Time", (TimeType) type, false);
} else if (type instanceof DecimalType) {
composeDecimalCore(prefix + "Decimal", (DecimalType) type, false);
composeDecimalExtras(prefix + "Decimal", (DecimalType) type, false);
} else
throw new Error("Unhandled type");
}
Aggregations