mdht / mdht-models

This branch supports Rational Software components
25 stars 18 forks source link

Generating CCD document using MDHT API inANDROID #104

Open karthick229 opened 7 years ago

karthick229 commented 7 years ago

I am trying to use MDHT API to generate CCD documents IN Android. I am doing this in the following way.I am download this below link....Myself didn't How the way to integrate in Android Studio...... I was wondering if I am missing anything. Is there any open source MDHT GUI that generates code for each section or am I moving in the right direction?

Downloaded Java run time libraries and placed them in class path and writing code to generate all the sections using MDHT API. https://github.com/mdht/mdht/tree/develop/www/cn-project-pages/snippets https://github.com/chintanop/ccda-rest-api https://github.com/chris-watson/xpathvalidator

I have already looked at user guide/developers guide. Any help is appreciated.

swmuir commented 7 years ago

I am not sure of the particulars of Android Studio but the latest release of MDHT runtime support the consolidated specification is here

https://github.com/mdht/mdht-models/releases

This supplies the java api used to create CCD documents

Look into the how to import third party jars into android studio

Thanks

sean

I am not familiar withe res

On Feb 4, 2017, at 12:00 AM, karthick229 notifications@github.com wrote:

I am trying to use MDHT API to generate CCD documents IN Android. I am doing this in the following way.I am download this below link....Myself didn't How the way to integrate in Android Studio...... I was wondering if I am missing anything. Is there any open source MDHT GUI that generates code for each section or am I moving in the right direction?

Downloaded Java run time libraries and placed them in class path and writing code to generate all the sections using MDHT API. https://github.com/mdht/mdht/tree/develop/www/cn-project-pages/snippets https://github.com/mdht/mdht/tree/develop/www/cn-project-pages/snippets https://github.com/chintanop/ccda-rest-api https://github.com/chintanop/ccda-rest-api https://github.com/chris-watson/xpathvalidator https://github.com/chris-watson/xpathvalidator I have already looked at user guide/developers guide. Any help is appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mdht/mdht-models/issues/104, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGeF3rsc4iiZaP5mJiqtWBKTZnb6M62ks5rZAX0gaJpZM4L3Ctq.

drbgfc commented 7 years ago

There is no GUI that I know of besides using eclipse itself. I don't see any reason why you shouldn't be able to drop the MDHT jars in Android Studio and run them on android (but it sounds like this is what you have done already). I noticed you are looking into using the xpathvalidator which is a fork of a SITE project that is now deprecated (I believe replaced with the codevalidator). You may want to see if any of these projects will help you as well, but I don't think you should need anything beyond the latest MDHT release: https://github.com/siteadmin

On 2/5/2017 9:12 AM, Sean Muir wrote:

I am not sure of the particulars of Android Studio but the latest release of MDHT runtime support the consolidated specification is here

https://github.com/mdht/mdht-models/releases

This supplies the java api used to create CCD documents

Look into the how to import third party jars into android studio

Thanks

sean

I am not familiar withe res

On Feb 4, 2017, at 12:00 AM, karthick229 notifications@github.com wrote:

I am trying to use MDHT API to generate CCD documents IN Android. I am doing this in the following way.I am download this below link....Myself didn't How the way to integrate in Android Studio...... I was wondering if I am missing anything. Is there any open source MDHT GUI that generates code for each section or am I moving in the right direction?

Downloaded Java run time libraries and placed them in class path and writing code to generate all the sections using MDHT API.

https://github.com/mdht/mdht/tree/develop/www/cn-project-pages/snippets https://github.com/mdht/mdht/tree/develop/www/cn-project-pages/snippets https://github.com/chintanop/ccda-rest-api https://github.com/chintanop/ccda-rest-api https://github.com/chris-watson/xpathvalidator https://github.com/chris-watson/xpathvalidator I have already looked at user guide/developers guide. Any help is appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mdht/mdht-models/issues/104, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGeF3rsc4iiZaP5mJiqtWBKTZnb6M62ks5rZAX0gaJpZM4L3Ctq.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mdht/mdht-models/issues/104#issuecomment-277522289, or mute the thread https://github.com/notifications/unsubscribe-auth/AFPaJsur5UCUzo_bMrBf66QSwm2WfprRks5rZdjZgaJpZM4L3Ctq.

