Add validation
This commit is contained in:
parent
9fef4f6bab
commit
e29e10450c
|
@ -35,6 +35,7 @@ public class App {
|
||||||
ourCommands.add(new RunServerCommand());
|
ourCommands.add(new RunServerCommand());
|
||||||
ourCommands.add(new ExampleDataUploader());
|
ourCommands.add(new ExampleDataUploader());
|
||||||
ourCommands.add(new ValidateCommand());
|
ourCommands.add(new ValidateCommand());
|
||||||
|
ourCommands.add(new ValidationDataUploader());
|
||||||
|
|
||||||
Collections.sort(ourCommands);
|
Collections.sort(ourCommands);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,8 @@ public class RunServerCommand extends BaseCommand {
|
||||||
public void run(CommandLine theCommandLine) throws ParseException {
|
public void run(CommandLine theCommandLine) throws ParseException {
|
||||||
myPort = parseOptionInteger(theCommandLine, OPTION_P, DEFAULT_PORT);
|
myPort = parseOptionInteger(theCommandLine, OPTION_P, DEFAULT_PORT);
|
||||||
|
|
||||||
|
// ((ch.qos.logback.classic.Logger)LoggerFactory.getLogger("/")).setLevel(Level.ERROR);
|
||||||
|
|
||||||
ourLog.info("Preparing HAPI FHIR JPA server");
|
ourLog.info("Preparing HAPI FHIR JPA server");
|
||||||
File tempWarFile;
|
File tempWarFile;
|
||||||
try {
|
try {
|
||||||
|
@ -81,6 +83,8 @@ public class RunServerCommand extends BaseCommand {
|
||||||
ourLog.info("Server started on port {}", myPort);
|
ourLog.info("Server started on port {}", myPort);
|
||||||
ourLog.info("Web Testing UI : http://localhost:{}/", myPort);
|
ourLog.info("Web Testing UI : http://localhost:{}/", myPort);
|
||||||
ourLog.info("Server Base URL: http://localhost:{}/baseDstu2/", myPort);
|
ourLog.info("Server Base URL: http://localhost:{}/baseDstu2/", myPort);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(String[] theArgs) {
|
public void run(String[] theArgs) {
|
||||||
|
|
|
@ -1,134 +1,157 @@
|
||||||
package ca.uhn.fhir.cli;
|
package ca.uhn.fhir.cli;
|
||||||
|
|
||||||
|
import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
|
import org.apache.commons.cli.Option;
|
||||||
import org.apache.commons.cli.Options;
|
import org.apache.commons.cli.Options;
|
||||||
import org.apache.commons.cli.ParseException;
|
import org.apache.commons.cli.ParseException;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.hl7.fhir.instance.model.Bundle;
|
|
||||||
import org.hl7.fhir.instance.model.Bundle.BundleEntryComponent;
|
|
||||||
import org.hl7.fhir.instance.model.StructureDefinition;
|
|
||||||
import org.hl7.fhir.instance.model.ValueSet;
|
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
|
||||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||||
|
|
||||||
import ca.uhn.fhir.context.FhirContext;
|
import ca.uhn.fhir.context.FhirContext;
|
||||||
|
import ca.uhn.fhir.model.dstu2.resource.Bundle;
|
||||||
|
import ca.uhn.fhir.model.dstu2.resource.Bundle.Entry;
|
||||||
|
import ca.uhn.fhir.model.dstu2.resource.StructureDefinition;
|
||||||
|
import ca.uhn.fhir.model.dstu2.resource.ValueSet;
|
||||||
|
import ca.uhn.fhir.parser.DataFormatException;
|
||||||
import ca.uhn.fhir.rest.client.IGenericClient;
|
import ca.uhn.fhir.rest.client.IGenericClient;
|
||||||
|
|
||||||
public class ValidationDataUploader extends BaseCommand {
|
public class ValidationDataUploader extends BaseCommand {
|
||||||
|
|
||||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidationDataUploader.class);
|
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidationDataUploader.class);
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
@Override
|
||||||
new ValidationDataUploader().execute();
|
public String getCommandDescription() {
|
||||||
|
return "Uploads the conformance resources (StructureDefinition and ValueSet) from the official FHIR definitions.";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void execute() throws IOException, ClientProtocolException, UnsupportedEncodingException {
|
@Override
|
||||||
ourLog.info("Starting...");
|
public String getCommandName() {
|
||||||
|
return "upload-definitions";
|
||||||
|
}
|
||||||
|
|
||||||
FhirContext ctx = FhirContext.forDstu2Hl7Org();
|
@Override
|
||||||
|
public Options getOptions() {
|
||||||
|
Options options = new Options();
|
||||||
|
Option opt;
|
||||||
|
|
||||||
IGenericClient client = newClient(ctx,"");
|
opt = new Option("t", "target", true, "Base URL for the target server (e.g. \"http://example.com/fhir\")");
|
||||||
|
opt.setRequired(true);
|
||||||
|
options.addOption(opt);
|
||||||
|
|
||||||
int total;
|
return options;
|
||||||
int count;
|
}
|
||||||
|
|
||||||
// String vsContents =
|
@Override
|
||||||
// IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/valuesets.xml"),
|
public void run(CommandLine theCommandLine) throws ParseException {
|
||||||
// "UTF-8");
|
String targetServer = theCommandLine.getOptionValue("t");
|
||||||
// Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
if (isBlank(targetServer)) {
|
||||||
//
|
throw new ParseException("No target server (-t) specified");
|
||||||
// int total = bundle.getEntry().size();
|
} else if (targetServer.startsWith("http") == false) {
|
||||||
// int count = 1;
|
throw new ParseException("Invalid target server specified, must begin with 'http'");
|
||||||
// for (BundleEntryComponent i : bundle.getEntry()) {
|
}
|
||||||
// ValueSet next = (ValueSet) i.getResource();
|
|
||||||
// next.setId(next.getIdElement().toUnqualifiedVersionless());
|
|
||||||
//
|
|
||||||
// ourLog.info("Uploading ValueSet {}/{} : {}", new Object[] {count,total,next.getIdElement().getValue()});
|
|
||||||
// client.update().resource(next).execute();
|
|
||||||
//
|
|
||||||
// count++;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// ourLog.info("Finished uploading ValueSets");
|
|
||||||
|
|
||||||
// String vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/v3-codesystems.xml"), "UTF-8");
|
FhirContext ctx = FhirContext.forDstu2();
|
||||||
// Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
ourLog.info("Uploading definitions to server: " + targetServer);
|
||||||
// total = bundle.getEntry().size();
|
|
||||||
// count = 1;
|
|
||||||
// for (BundleEntryComponent i : bundle.getEntry()) {
|
|
||||||
// ValueSet next = (ValueSet) i.getResource();
|
|
||||||
// next.setId(next.getIdElement().toUnqualifiedVersionless());
|
|
||||||
//
|
|
||||||
// ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
|
||||||
// client.update().resource(next).execute();
|
|
||||||
//
|
|
||||||
// count++;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
IGenericClient client = newClient(ctx, targetServer);
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
String vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/v2-tables.xml"), "UTF-8");
|
String vsContents;
|
||||||
|
try {
|
||||||
|
vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/valuesets.xml"), "UTF-8");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CommandFailureException(e.toString());
|
||||||
|
}
|
||||||
Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
Bundle bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
||||||
|
|
||||||
|
int total = bundle.getEntry().size();
|
||||||
|
int count = 1;
|
||||||
|
for (Entry i : bundle.getEntry()) {
|
||||||
|
ValueSet next = (ValueSet) i.getResource();
|
||||||
|
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
||||||
|
|
||||||
|
ourLog.info("Uploading ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
||||||
|
client.update().resource(next).execute();
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/v3-codesystems.xml"), "UTF-8");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CommandFailureException(e.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
||||||
total = bundle.getEntry().size();
|
total = bundle.getEntry().size();
|
||||||
count = 1;
|
count = 1;
|
||||||
for (BundleEntryComponent i : bundle.getEntry()) {
|
for (Entry i : bundle.getEntry()) {
|
||||||
if (count > 1900) {
|
ValueSet next = (ValueSet) i.getResource();
|
||||||
|
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
||||||
|
|
||||||
|
ourLog.info("Uploading v3-codesystems ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
||||||
|
client.update().resource(next).execute();
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
vsContents = IOUtils.toString(ValidationDataUploader.class.getResourceAsStream("/org/hl7/fhir/instance/model/valueset/v2-tables.xml"), "UTF-8");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CommandFailureException(e.toString());
|
||||||
|
}
|
||||||
|
bundle = ctx.newXmlParser().parseResource(Bundle.class, vsContents);
|
||||||
|
total = bundle.getEntry().size();
|
||||||
|
count = 1;
|
||||||
|
for (Entry i : bundle.getEntry()) {
|
||||||
ValueSet next = (ValueSet) i.getResource();
|
ValueSet next = (ValueSet) i.getResource();
|
||||||
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
||||||
|
|
||||||
ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
ourLog.info("Uploading v2-tables ValueSet {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
||||||
client.update().resource(next).execute();
|
client.update().resource(next).execute();
|
||||||
}
|
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.info("Finished uploading ValueSets");
|
ourLog.info("Finished uploading ValueSets");
|
||||||
|
|
||||||
ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
|
ResourcePatternResolver patternResolver = new PathMatchingResourcePatternResolver();
|
||||||
Resource[] mappingLocations = patternResolver.getResources("classpath*:org/hl7/fhir/instance/model/profile/*.profile.xml");
|
Resource[] mappingLocations;
|
||||||
|
try {
|
||||||
|
mappingLocations = patternResolver.getResources("classpath*:org/hl7/fhir/instance/model/profile/*.profile.xml");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CommandFailureException(e.toString());
|
||||||
|
}
|
||||||
total = mappingLocations.length;
|
total = mappingLocations.length;
|
||||||
count = 1;
|
count = 1;
|
||||||
for (Resource i : mappingLocations) {
|
for (Resource i : mappingLocations) {
|
||||||
if (count > 140) {
|
StructureDefinition next;
|
||||||
StructureDefinition next = ctx.newXmlParser().parseResource(StructureDefinition.class, IOUtils.toString(i.getInputStream(), "UTF-8"));
|
try {
|
||||||
|
next = ctx.newXmlParser().parseResource(StructureDefinition.class, IOUtils.toString(i.getInputStream(), "UTF-8"));
|
||||||
|
} catch (DataFormatException | IOException e) {
|
||||||
|
throw new CommandFailureException(e.toString());
|
||||||
|
}
|
||||||
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
next.setId(next.getIdElement().toUnqualifiedVersionless());
|
||||||
|
|
||||||
ourLog.info("Uploading StructureDefinition {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
ourLog.info("Uploading StructureDefinition {}/{} : {}", new Object[] { count, total, next.getIdElement().getValue() });
|
||||||
|
try {
|
||||||
client.update().resource(next).execute();
|
client.update().resource(next).execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
ourLog.warn("Failed to upload {} - {}", next.getIdElement().getValue(), e.getMessage());
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
ourLog.info("Finished uploading ValueSets");
|
ourLog.info("Finished uploading ValueSets");
|
||||||
|
|
||||||
}
|
long delay = System.currentTimeMillis() - start;
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandDescription() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getCommandName() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Options getOptions() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run(CommandLine theCommandLine) throws ParseException {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
|
ourLog.info("Finished uploading definitions to server (took {} ms)", delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,38 +8,11 @@
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<logger name="java.sql" additivity="false" level="warn">
|
<logger name="ca.uhn.fhir.cli" additivity="false" level="info">
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="ca.uhn.fhir.jpa" additivity="false" level="info">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="ca.uhn.fhir.rest" additivity="false" level="warn">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.eclipse" additivity="false" level="warn">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.springframework" additivity="false" level="warn">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.apache" additivity="false" level="info">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.thymeleaf" additivity="false" level="warn">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
<logger name="org.hibernate" additivity="false" level="warn">
|
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<!--
|
<root level="warn">
|
||||||
<logger name="ca.uhn.fhir.rest.client" additivity="false" level="trace">
|
|
||||||
<appender-ref ref="STDOUT" />
|
|
||||||
</logger>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
|
@ -101,17 +101,15 @@ public class FhirResourceDaoSubscriptionDstu2 extends FhirResourceDaoDstu2<Subsc
|
||||||
|
|
||||||
// SubscriptionCandidateResource
|
// SubscriptionCandidateResource
|
||||||
|
|
||||||
TypedQuery<SubscriptionTable> q = myEntityManager.createNamedQuery("Q_HFJ_SUBSCRIPTION_NEXT_CHECK", SubscriptionTable.class);
|
Collection<Long> subscriptions = mySubscriptionTableDao.finsSubscriptionsWhichNeedToBeChecked(SubscriptionStatusEnum.ACTIVE, new Date());
|
||||||
q.setParameter("next_check", new Date());
|
|
||||||
q.setParameter("status", SubscriptionStatusEnum.ACTIVE);
|
|
||||||
List<SubscriptionTable> subscriptions = q.getResultList();
|
|
||||||
|
|
||||||
TransactionTemplate txTemplate = new TransactionTemplate(myTxManager);
|
TransactionTemplate txTemplate = new TransactionTemplate(myTxManager);
|
||||||
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
txTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);
|
||||||
for (final SubscriptionTable nextSubscriptionTable : subscriptions) {
|
for (final Long nextSubscriptionTablePid : subscriptions) {
|
||||||
txTemplate.execute(new TransactionCallback<Void>() {
|
txTemplate.execute(new TransactionCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void doInTransaction(TransactionStatus theStatus) {
|
public Void doInTransaction(TransactionStatus theStatus) {
|
||||||
|
SubscriptionTable nextSubscriptionTable = mySubscriptionTableDao.findOne(nextSubscriptionTablePid);
|
||||||
pollForNewUndeliveredResources(nextSubscriptionTable);
|
pollForNewUndeliveredResources(nextSubscriptionTable);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.data.repository.query.Param;
|
import org.springframework.data.repository.query.Param;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.entity.SubscriptionTable;
|
import ca.uhn.fhir.jpa.entity.SubscriptionTable;
|
||||||
|
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
|
||||||
|
|
||||||
public interface ISubscriptionTableDao extends JpaRepository<SubscriptionTable, Long> {
|
public interface ISubscriptionTableDao extends JpaRepository<SubscriptionTable, Long> {
|
||||||
|
|
||||||
|
@ -46,4 +47,6 @@ public interface ISubscriptionTableDao extends JpaRepository<SubscriptionTable,
|
||||||
@Query("SELECT t FROM SubscriptionTable t WHERE t.myLastClientPoll < :cutoff OR (t.myLastClientPoll IS NULL AND t.myCreated < :cutoff)")
|
@Query("SELECT t FROM SubscriptionTable t WHERE t.myLastClientPoll < :cutoff OR (t.myLastClientPoll IS NULL AND t.myCreated < :cutoff)")
|
||||||
public Collection<SubscriptionTable> findInactiveBeforeCutoff(@Param("cutoff") Date theCutoff);
|
public Collection<SubscriptionTable> findInactiveBeforeCutoff(@Param("cutoff") Date theCutoff);
|
||||||
|
|
||||||
|
@Query("SELECT t.myId FROM SubscriptionTable t WHERE t.myStatus = :status AND t.myNextCheck <= :next_check")
|
||||||
|
public Collection<Long> finsSubscriptionsWhichNeedToBeChecked(@Param("status") SubscriptionStatusEnum theStatus, @Param("next_check") Date theNextCheck);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
|
||||||
})
|
})
|
||||||
@NamedQueries({
|
@NamedQueries({
|
||||||
@NamedQuery(name="Q_HFJ_SUBSCRIPTION_SET_STATUS", query="UPDATE SubscriptionTable t SET t.myStatus = :status WHERE t.myResId = :res_id"),
|
@NamedQuery(name="Q_HFJ_SUBSCRIPTION_SET_STATUS", query="UPDATE SubscriptionTable t SET t.myStatus = :status WHERE t.myResId = :res_id"),
|
||||||
@NamedQuery(name="Q_HFJ_SUBSCRIPTION_NEXT_CHECK", query="SELECT t FROM SubscriptionTable t WHERE t.myStatus = :status AND t.myNextCheck <= :next_check"),
|
|
||||||
@NamedQuery(name="Q_HFJ_SUBSCRIPTION_GET_BY_RES", query="SELECT t FROM SubscriptionTable t WHERE t.myResId = :res_id")
|
@NamedQuery(name="Q_HFJ_SUBSCRIPTION_GET_BY_RES", query="SELECT t FROM SubscriptionTable t WHERE t.myResId = :res_id")
|
||||||
})
|
})
|
||||||
//@formatter:on
|
//@formatter:on
|
||||||
|
|
|
@ -6,6 +6,7 @@ import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.jetty.websocket.api.Session;
|
import org.eclipse.jetty.websocket.api.Session;
|
||||||
|
@ -19,6 +20,7 @@ import org.hl7.fhir.instance.model.api.IIdType;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptor;
|
import ca.uhn.fhir.jpa.util.SubscriptionsRequireManualActivationInterceptor;
|
||||||
|
import ca.uhn.fhir.model.api.ResourceMetadataKeyEnum;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
import ca.uhn.fhir.model.dstu2.resource.Observation;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||||
import ca.uhn.fhir.model.dstu2.resource.Subscription;
|
import ca.uhn.fhir.model.dstu2.resource.Subscription;
|
||||||
|
@ -250,6 +252,7 @@ public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
mySubscriptionDao.read(new IdDt("Subscription", socket.mySubsId));
|
mySubscriptionDao.read(new IdDt("Subscription", socket.mySubsId));
|
||||||
|
|
||||||
Observation obs = new Observation();
|
Observation obs = new Observation();
|
||||||
|
ResourceMetadataKeyEnum.PROFILES.put(obs, Collections.singletonList(new IdDt("http://foo")));
|
||||||
obs.getSubject().setReference(pId);
|
obs.getSubject().setReference(pId);
|
||||||
obs.setStatus(ObservationStatusEnum.FINAL);
|
obs.setStatus(ObservationStatusEnum.FINAL);
|
||||||
IIdType afterId1 = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
|
IIdType afterId1 = myObservationDao.create(obs).getId().toUnqualifiedVersionless();
|
||||||
|
@ -301,6 +304,7 @@ public class SubscriptionsDstu2Test extends BaseResourceProviderDstu2Test {
|
||||||
IIdType pId = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
IIdType pId = myPatientDao.create(p).getId().toUnqualifiedVersionless();
|
||||||
|
|
||||||
Subscription subs = new Subscription();
|
Subscription subs = new Subscription();
|
||||||
|
ResourceMetadataKeyEnum.PROFILES.put(subs, Collections.singletonList(new IdDt("http://foo")));
|
||||||
subs.getChannel().setType(SubscriptionChannelTypeEnum.WEBSOCKET);
|
subs.getChannel().setType(SubscriptionChannelTypeEnum.WEBSOCKET);
|
||||||
subs.setCriteria("Observation?subject=Patient/" + pId.getIdPart());
|
subs.setCriteria("Observation?subject=Patient/" + pId.getIdPart());
|
||||||
subs.setStatus(SubscriptionStatusEnum.ACTIVE);
|
subs.setStatus(SubscriptionStatusEnum.ACTIVE);
|
||||||
|
|
Loading…
Reference in New Issue