-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: John T.E. Timm <johntimm@us.ibm.com>
- Loading branch information
Showing
7 changed files
with
3,949 additions
and
51 deletions.
There are no files selected for viewing
85 changes: 85 additions & 0 deletions
85
...mance/fhir-ig-spl/src/test/java/com/ibm/fhir/ig/us/spl/EstablishmentOrganizationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* (C) Copyright IBM Corp. 2021 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.ibm.fhir.ig.us.spl; | ||
|
||
import java.io.InputStream; | ||
import java.util.List; | ||
import java.util.logging.Handler; | ||
import java.util.logging.Level; | ||
import java.util.logging.LogRecord; | ||
import java.util.logging.Logger; | ||
|
||
import com.ibm.fhir.model.format.Format; | ||
import com.ibm.fhir.model.parser.FHIRParser; | ||
import com.ibm.fhir.model.resource.OperationOutcome.Issue; | ||
import com.ibm.fhir.model.resource.Organization; | ||
import com.ibm.fhir.model.resource.Resource; | ||
import com.ibm.fhir.model.resource.StructureDefinition; | ||
import com.ibm.fhir.model.type.ContactPoint; | ||
import com.ibm.fhir.profile.ConstraintGenerator; | ||
import com.ibm.fhir.profile.ProfileSupport; | ||
import com.ibm.fhir.registry.FHIRRegistry; | ||
import com.ibm.fhir.registry.resource.FHIRRegistryResource; | ||
import com.ibm.fhir.registry.util.FHIRRegistryResourceProviderAdapter; | ||
import com.ibm.fhir.validation.FHIRValidator; | ||
|
||
public class EstablishmentOrganizationTest { | ||
public static void main(String[] args) throws Exception { | ||
Logger logger = Logger.getLogger(ConstraintGenerator.class.getName()); | ||
logger.setLevel(Level.FINEST); | ||
Handler h = new Handler() { | ||
@Override | ||
public void publish(LogRecord record) { | ||
System.out.println(record.getMessage()); | ||
} | ||
|
||
@Override | ||
public void flush() { | ||
} | ||
|
||
@Override | ||
public void close() throws SecurityException { | ||
} | ||
}; | ||
h.setLevel(Level.FINEST); | ||
logger.addHandler(h); | ||
|
||
try (InputStream in = EstablishmentOrganizationTest.class.getClassLoader().getResourceAsStream("xml/StructureDefinition-EstablishmentOrganization.xml")) { | ||
StructureDefinition structureDefinition = FHIRParser.parser(Format.XML).parse(in); | ||
FHIRRegistry.getInstance().addProvider(new FHIRRegistryResourceProviderAdapter() { | ||
@Override | ||
public FHIRRegistryResource getRegistryResource(Class<? extends Resource> resourceType, String url, String version) { | ||
if ("http://hl7.org/fhir/us/spl/StructureDefinition/EstablishmentOrganization".equals(url)) { | ||
return FHIRRegistryResource.from(structureDefinition); | ||
} | ||
return null; | ||
} | ||
}); | ||
ProfileSupport.getConstraints("http://hl7.org/fhir/us/spl/StructureDefinition/EstablishmentOrganization", Organization.class).forEach(System.out::println); | ||
} | ||
|
||
try (InputStream in = EstablishmentOrganizationTest.class.getClassLoader().getResourceAsStream("xml/StructureDefinition-SPLContactPoint.xml")) { | ||
StructureDefinition structureDefinition = FHIRParser.parser(Format.XML).parse(in); | ||
FHIRRegistry.getInstance().addProvider(new FHIRRegistryResourceProviderAdapter() { | ||
@Override | ||
public FHIRRegistryResource getRegistryResource(Class<? extends Resource> resourceType, String url, String version) { | ||
if ("http://hl7.org/fhir/us/spl/StructureDefinition/SPLContactPoint".equals(url)) { | ||
return FHIRRegistryResource.from(structureDefinition); | ||
} | ||
return null; | ||
} | ||
}); | ||
ProfileSupport.getConstraints("http://hl7.org/fhir/us/spl/StructureDefinition/SPLContactPoint", ContactPoint.class).forEach(System.out::println); | ||
} | ||
|
||
try (InputStream in = EstablishmentOrganizationTest.class.getClassLoader().getResourceAsStream("xml/Organization-ExampleEstablishment.xml")) { | ||
Organization organization = FHIRParser.parser(Format.XML).parse(in); | ||
List<Issue> issues = FHIRValidator.validator().validate(organization); | ||
issues.forEach(System.out::println); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
conformance/fhir-ig-spl/src/test/resources/xml/Organization-ExampleEstablishment.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<Organization xmlns="http://hl7.org/fhir"> | ||
<id value="ExampleEstablishmentRegistrant"/> | ||
<meta> | ||
<profile value="http://hl7.org/fhir/us/spl/StructureDefinition/EstablishmentOrganization"/> | ||
</meta> | ||
<text> | ||
<status value="generated"/><div xmlns="http://www.w3.org/1999/xhtml"><p><b>Generated Narrative</b></p><p><b>identifier</b>: id: 111111111</p><p><b>type</b>: <span title="Codes: {http://hl7.org/fhir/us/spl/CodeSystem/codesystem-splOrganizationTypes EstablishmentRegistrant}">An organization that registers establishment organizations.</span></p><p><b>name</b>: REGISTRANT SERVICES INC</p><h3>Contacts</h3><table class="grid"><tr><td>-</td><td><b>Name</b></td><td><b>Telecom</b></td><td><b>Address</b></td></tr><tr><td>*</td><td>Charles Smith</td><td><a href="tel:+1-703-362-1280;ext=1234">+1-703-362-1280;ext=1234</a>, <a href="mailto:charles@anywhere.com">charles@anywhere.com</a></td><td>123 IVY LANE ROAD SMITH FALLS MD 12345 USA </td></tr></table></div> | ||
</text> | ||
<identifier> | ||
<system value="urn:oid:1.3.6.1.4.1.519.1"/> | ||
<value value="111111111"/> | ||
</identifier> | ||
<type> | ||
<coding> | ||
<system value="http://hl7.org/fhir/us/spl/CodeSystem/codesystem-splOrganizationTypes"/> | ||
<code value="EstablishmentRegistrant"/> | ||
</coding> | ||
</type> | ||
<name value="REGISTRANT SERVICES INC"/> | ||
<contact> | ||
<name> | ||
<text value="Charles Smith"/> | ||
</name> | ||
<telecom> | ||
<system value="phone"/> | ||
<value value="+1-703-362-1280"/> | ||
</telecom> | ||
<telecom> | ||
<system value="email"/> | ||
<value value="charles@anywhere.com"/> | ||
</telecom> | ||
<address> | ||
<line value="123 IVY LANE ROAD"/> | ||
<city value="SMITH FALLS"/> | ||
<state value="MD"/> | ||
<postalCode value="12345"/> | ||
<country value="USA"/> | ||
</address> | ||
</contact> | ||
</Organization> |
Oops, something went wrong.