karthick229 commented 7 years ago

Error.......after adding eclipse jar in my file............

Process: com.animedix.health_hive, PID: 15405 java.lang.NoClassDefFoundError: org.eclipse.ocl.AbstractTypeResolver$ResolveSwitch at org.eclipse.ocl.AbstractTypeResolver.(AbstractTypeResolver.java:66) at org.eclipse.ocl.ecore.internal.TypeResolverImpl.(TypeResolverImpl.java:56) at org.eclipse.ocl.ecore.EcoreEnvironment.createTypeResolver(EcoreEnvironment.java:310) at org.eclipse.ocl.ecore.EcoreEnvironment.(EcoreEnvironment.java:160) at org.eclipse.ocl.ecore.EcoreEnvironmentFactory.createEnvironment(EcoreEnvironmentFactory.java:107) at org.eclipse.ocl.OCL.(OCL.java:96) at org.eclipse.ocl.ecore.OCL.(OCL.java:84) at org.eclipse.ocl.ecore.OCL.newInstance(OCL.java:123) at org.openhealthtools.mdht.uml.cda.util.CDAUtil.(CDAUtil.java:1207) at org.openhealthtools.mdht.uml.cda.util.AnnotationBasedInitializer.initialize(AnnotationBasedInitializer.java:46) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:465) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:459) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:437) at org.openhealthtools.mdht.uml.cda.ccd.impl.ContinuityOfCareDocumentImpl.init(ContinuityOfCareDocumentImpl.java:544) at com.animedix.health_hive.Ccd.createccd(Ccd.java:48) at com.animedix.health_hive.access.MainActivity.onCreate(MainActivity.java:66) at android.app.Activity.performCreate(Activity.java:6543) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5740) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)

ccd.java

package com.animedix.health_hive;

import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.util.Log;

import org.openhealthtools.mdht.uml.cda.CDAFactory; import org.openhealthtools.mdht.uml.cda.Participant2; import org.openhealthtools.mdht.uml.cda.ParticipantRole; import org.openhealthtools.mdht.uml.cda.Patient; import org.openhealthtools.mdht.uml.cda.PatientRole; import org.openhealthtools.mdht.uml.cda.PlayingEntity; import org.openhealthtools.mdht.uml.cda.ccd.AlertObservation; import org.openhealthtools.mdht.uml.cda.ccd.AlertStatusObservation; import org.openhealthtools.mdht.uml.cda.ccd.AlertsSection; import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory; import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument; import org.openhealthtools.mdht.uml.cda.ccd.ProblemAct; import org.openhealthtools.mdht.uml.cda.ccd.ReactionObservation; import org.openhealthtools.mdht.uml.cda.util.CDAUtil; import org.openhealthtools.mdht.uml.hl7.datatypes.AD; import org.openhealthtools.mdht.uml.hl7.datatypes.CD; import org.openhealthtools.mdht.uml.hl7.datatypes.CE; import org.openhealthtools.mdht.uml.hl7.datatypes.CS; import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; import org.openhealthtools.mdht.uml.hl7.datatypes.II; import org.openhealthtools.mdht.uml.hl7.datatypes.PN; import org.openhealthtools.mdht.uml.hl7.datatypes.TS; import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassRoot; import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot;

import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.util.UUID;

