Skip to content

Commit

Permalink
update IG publisher to allow auto-loading of resources
Browse files Browse the repository at this point in the history
git-svn-id: http://gforge.hl7.org/svn/fhir/trunk/build@12183 2f0db536-2c49-4257-a3fa-e771ed206c19
  • Loading branch information
grahameg committed Jul 3, 2017
1 parent 83d1de2 commit ab9aa4f
Show file tree
Hide file tree
Showing 14 changed files with 335 additions and 67 deletions.
Expand Up @@ -34,6 +34,7 @@ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWIS
import java.util.*;

import org.hl7.fhir.utilities.Utilities;
import org.hl7.fhir.r4.model.CodeSystem.PropertyComponent;
import org.hl7.fhir.r4.model.Enumerations.*;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.api.annotation.SearchParamDefinition;
Expand Down Expand Up @@ -4719,6 +4720,14 @@ public ResourceType getResourceType() {
*/
public static final ca.uhn.fhir.rest.gclient.TokenClientParam STATUS = new ca.uhn.fhir.rest.gclient.TokenClientParam(SP_STATUS);

public PropertyComponent getProperty(String code) {
for (PropertyComponent pd : getProperty()) {
if (pd.getCode().equalsIgnoreCase(code))
return pd;
}
return null;
}


}

Expand Up @@ -429,6 +429,13 @@ public void checkNoModifiers(String noun, String verb) throws FHIRException {

}

public void addExtension(String url, Type value) {
Extension ex = new Extension();
ex.setUrl(url);
ex.setValue(value);
getExtension().add(ex);
}

// end addition

}
Expand Down
Expand Up @@ -2688,7 +2688,6 @@ public StructureMap generateMapFromMappings(StructureDefinition sd) throws IOExc
b.append("\r\n");
b.append(suffix);
b.append("\r\n");
TextFile.stringToFile(b.toString(), "c:\\temp\\test.map");
StructureMap map = parse(b.toString());
map.setId(tail(map.getUrl()));
if (!map.hasStatus())
Expand Down
Expand Up @@ -1069,6 +1069,21 @@ public static int countFilesInDirectory(String dirName) {
return i;
}

public static String makeId(String name) {
StringBuilder b = new StringBuilder();
for (char ch : name.toCharArray()) {
if (ch >= 'a' && ch <= 'z')
b.append(ch);
else if (ch >= 'A' && ch <= 'Z')
b.append(ch);
else if (ch >= '0' && ch <= '9')
b.append(ch);
else if (ch == '-' || ch == '.')
b.append(ch);
}
return b.toString();
}




Expand Down
Binary file removed qa/reviewed content/applied/main pages 44-129.doc
Binary file not shown.
156 changes: 156 additions & 0 deletions source/consent/consent-spreadsheet.sheet.txt
Expand Up @@ -586,3 +586,159 @@
Type = @Consent.provision
Short Name = Nested Exception Rules
Definition = Rules which provide exceptions to the base rule or subrules

=== Sheet Search =====================================

-- Row 1 -----------------------------------
Name = data
Type = reference
Path = Consent.provision.data.reference

-- Row 2 -----------------------------------
Name = patient
Type = reference
Path = Consent.patient

-- Row 3 -----------------------------------
Name = identifier
Type = token
Path = Consent.identifier

-- Row 4 -----------------------------------
Name = organization
Type = reference
Path = Consent.organization

-- Row 5 -----------------------------------
Name = date
Type = date
Path = Consent.dateTime

-- Row 6 -----------------------------------
Name = period
Type = date
Path = Consent.provision.period

-- Row 7 -----------------------------------
Name = status
Type = token
Path = Consent.status

-- Row 8 -----------------------------------
Name = category
Type = token
Path = Consent.category

-- Row 9 -----------------------------------
Name = consentor
Type = reference
Path = Consent.consentingParty

-- Row 10 -----------------------------------
Name = source
Type = reference
Path = Consent.source[x]

-- Row 11 -----------------------------------
Name = actor
Type = reference
Path = Consent.provision.actor.reference

-- Row 12 -----------------------------------
Name = action
Type = token
Path = Consent.provision.action

-- Row 13 -----------------------------------
Name = securitylabel
Type = token
Path = Consent.provision.securityLabel

-- Row 14 -----------------------------------
Name = purpose
Type = token
Path = Consent.provision.purpose

=== Sheet Profiles =====================================

-- Row 1 -----------------------------------
Name = Consent Extension
IG Name = core
Filename = consent-extensions.xml
Type = spreadsheet

=== Sheet Examples =====================================

-- Row 1 -----------------------------------
Name = Consent-In
Identity = consent-example-basic
Description = General Consent Example
Filename = consent-example.xml

-- Row 2 -----------------------------------
Name = Consent-Out
Identity = consent-example-Out
Description = Consent withholding access
Filename = consent-example-Out.xml

