I'm working on a JavaScript write source connector to pull patients from MirthResults and build a CDA. Once the CDA is generated it will be sent to a destination. I'm encountering issues calling the function createCdaFromSubject. Below is the code I'm using as well as the error message I'm receiving. Not sure if it has to do with the last two parameters being in Gregorian date format or how to convert them to Julian dates. Any ideas what I'm doing wrong in the function call?
Source Code:
importPackage(com.mirth.results.client);
importPackage(com.mirth.results.models.serializer) ;
var client = MirthResultsClient("http://localhost:8888", "mirth", "m1rthr3sults");
var subjectFilterModel = new SubjectFilterModel();
var today = new Date();
var yesterday = new Date();
var documentTypeName = 'C32';
var today_dd = today.getDate();
var today_mm = today.getMonth() + 1; //January is 0!
var today_yyyy = today.getFullYear();
if (today_dd < 10)
{
today_dd = '0' + today_dd
}
if (today_mm < 10)
{
today_mm ='0' + today_mm
}
today = today_mm + '/' + today_dd + '/' + today_yyyy;
yesterday.setDate(yesterday.getDate() - 100);
var yesterday_dd = yesterday.getDate();
var yesterday_mm = yesterday.getMonth() + 1; //January is 0!
var yesterday_yyyy = yesterday.getFullYear();
if (yesterday_dd < 10)
{
yesterday_dd = '0' + today_dd
}
if (yesterday_mm < 10)
{
yesterday_mm ='0' + today_mm
}
yesterday = yesterday_mm + '/' + yesterday_dd + '/' + yesterday_yyyy;
var endDate = DateUtil.getDate("MM/dd/yyyy", today);
var gregEndDate = client.dateToGregorian(endDate);
var startDate = DateUtil.getDate("MM/dd/yyyy", yesterday);
var gregStartDate = client.dateToGregorian(startDate);
subjectFilterModel.setSubjectUpdatedStart(gregStar tDate);
subjectFilterModel.setSubjectUpdatedEnd(gregEndDat e);
// get patient model then get document
var resultModel = client.getPatientsByFilter(subjectFilterModel);
var serializer = Packages.com.mirth.results.models.serializer.Model Serializer.getInstance();
if (!resultModel.isOperationSucceeded())
{
throw "Error was: " + resultModel.toStatus().toString();
}
else
{
var results = resultModel.getResult();
for (i = 0; i < results.size(); i++)
{
var patientModel = results.get(i);
logger.info(serializer.toXML(patientModel));
// get patient id
var id = patientModel.getId();
// get clinical document model by patient id
var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName,
subjectFilterModel.getSubjectUpdatedStart(),
subjectFilterModel.getSubjectUpdatedEnd());
if (!cdaResults.isOperationSucceeded())
{
throw "Error was: " + cdaResults.toStatus().toString();
}
else
{
// Send CDA...
}
}
}
Error Message:
[2015-03-02 03:56:29,543] ERROR (com.mirth.connect.connectors.js.JavaScriptReceive r:90): Error executing JavaScript Reader script f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff.
com.mirth.connect.server.util.javascript.JavaScrip tExecutorException: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
MirthResults To CDACONNECTOR:
SourceSOURCE CODE:
247: 248:
// get patient id249: var id = patientModel.getId();250: 251:
// get clinical document model by patient id252: var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName, 253:
subjectFilterModel.getSubjectUpdatedStart(), 254:
subjectFilterModel.getSubjectUpdatedEnd());255: 256:
if (!cdaResults.isOperationSucceeded()) LINE NUMBER:
252DETAILS:
Can't find method com.mirth.results.client.MirthResultsClient.create CdaFromSubject(java.lang.String,java.lang.String,s tring,org.apache.xerces.jaxp.datatype.XMLGregorian CalendarImpl,org.apache.xerces.jaxp.datatype.XMLGr egorianCalendarImpl).
at f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff:252 (doScript)
at f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff:267
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.execute(JavaScriptUtil.java:62)
at com.mirth.connect.connectors.js.JavaScriptReceiver .poll(JavaScriptReceiver.java:88)
at com.mirth.connect.donkey.server.channel.PollConnec tor$PollConnectorTask.run(PollConnector.java:141)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)Caused by: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
MirthResults To CDACONNECTOR:
SourceSOURCE CODE:
247: 248:
// get patient id249: var id = patientModel.getId();250: 251:
// get clinical document model by patient id252: var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName, 253:
subjectFilterModel.getSubjectUpdatedStart(), 254:
createCdaFrom Subject Definition:
createCdaFromSubject
Finds a patient with a given ID and builds a CDA of the specified type with the clinical information found in the
specified date range.
Parameters
Element Type Description
subjectId String any identifier for the subject (MR ID, MRN, etc)
receivingFacilityId String the ID of the receiving facility
documentTypeName String the type of document to create, such as LAB_REPORT, C32, C62,
SUMMARIZATION_OF_EPISODE, SSA
beginDate Date the date for the earliest clinical items to retrieve
endDate Date the date for the latest clinical items to retrieve
Source Code:
importPackage(com.mirth.results.client);
importPackage(com.mirth.results.models.serializer) ;
var client = MirthResultsClient("http://localhost:8888", "mirth", "m1rthr3sults");
var subjectFilterModel = new SubjectFilterModel();
var today = new Date();
var yesterday = new Date();
var documentTypeName = 'C32';
var today_dd = today.getDate();
var today_mm = today.getMonth() + 1; //January is 0!
var today_yyyy = today.getFullYear();
if (today_dd < 10)
{
today_dd = '0' + today_dd
}
if (today_mm < 10)
{
today_mm ='0' + today_mm
}
today = today_mm + '/' + today_dd + '/' + today_yyyy;
yesterday.setDate(yesterday.getDate() - 100);
var yesterday_dd = yesterday.getDate();
var yesterday_mm = yesterday.getMonth() + 1; //January is 0!
var yesterday_yyyy = yesterday.getFullYear();
if (yesterday_dd < 10)
{
yesterday_dd = '0' + today_dd
}
if (yesterday_mm < 10)
{
yesterday_mm ='0' + today_mm
}
yesterday = yesterday_mm + '/' + yesterday_dd + '/' + yesterday_yyyy;
var endDate = DateUtil.getDate("MM/dd/yyyy", today);
var gregEndDate = client.dateToGregorian(endDate);
var startDate = DateUtil.getDate("MM/dd/yyyy", yesterday);
var gregStartDate = client.dateToGregorian(startDate);
subjectFilterModel.setSubjectUpdatedStart(gregStar tDate);
subjectFilterModel.setSubjectUpdatedEnd(gregEndDat e);
// get patient model then get document
var resultModel = client.getPatientsByFilter(subjectFilterModel);
var serializer = Packages.com.mirth.results.models.serializer.Model Serializer.getInstance();
if (!resultModel.isOperationSucceeded())
{
throw "Error was: " + resultModel.toStatus().toString();
}
else
{
var results = resultModel.getResult();
for (i = 0; i < results.size(); i++)
{
var patientModel = results.get(i);
logger.info(serializer.toXML(patientModel));
// get patient id
var id = patientModel.getId();
// get clinical document model by patient id
var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName,
subjectFilterModel.getSubjectUpdatedStart(),
subjectFilterModel.getSubjectUpdatedEnd());
if (!cdaResults.isOperationSucceeded())
{
throw "Error was: " + cdaResults.toStatus().toString();
}
else
{
// Send CDA...
}
}
}
Error Message:
[2015-03-02 03:56:29,543] ERROR (com.mirth.connect.connectors.js.JavaScriptReceive r:90): Error executing JavaScript Reader script f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff.
com.mirth.connect.server.util.javascript.JavaScrip tExecutorException: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
MirthResults To CDACONNECTOR:
SourceSOURCE CODE:
247: 248:
// get patient id249: var id = patientModel.getId();250: 251:
// get clinical document model by patient id252: var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName, 253:
subjectFilterModel.getSubjectUpdatedStart(), 254:
subjectFilterModel.getSubjectUpdatedEnd());255: 256:
if (!cdaResults.isOperationSucceeded()) LINE NUMBER:
252DETAILS:
Can't find method com.mirth.results.client.MirthResultsClient.create CdaFromSubject(java.lang.String,java.lang.String,s tring,org.apache.xerces.jaxp.datatype.XMLGregorian CalendarImpl,org.apache.xerces.jaxp.datatype.XMLGr egorianCalendarImpl).
at f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff:252 (doScript)
at f6c08a1d-bcf5-4bd1-b85b-740fd2e159ff:267
at com.mirth.connect.server.util.javascript.JavaScrip tUtil.execute(JavaScriptUtil.java:62)
at com.mirth.connect.connectors.js.JavaScriptReceiver .poll(JavaScriptReceiver.java:88)
at com.mirth.connect.donkey.server.channel.PollConnec tor$PollConnectorTask.run(PollConnector.java:141)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)Caused by: com.mirth.connect.server.MirthJavascriptTransforme rException: CHANNEL:
MirthResults To CDACONNECTOR:
SourceSOURCE CODE:
247: 248:
// get patient id249: var id = patientModel.getId();250: 251:
// get clinical document model by patient id252: var cdaResults = client.createCdaFromSubject(id, $('facility'), documentTypeName, 253:
subjectFilterModel.getSubjectUpdatedStart(), 254:
createCdaFrom Subject Definition:
createCdaFromSubject
Finds a patient with a given ID and builds a CDA of the specified type with the clinical information found in the
specified date range.
Parameters
Element Type Description
subjectId String any identifier for the subject (MR ID, MRN, etc)
receivingFacilityId String the ID of the receiving facility
documentTypeName String the type of document to create, such as LAB_REPORT, C32, C62,
SUMMARIZATION_OF_EPISODE, SSA
beginDate Date the date for the earliest clinical items to retrieve
endDate Date the date for the latest clinical items to retrieve
Unable to call createCdaFromSubject
0 commentaires:
Enregistrer un commentaire