public class Ccd extends AppCompatActivity{

public void createccd() {

    // create and initialize an instance of the ContinuityOfCareDocument class
    ContinuityOfCareDocument ccdDocument = CCDFactory.eINSTANCE.createContinuityOfCareDocument().init();
    Log.e("ccd", "ccd"+ccdDocument);
    // create a patient role object and add it to the document
    PatientRole patientRole = CDAFactory.eINSTANCE.createPatientRole();
    ccdDocument.addPatientRole(patientRole);
    II id = DatatypesFactory.eINSTANCE.createII();

// patientRole.getIds().add(id);//*//

    id.setRoot("996-756-495");
    id.setExtension("2.16.840.1.113883.19.5");

    // create an address object and add it to patient role
    AD addr = DatatypesFactory.eINSTANCE.createAD();
    //*

//patientRole.getAddrs().add(addr);//*//

    //*

//addr.getUses().add(PostalAddressUse.H);//*//

    addr.addStreetAddressLine("1313 Mockingbird Lane");
    addr.addCity("Janesville");
    addr.addState("WI");
    addr.addPostalCode("53545");

    // create a patient object and add it to patient role
    Patient patient = CDAFactory.eINSTANCE.createPatient();
    patientRole.setPatient(patient);
    PN name = DatatypesFactory.eINSTANCE.createPN();
    //*

//patient.getNames().add(name);//*//

    name.addGiven("Henry");
    name.addFamily("Levin");

    CE administrativeGenderCode = DatatypesFactory.eINSTANCE.createCE();

    patient.setAdministrativeGenderCode(administrativeGenderCode);
    administrativeGenderCode.setCode("M");
    administrativeGenderCode.setCodeSystem("2.16.840.1.113883.5.1");

    TS birthTime = DatatypesFactory.eINSTANCE.createTS();
    patient.setBirthTime(birthTime);
    birthTime.setValue("19320924");

    // create and initialize the CCD alerts section
    AlertsSection alertsSection = CCDFactory.eINSTANCE.createAlertsSection().init();
    ccdDocument.addSection(alertsSection);

    // set up the narrative (human-readable) text portion of the alerts section
    StringBuffer buffer = new StringBuffer();
    buffer.append("<table border=\"1\" width=\"100%\">");
    buffer.append("<thead>");
    buffer.append("<tr>");
    buffer.append("<th>Substance</th>");
    buffer.append("<th>Reaction</th>");
    buffer.append("<th>Status</th>");
    buffer.append("</tr>");
    buffer.append("</thead>");
    buffer.append("<tbody>");
    buffer.append("<tr>");
    buffer.append("<td>Penicillin</td>");
    buffer.append("<td>Hives</td>");
    buffer.append("<td>Active</td>");
    buffer.append("</tr>");
    buffer.append("</tbody>");
    buffer.append("</table>");
    alertsSection.createStrucDocText(buffer.toString());

    // create and initialize a CCD problem act
    ProblemAct problemAct = CCDFactory.eINSTANCE.createProblemAct().init();
    alertsSection.addAct(problemAct);

    id = DatatypesFactory.eINSTANCE.createII();
    //*

//problemAct.getIds().add(id);//*//

    id.setRoot(UUID.randomUUID().toString());

    // create and initialize an alert observation within the problem act
    AlertObservation alertObservation = CCDFactory.eINSTANCE.createAlertObservation().init();
    problemAct.addObservation(alertObservation);
    //*

//((EntryRelationship) alertObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.SUBJ);//*//

    id = DatatypesFactory.eINSTANCE.createII();
    //*

//alertObservation.getIds().add(id);//*//

    id.setRoot(UUID.randomUUID().toString());

    CD code = DatatypesFactory.eINSTANCE.createCD();
    alertObservation.setCode(code);
    code.setCode("ASSERTION");
    code.setCodeSystem("2.16.840.1.113883.5.4");

    CS statusCode = DatatypesFactory.eINSTANCE.createCS();
    alertObservation.setStatusCode(statusCode);
    statusCode.setCode("completed");

    CD value = DatatypesFactory.eINSTANCE.createCD();
    //*

//alertObservation.getValues().add(value);//*//

    value.setCode("282100009");
    value.setCodeSystem("2.16.840.1.113883.6.96");
    value.setDisplayName("Adverse reaction to substance");

    // playing entity contains coded information on the substance
    Participant2 participant = CDAFactory.eINSTANCE.createParticipant2();
    //*

//alertObservation.getParticipants().add(participant);//*//

    participant.setTypeCode(ParticipationType.CSM);

    ParticipantRole participantRole = CDAFactory.eINSTANCE.createParticipantRole();
    participant.setParticipantRole(participantRole);
    participantRole.setClassCode(RoleClassRoot.MANU);

    PlayingEntity playingEntity = CDAFactory.eINSTANCE.createPlayingEntity();
    participantRole.setPlayingEntity(playingEntity);
    playingEntity.setClassCode(EntityClassRoot.MMAT);
    CE playingEntityCode = DatatypesFactory.eINSTANCE.createCE();
    playingEntity.setCode(playingEntityCode);
    playingEntityCode.setCode("70618");
    playingEntityCode.setCodeSystem("2.16.840.1.113883.6.88");
    playingEntityCode.setDisplayName("Penicillin");

    // reaction observation contains coded information on the adverse reaction
    ReactionObservation reactionObservation = CCDFactory.eINSTANCE.createReactionObservation().init();
    alertObservation.addObservation(reactionObservation);
    //*

//((EntryRelationship) reactionObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.MFST);//*//

    //*

//((EntryRelationship) reactionObservation.eContainer()).setInversionInd(Boolean.TRUE);//*//

    code = DatatypesFactory.eINSTANCE.createCD();
    reactionObservation.setCode(code);
    code.setCode("ASSERTION");
    code.setCodeSystem("2.16.840.1.113883.5.4");

    statusCode = DatatypesFactory.eINSTANCE.createCS();
    reactionObservation.setStatusCode(statusCode);
    statusCode.setCode("completed");

    value = DatatypesFactory.eINSTANCE.createCD();
    //*

//reactionObservation.getValues().add(value);//*//

    value.setCode("247472004");
    value.setCodeSystem("2.16.840.1.113883.6.96");
    value.setDisplayName("Hives");

    // alert status contains information about whether allergy is currently active
    AlertStatusObservation alertStatusObservation = CCDFactory.eINSTANCE.createAlertStatusObservation().init();
    alertObservation.addObservation(alertStatusObservation);
    //*

//((EntryRelationship) alertStatusObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.REFR);//*//

    CE alertStatusObservationValue = DatatypesFactory.eINSTANCE.createCE();
    //*

//alertStatusObservation.getValues().add(alertStatusObservationValue);//*//

    alertStatusObservationValue.setCode("55561003");
    alertStatusObservationValue.setCodeSystem("2.16.840.1.113883.6.96");
    alertStatusObservationValue.setDisplayName("Active");

    // write the document out to the console
    try {

        /*File tempFile=File.createTempFile("sam",".xml",new File("C:/Development/JAVA/eclipse-jee-mars-R-win32-x86_64/workspace/MDHT/"));*//**//**/

        // tempFile.deleteOnExit();

        String dirPath = Environment.getExternalStorageDirectory() + File.separator + "myDirectory.xml";
        File projDir = new File(dirPath);
        OutputStream out = new BufferedOutputStream((new FileOutputStream(projDir)));
        CDAUtil.save(ccdDocument, out);
        out.flush();
        out.close();
        System.out.println("created..........");

        //CDAUtil.save(ccdDocument, System.out);

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        System.out.println(e.getMessage());
    }

}

}