-- Row 3 -----------------------------------
Name = Consent-Emergency
Identity = consent-example-Emergency
Description = Consent withholding access to data for Treatment exept for Emergency Treatment
Filename = consent-example-Emergency.xml

-- Row 4 -----------------------------------
Name = Consent-Not-This
Identity = consent-example-notThis
Description = Withhold or withdraw consent for disclosure of records related to specific domain (e.g. DI, LAB, etc.)
Filename = consent-example-notThis.xml

-- Row 5 -----------------------------------
Name = Consent-Not-Time
Identity = consent-example-notTime
Description = Withhold or withdraw consent for disclosure of a specific timeframe
Filename = consent-example-notTime.xml

-- Row 6 -----------------------------------
Name = Consent-Not-Org
Identity = consent-example-notOrg
Description = Withhold or withdraw consent for disclosure to a specific provider organization
Filename = consent-example-notOrg.xml

-- Row 7 -----------------------------------
Name = Consent-Not-Them
Identity = consent-example-notThem
Description = Withhold or withdraw consent for disclosure to a specific provider agent (an individual within an organization)
Filename = consent-example-notThem.xml

-- Row 8 -----------------------------------
Name = Consent-Not-Author
Identity = consent-example-notAuthor
Description = Withhold or withdraw consent for disclosure of records that were authored by a specific organization (or service delivery location).
Filename = consent-example-notAuthor.xml

-- Row 9 -----------------------------------
Name = Consent-Grantor
Identity = consent-example-grantor
Description = Patient grants access to a specified individual for read-only access
Filename = consent-example-grantor.xml

-- Row 10 -----------------------------------
Name = Consent from Patients Know Best
Identity = consent-example-pkb
Description = Example of Patients Know Best Usage
Filename = consent-example-pkb.xml

-- Row 11 -----------------------------------
Name = Smart on FHIR example
Identity = consent-example-smartonfhir
Description = Template for recording a Smart on FHIR Authorization
Filename = consent-example-smartonfhir.xml

-- Row 12 -----------------------------------
Name = Consent with Signature
Identity = consent-example-signature
Description = Consent Example with a signature
Filename = consent-example-signature.xml

=== Sheet Examples =====================================
Expand Up @@ -147,4 +147,7 @@ public String getTitle() {
public void setTitle(String title) {
this.title = title;
}
public boolean matches(FetchedFile other) {
return this.path.equals(other.path);
}
}
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.List;

import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.r4.context.IWorkerContext;
import org.hl7.fhir.r4.context.IWorkerContext.ILoggingService;
import org.hl7.fhir.r4.model.Type;
Expand All @@ -15,7 +16,7 @@ public interface IFetchFile {
FetchedFile fetch(Type source, FetchedFile base) throws Exception;
FetchedFile fetchResourceFile(String name) throws Exception;
void setPkp(IGKnowledgeProvider pkp);
List<FetchedFile> scan(String sourceDir, IWorkerContext context) throws IOException;
List<FetchedFile> scan(String sourceDir, IWorkerContext context, boolean autoScan) throws IOException, FHIRException;

public ILoggingService getLogger();
public void setLogger(ILoggingService log);
Expand Down
Expand Up @@ -42,6 +42,7 @@ public class IGKnowledgeProvider implements ProfileKnowledgeProvider, ParserBase
private List<ValidationMessage> errors;
private JsonObject defaultConfig;
private JsonObject resourceConfig;
private boolean autoPath = false;

public IGKnowledgeProvider(IWorkerContext context, String pathToSpec, JsonObject igs, List<ValidationMessage> errors) throws Exception {
super();
Expand All @@ -63,7 +64,9 @@ private void loadPaths(JsonObject igs) throws Exception {
if (resourceConfig == null)
throw new Exception("You must provide a list of resources in the json file");
for (Entry<String, JsonElement> pp : resourceConfig.entrySet()) {
if (!pp.getKey().startsWith("_")) {
if (pp.getKey().equals("*")) {
autoPath = true;
} else if (!pp.getKey().startsWith("_")) {
String s = pp.getKey();
if (!s.contains("/"))
throw new Exception("Bad Resource Identity - should have the format [Type]/[id]:" + s);
Expand All @@ -78,8 +81,8 @@ private void loadPaths(JsonObject igs) throws Exception {
throw new Exception("Unexpected type in resource list - must be an object");
JsonObject o = (JsonObject) pp.getValue();
JsonElement p = o.get("base");
// if (p == null)
// throw new Exception("You must provide a base on each path in the json file");
// if (p == null)
// throw new Exception("You must provide a base on each path in the json file");
if (p != null && !(p instanceof JsonPrimitive) && !((JsonPrimitive) p).isString())
throw new Exception("Unexpected type in paths - base must be a string");
p = o.get("defns");
Expand Down Expand Up @@ -411,4 +414,8 @@ public IWorkerContext getContext() {
return context;
}

public boolean isAutoPath() {
return autoPath;
}

}

0 comments on commit ab9aa4f

Please sign in to comment.