dependencies in gradle.......................

compile files('libs/ipf-oht-mdht.jar') compile files('libs/ipf-oht-mdht-uml-hl7-vocab-1.2.0.201212201425.jar') compile files('libs/ipf-oht.jar') compile files('libs/ipf-oht-mdht-uml-hl7-datatypes-1.2.0.201212201425.jar') compile files('libs/org.openhealthtools.mdht.uml.hl7.rim.source_1.2.0.201302191803.jar') compile files('libs/ipf-oht-mdht-uml-hl7-rim-1.2.0.201212201425.jar')

compile files('libs/org.eclipse.emf.common_2.5.0.v200906151043.jar')
compile files('libs/org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar')
compile files('libs/org.eclipse.emf.ecore_2.5.0.v200906151043.jar')
compile files('libs/org.eclipse.ocl.ecore-3.5.0.v20150525-1635.jar')
compile files('libs/org.eclipse.ocl-3.5.0.v20150521-1211.jar')

I have already looked at user guide/developers guide. Any help is appreciated.

swmuir commented 7 years ago

That looks like a potential conflict with the ocl jars

Is this maven project - can you post the dependency tree ? or list the included jars ?

On Feb 11, 2017, at 1:23 AM, karthick229 notifications@github.com wrote:

Error.......after adding eclipse jar in my file............

Process: com.animedix.health_hive, PID: 15405 java.lang.NoClassDefFoundError: org.eclipse.ocl.AbstractTypeResolver$ResolveSwitch at org.eclipse.ocl.AbstractTypeResolver.(AbstractTypeResolver.java:66) at org.eclipse.ocl.ecore.internal.TypeResolverImpl.(TypeResolverImpl.java:56) at org.eclipse.ocl.ecore.EcoreEnvironment.createTypeResolver(EcoreEnvironment.java:310) at org.eclipse.ocl.ecore.EcoreEnvironment.(EcoreEnvironment.java:160) at org.eclipse.ocl.ecore.EcoreEnvironmentFactory.createEnvironment(EcoreEnvironmentFactory.java:107) at org.eclipse.ocl.OCL.(OCL.java:96) at org.eclipse.ocl.ecore.OCL.(OCL.java:84) at org.eclipse.ocl.ecore.OCL.newInstance(OCL.java:123) at org.openhealthtools.mdht.uml.cda.util.CDAUtil.(CDAUtil.java:1207) at org.openhealthtools.mdht.uml.cda.util.AnnotationBasedInitializer.initialize(AnnotationBasedInitializer.java:46) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:465) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:459) at org.openhealthtools.mdht.emf.runtime.util.Initializer$Util.init(Initializer.java:437) at org.openhealthtools.mdht.uml.cda.ccd.impl.ContinuityOfCareDocumentImpl.init(ContinuityOfCareDocumentImpl.java:544) at com.animedix.health_hive.Ccd.createccd(Ccd.java:48) at com.animedix.health_hive.access.MainActivity.onCreate(MainActivity.java:66) at android.app.Activity.performCreate(Activity.java:6543) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2513) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1475) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:207) at android.app.ActivityThread.main(ActivityThread.java:5740) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:766)

ccd.java

package com.animedix.health_hive;

import android.os.Environment; import android.support.v7.app.AppCompatActivity; import android.util.Log;

import org.openhealthtools.mdht.uml.cda.CDAFactory; import org.openhealthtools.mdht.uml.cda.Participant2; import org.openhealthtools.mdht.uml.cda.ParticipantRole; import org.openhealthtools.mdht.uml.cda.Patient; import org.openhealthtools.mdht.uml.cda.PatientRole; import org.openhealthtools.mdht.uml.cda.PlayingEntity; import org.openhealthtools.mdht.uml.cda.ccd.AlertObservation; import org.openhealthtools.mdht.uml.cda.ccd.AlertStatusObservation; import org.openhealthtools.mdht.uml.cda.ccd.AlertsSection; import org.openhealthtools.mdht.uml.cda.ccd.CCDFactory; import org.openhealthtools.mdht.uml.cda.ccd.ContinuityOfCareDocument; import org.openhealthtools.mdht.uml.cda.ccd.ProblemAct; import org.openhealthtools.mdht.uml.cda.ccd.ReactionObservation; import org.openhealthtools.mdht.uml.cda.util.CDAUtil; import org.openhealthtools.mdht.uml.hl7.datatypes.AD; import org.openhealthtools.mdht.uml.hl7.datatypes.CD; import org.openhealthtools.mdht.uml.hl7.datatypes.CE; import org.openhealthtools.mdht.uml.hl7.datatypes.CS; import org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory; import org.openhealthtools.mdht.uml.hl7.datatypes.II; import org.openhealthtools.mdht.uml.hl7.datatypes.PN; import org.openhealthtools.mdht.uml.hl7.datatypes.TS; import org.openhealthtools.mdht.uml.hl7.vocab.EntityClassRoot; import org.openhealthtools.mdht.uml.hl7.vocab.ParticipationType; import org.openhealthtools.mdht.uml.hl7.vocab.RoleClassRoot;

import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; import java.util.UUID;

public class Ccd extends AppCompatActivity{

public void createccd() {

// create and initialize an instance of the ContinuityOfCareDocument class
ContinuityOfCareDocument ccdDocument = CCDFactory.eINSTANCE.createContinuityOfCareDocument().init();
Log.e("ccd", "ccd"+ccdDocument);
// create a patient role object and add it to the document
PatientRole patientRole = CDAFactory.eINSTANCE.createPatientRole();
ccdDocument.addPatientRole(patientRole);
II id = DatatypesFactory.eINSTANCE.createII();

//* patientRole.getIds().add(id);//**//

id.setRoot("996-756-495");
id.setExtension("2.16.840.1.113883.19.5");

// create an address object and add it to patient role
AD addr = DatatypesFactory.eINSTANCE.createAD();
//*

//patientRole.getAddrs().add(addr);//*//

//*

//addr.getUses().add(PostalAddressUse.H);//*//

addr.addStreetAddressLine("1313 Mockingbird Lane");
addr.addCity("Janesville");
addr.addState("WI");
addr.addPostalCode("53545");

// create a patient object and add it to patient role
Patient patient = CDAFactory.eINSTANCE.createPatient();
patientRole.setPatient(patient);
PN name = DatatypesFactory.eINSTANCE.createPN();
//*

//patient.getNames().add(name);//*//

name.addGiven("Henry");
name.addFamily("Levin");

CE administrativeGenderCode = DatatypesFactory.eINSTANCE.createCE();

patient.setAdministrativeGenderCode(administrativeGenderCode);
administrativeGenderCode.setCode("M");
administrativeGenderCode.setCodeSystem("2.16.840.1.113883.5.1");

TS birthTime = DatatypesFactory.eINSTANCE.createTS();
patient.setBirthTime(birthTime);
birthTime.setValue("19320924");

// create and initialize the CCD alerts section
AlertsSection alertsSection = CCDFactory.eINSTANCE.createAlertsSection().init();
ccdDocument.addSection(alertsSection);

// set up the narrative (human-readable) text portion of the alerts section
StringBuffer buffer = new StringBuffer();
buffer.append("<table border=\"1\" width=\"100%\">");
buffer.append("<thead>");
buffer.append("<tr>");
buffer.append("<th>Substance</th>");
buffer.append("<th>Reaction</th>");
buffer.append("<th>Status</th>");
buffer.append("</tr>");
buffer.append("</thead>");
buffer.append("<tbody>");
buffer.append("<tr>");
buffer.append("<td>Penicillin</td>");
buffer.append("<td>Hives</td>");
buffer.append("<td>Active</td>");
buffer.append("</tr>");
buffer.append("</tbody>");
buffer.append("</table>");
alertsSection.createStrucDocText(buffer.toString());

// create and initialize a CCD problem act
ProblemAct problemAct = CCDFactory.eINSTANCE.createProblemAct().init();
alertsSection.addAct(problemAct);

id = DatatypesFactory.eINSTANCE.createII();
//*

//problemAct.getIds().add(id);//*//

id.setRoot(UUID.randomUUID().toString());

// create and initialize an alert observation within the problem act
AlertObservation alertObservation = CCDFactory.eINSTANCE.createAlertObservation().init();
problemAct.addObservation(alertObservation);
//*

//((EntryRelationship) alertObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.SUBJ);//*//

id = DatatypesFactory.eINSTANCE.createII();
//*

//alertObservation.getIds().add(id);//*//

id.setRoot(UUID.randomUUID().toString());

CD code = DatatypesFactory.eINSTANCE.createCD();
alertObservation.setCode(code);
code.setCode("ASSERTION");
code.setCodeSystem("2.16.840.1.113883.5.4");

CS statusCode = DatatypesFactory.eINSTANCE.createCS();
alertObservation.setStatusCode(statusCode);
statusCode.setCode("completed");

CD value = DatatypesFactory.eINSTANCE.createCD();
//*

//alertObservation.getValues().add(value);//*//

value.setCode("282100009");
value.setCodeSystem("2.16.840.1.113883.6.96");
value.setDisplayName("Adverse reaction to substance");

// playing entity contains coded information on the substance
Participant2 participant = CDAFactory.eINSTANCE.createParticipant2();
//*

//alertObservation.getParticipants().add(participant);//*//

participant.setTypeCode(ParticipationType.CSM);

ParticipantRole participantRole = CDAFactory.eINSTANCE.createParticipantRole();
participant.setParticipantRole(participantRole);
participantRole.setClassCode(RoleClassRoot.MANU);

PlayingEntity playingEntity = CDAFactory.eINSTANCE.createPlayingEntity();
participantRole.setPlayingEntity(playingEntity);
playingEntity.setClassCode(EntityClassRoot.MMAT);
CE playingEntityCode = DatatypesFactory.eINSTANCE.createCE();
playingEntity.setCode(playingEntityCode);
playingEntityCode.setCode("70618");
playingEntityCode.setCodeSystem("2.16.840.1.113883.6.88");
playingEntityCode.setDisplayName("Penicillin");

// reaction observation contains coded information on the adverse reaction
ReactionObservation reactionObservation = CCDFactory.eINSTANCE.createReactionObservation().init();
alertObservation.addObservation(reactionObservation);
//*

//((EntryRelationship) reactionObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.MFST);//*//

//*

//((EntryRelationship) reactionObservation.eContainer()).setInversionInd(Boolean.TRUE);//*//

code = DatatypesFactory.eINSTANCE.createCD();
reactionObservation.setCode(code);
code.setCode("ASSERTION");
code.setCodeSystem("2.16.840.1.113883.5.4");

statusCode = DatatypesFactory.eINSTANCE.createCS();
reactionObservation.setStatusCode(statusCode);
statusCode.setCode("completed");

value = DatatypesFactory.eINSTANCE.createCD();
//*

//reactionObservation.getValues().add(value);//*//

value.setCode("247472004");
value.setCodeSystem("2.16.840.1.113883.6.96");
value.setDisplayName("Hives");

// alert status contains information about whether allergy is currently active
AlertStatusObservation alertStatusObservation = CCDFactory.eINSTANCE.createAlertStatusObservation().init();
alertObservation.addObservation(alertStatusObservation);
//*

//((EntryRelationship) alertStatusObservation.eContainer()).setTypeCode(x_ActRelationshipEntryRelationship.REFR);//*//

CE alertStatusObservationValue = DatatypesFactory.eINSTANCE.createCE();
//*

//alertStatusObservation.getValues().add(alertStatusObservationValue);//*//

alertStatusObservationValue.setCode("55561003");
alertStatusObservationValue.setCodeSystem("2.16.840.1.113883.6.96");
alertStatusObservationValue.setDisplayName("Active");

// write the document out to the console
try {

    /*File tempFile=File.createTempFile("sam",".xml",new File("C:/Development/JAVA/eclipse-jee-mars-R-win32-x86_64/workspace/MDHT/"));*//**//**/

    // tempFile.deleteOnExit();

    String dirPath = Environment.getExternalStorageDirectory() + File.separator + "myDirectory.xml";
    File projDir = new File(dirPath);
    OutputStream out = new BufferedOutputStream((new FileOutputStream(projDir)));
    CDAUtil.save(ccdDocument, out);
    out.flush();
    out.close();
    System.out.println("created..........");

    //CDAUtil.save(ccdDocument, System.out);

} catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    System.out.println(e.getMessage());
}

} }

dependencies in gradle.......................

compile files('libs/ipf-oht-mdht.jar') compile files('libs/ipf-oht-mdht-uml-hl7-vocab-1.2.0.201212201425.jar') compile files('libs/ipf-oht.jar') compile files('libs/ipf-oht-mdht-uml-hl7-datatypes-1.2.0.201212201425.jar') compile files('libs/org.openhealthtools.mdht.uml.hl7.rim.source_1.2.0.201302191803.jar') compile files('libs/ipf-oht-mdht-uml-hl7-rim-1.2.0.201212201425.jar')

compile files('libs/org.eclipse.emf.common_2.5.0.v200906151043.jar') compile files('libs/org.eclipse.emf.ecore.xmi_2.5.0.v200906151043.jar') compile files('libs/org.eclipse.emf.ecore_2.5.0.v200906151043.jar') compile files('libs/org.eclipse.ocl.ecore-3.5.0.v20150525-1635.jar') compile files('libs/org.eclipse.ocl-3.5.0.v20150521-1211.jar') I have already looked at user guide/developers guide. Any help is appreciated.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mdht/mdht-models/issues/104#issuecomment-279125007, or mute the thread https://github.com/notifications/unsubscribe-auth/AFGeFwI3yP39ihN17aC95LC4RfsKWucWks5rbVPfgaJpZM4L3Ctq.

BlueWaveTechnology commented 7 years ago

Add these dependencies in Gradle File: // https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-uml-cda-ccd compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-uml-cda-ccd', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-emf-runtime compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-emf-runtime', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-uml-cda compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-uml-cda', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-uml-hl7-datatypes compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-uml-hl7-datatypes', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-uml-hl7-vocab compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-uml-hl7-vocab', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht-uml-cda-ihe compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht-uml-cda-ihe', version: '1.2.0.201212201425'

// https://mvnrepository.com/artifact/org.openehealth.ipf.oht.mdht/ipf-oht-mdht compile group: 'org.openehealth.ipf.oht.mdht', name: 'ipf-oht-mdht', version: '1.2.0.201212201425'