Changeset 2594

Show
Ignore:
Timestamp:
02/05/10 15:10:05 (2 years ago)
Author:
wouter
Message:

Last part of migration from exist to sql for healthdocuments.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • his-extensions/plugins/trunk/opinio/his-plugin/src/main/java/org/joiningtracks/his/plugin/integration/opinio/provider/QuestionnaireProvider.java

    r1888 r2594  
    11package org.joiningtracks.his.plugin.integration.opinio.provider; 
    22 
    3 import org.joiningtracks.his.data.model.HealthDocument; 
    43import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
     4import org.joiningtracks.his.data.model.HisHealthDocument; 
    55import org.joiningtracks.his.plugin.integration.opinio.data.model.Questionnaire; 
    66import org.joiningtracks.his.plugin.integration.opinio.data.model.Respondent; 
     
    2929     * @return the transformed questionnaire response 
    3030     */ 
    31     HealthDocument processQuestionnaireResponse(Respondent respondent, HealthDocument questionnaireResponse); 
     31    HisHealthDocument processQuestionnaireResponse(Respondent respondent, HisHealthDocument questionnaireResponse); 
    3232 
    3333    HealthDocumentMetaData getHealthDocumentMetaData(); 
  • his-extensions/plugins/trunk/opinio/his-plugin/src/main/java/org/joiningtracks/his/plugin/integration/opinio/rest/server/ResponsesResource.java

    r1877 r2594  
    33import org.apache.wicket.injection.web.InjectorHolder; 
    44import org.apache.wicket.spring.injection.annot.SpringBean; 
    5 import org.joiningtracks.his.data.model.HealthDocument; 
    65import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
     6import org.joiningtracks.his.data.model.HisHealthDocument; 
    77import org.joiningtracks.his.data.model.PathwayParticipation; 
    88import org.joiningtracks.his.plugin.integration.opinio.data.model.Respondent; 
    99import org.joiningtracks.his.plugin.integration.opinio.provider.QuestionnaireProvider; 
    1010import org.joiningtracks.his.plugin.integration.opinio.service.QuestionnaireIntegrationService; 
    11 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     11import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    1212import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    1313import org.joiningtracks.his.support.util.xml.XmlUtils; 
     
    1717import org.slf4j.Logger; 
    1818import org.slf4j.LoggerFactory; 
    19 import org.w3c.dom.Node
     19import org.w3c.dom.Document
    2020 
    2121/** 
     
    2626 
    2727    @SpringBean 
    28     private HealthRecordService healthRecordService; 
     28    private HealthDocumentService healthDocumentService; 
    2929 
    3030    @SpringBean 
     
    111111        } 
    112112 
    113         HealthDocument healthDocument = createHealthDocument(healthDocumentData, metaData); 
     113        HisHealthDocument healthDocument = createHealthDocument(healthDocumentData, metaData, pathwayParticipation); 
    114114        if(healthDocument == null) { 
    115115            respondent.setStatus(Respondent.Status.results_store_failed); 
     
    129129 
    130130        try { 
    131             String healthDocumentId = addHealthDocument(healthDocument, pathwayParticipation); 
    132             respondent.setHealthDocumentId(healthDocumentId); 
     131            HisHealthDocument savedHealthDocument = healthDocumentService.create(healthDocument); 
     132            respondent.setHealthDocumentId(Long.toString(savedHealthDocument.getId())); 
    133133        } catch (Exception e){ 
    134134            respondent.setStatus(Respondent.Status.results_store_failed); 
     
    157157    } 
    158158 
    159     private String addHealthDocument(HealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
    160         String id = healthRecordService.add(healthDocument, pathwayParticipation); 
    161         return id
    162     } 
     159    private HisHealthDocument createHealthDocument(String healthDocumentData, HealthDocumentMetaData metaData, PathwayParticipation pathwayParticipation) { 
     160        Document data = XmlUtils.loadDocument(healthDocumentData); 
     161        HisHealthDocument newHd = new HisHealthDocument(metaData.getVersion(), metaData.getType(), pathwayParticipation, data)
     162        newHd.setFormId(metaData.getFormId()); 
    163163 
    164     private HealthDocument createHealthDocument(String healthDocumentData, HealthDocumentMetaData metaData) { 
    165         Node data = XmlUtils.loadDocument(healthDocumentData); 
    166         return new HealthDocument(data, metaData); 
     164        return newHd; 
    167165    } 
    168166} 
  • his-extensions/plugins/trunk/opinio/his-plugin/src/main/resources/META-INF/spring/bundle-config.xml

    r2577 r2594  
    4848 
    4949    <osgi:reference id="pathwayParticipationService" interface="org.joiningtracks.his.service.pathway.PathwayParticipationService"/> 
    50     <osgi:reference id="healthRecordService" interface="org.joiningtracks.his.service.healthrecord.HealthRecordService"/> 
     50    <osgi:reference id="healthDocumentService" interface="org.joiningtracks.his.service.healthdocument.HealthDocumentService"/> 
    5151 
    5252    <osgi:reference id="eventChannel" interface="org.springframework.integration.core.MessageChannel"/> 
  • his-extensions/plugins/trunk/samples/pathway-plugin/src/main/java/org/joiningtracks/his/pathway/sample/TherapyPossibleDecision.java

    r1483 r2594  
    1818import org.jbpm.graph.exe.ExecutionContext; 
    1919import org.jbpm.graph.node.DecisionHandler; 
    20 import org.joiningtracks.his.data.model.HealthDocument; 
     20import org.joiningtracks.his.data.model.HisHealthDocument; 
    2121import org.joiningtracks.his.support.util.xml.XPathUtils; 
    2222import org.slf4j.Logger; 
     
    4646     */ 
    4747    public String decide(ExecutionContext executionContext) throws Exception { 
    48         HealthDocument document = (HealthDocument) executionContext.getVariable("healthDocument"); 
     48        HisHealthDocument document = (HisHealthDocument) executionContext.getVariable("healthDocument"); 
    4949        // Be sure that the decision is not taken when there is no proper information as the process continues 
    5050        // without the right base for it's decision, this puts unwanted risk in the real life process.  
     
    5252            throw new Exception("there is no healthDocument found in the executionContext"); 
    5353        } 
    54         if (document.getMetaData().getType().equalsIgnoreCase("intakeform")) { 
    55             Node contentNode = document.getData(); 
     54        if (document.getDocumentType().equalsIgnoreCase("intakeform")) { 
     55            Node contentNode = document.getHealthDocument(); 
    5656            String decision = XPathUtils.resolveString("/intakeform/therapyrequired/text()", contentNode); 
    5757            logger.debug("healthdocument intakeform contains a " + decision + " for grouptherapy"); 
  • his-extensions/plugins/trunk/samples/pathway-plugin/src/main/java/org/joiningtracks/his/pathway/sample/intakeform/IntakeFormPanel.java

    r1652 r2594  
    99import org.jbpm.taskmgmt.exe.PooledActor; 
    1010import org.jbpm.taskmgmt.exe.TaskInstance; 
    11 import org.joiningtracks.his.data.model.HealthDocument; 
    12 import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
    13 import org.joiningtracks.his.data.model.PathwayParticipation; 
    14 import org.joiningtracks.his.data.model.Patient; 
     11import org.joiningtracks.his.data.model.*; 
    1512import org.joiningtracks.his.frontend.common.wicket.form.FormWithAssociatedMarkup; 
    1613import org.joiningtracks.his.frontend.common.wicket.form.dom.DocumentSubmissionHandler; 
    1714import org.joiningtracks.his.frontend.common.wicket.taskpanel.AbstractTaskPanel; 
    18 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     15import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    1916import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    2017import org.joiningtracks.his.service.process.TaskService; 
     
    2825    private PathwayParticipationService pathwayParticipationService; 
    2926    @SpringBean 
    30     private HealthRecordService healthRecordService; 
     27    private HealthDocumentService healthDocumentService; 
    3128    @SpringBean 
    3229    private TaskService taskService; 
     
    5653        intakeForm = intakeFormFactory.createForm("intake_form", new DocumentSubmissionHandler() { 
    5754            public void handle(FormWithAssociatedMarkup form, Document document) { 
    58                 HealthDocumentMetaData metaData = new HealthDocumentMetaData(IntakeFormFactory.FORM_NAME, IntakeFormFactory.FORM_VERSION); 
    59                 final HealthDocument healthDocument = new HealthDocument(document, metaData); 
    6055                final PathwayParticipation pp = pathwayParticipationService.findPathwayParticipationByProcessInstance(taskInstance.getProcessInstance().getId()); 
     56                final HisHealthDocument healthDocument = new HisHealthDocument(IntakeFormFactory.FORM_VERSION, 
     57                        IntakeFormFactory.FORM_NAME, pp, document); 
    6158 
    6259                transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    6360                    public Object execute() { 
    6461                        taskService.setVariable(taskInstance, "healthDocument", healthDocument); 
    65                         healthRecordService.add(healthDocument, pp); 
     62                        healthDocumentService.create(healthDocument); 
    6663                        taskService.markTaskAsCompleted(taskInstance); 
    6764                        return null; 
  • his-extensions/plugins/trunk/samples/pathway-plugin/src/main/resources/META-INF/spring/bundle-config.xml

    r1652 r2594  
    4949                    interface="org.joiningtracks.his.service.pathway.PathwayParticipationService"/> 
    5050 
    51     <osgi:reference id="healthRecordService" 
    52                     interface="org.joiningtracks.his.service.healthrecord.HealthRecordService"/> 
     51    <osgi:reference id="healthDocumentService" 
     52                    interface="org.joiningtracks.his.service.healthdocument.HealthDocumentService"/> 
    5353 
    5454    <osgi:reference id="transactionTemplate" interface="org.joiningtracks.his.service.transaction.TransactionTemplate"/> 
  • his-extensions/plugins/trunk/samples/pathway-plugin/src/test/java/org/joiningtracks/his/pathway/sample/JpdlSamplePathwayTest.java

    r2593 r2594  
    2222import org.jbpm.taskmgmt.exe.TaskInstance; 
    2323import org.joda.time.DateTime; 
    24 import org.joiningtracks.his.data.model.HealthDocument; 
    2524import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
    26 import org.joiningtracks.his.data.model.Patient; 
     25import org.joiningtracks.his.data.model.HisHealthDocument; 
    2726import org.joiningtracks.his.data.util.jbpm.JbpmTemplate; 
    28 import org.joiningtracks.his.support.util.event.EventListener; 
    2927import org.slf4j.Logger; 
    3028import org.slf4j.LoggerFactory; 
     
    115113        } 
    116114        HealthDocumentMetaData metaData = new HealthDocumentMetaData("intakeform", "1.0", "formId"); 
    117         HealthDocument newDoc = new HealthDocument("testid", new DateTime(), doc.getDocumentElement(), metaData); 
     115        HisHealthDocument newDoc = new HisHealthDocument(1L); 
     116        newDoc.setDocumentType(metaData.getType()); 
     117        newDoc.setDocumentVersion(metaData.getVersion()); 
     118        newDoc.setFormId(metaData.getFormId()); 
     119        newDoc.setHealthDocument(doc); 
     120        newDoc.setCreated(new DateTime()); 
    118121 
    119122        processInstance.getContextInstance().setVariable("healthDocument", newDoc); 
  • his-extensions/plugins/trunk/treatment/importer/src/main/resources/META-INF/spring/bundle-config.xml

    r2326 r2594  
    5757    <osgi:reference id="pathwayPluginService" interface="org.joiningtracks.his.plugin.bridge.pathway.PathwayPluginService"/> 
    5858     
    59     <osgi:reference id="healthRecordService" 
    60                     interface="org.joiningtracks.his.service.healthrecord.HealthRecordService"/> 
     59    <osgi:reference id="healthDocumentService" 
     60                    interface="org.joiningtracks.his.service.healthdocument.HealthDocumentService"/> 
    6161 
    6262    <osgi:reference id="clinicalPathwayService" 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/PatientAppointmentSignOffPanel.java

    r2507 r2594  
    3737import org.joiningtracks.his.pathway.nok.treatment.data.model.PatientGroupDocument; 
    3838import org.joiningtracks.his.service.appointment.AppointmentService; 
    39 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     39import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    4040import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    4141import org.joiningtracks.his.service.patientgroup.PatientGroupService; 
     
    5353    private AppointmentService appointmentService; 
    5454    @SpringBean 
    55     private HealthRecordService healthRecordService; 
     55    private HealthDocumentService healthDocumentService; 
    5656    @SpringBean 
    5757    private PathwayParticipationService pathwayParticipationService; 
     
    8484        if (!patientGroups.isEmpty()) { 
    8585            patientGroup = patientGroups.iterator().next(); 
    86         } 
    87  
    88         // for existing groups if the repository is not present create one 
    89         // we cannot create the repository in the his-core module as this requirement is only 
    90         // for treatment group. In that case, core would need the knowledge of all the supported groups 
    91         if (patientGroup.getUniqueIdentifier() == null) { 
    92             healthRecordService.createRepository(patientGroup); 
    93             patientGroup = patientGroupService.update(patientGroup); 
    9486        } 
    9587 
     
    271263     */ 
    272264    private void derivePatientGroupDocument() { 
    273         List<HealthDocumentInfo> groupHealthDocuments = healthRecordService.getAllHealthRecordInfo(patientGroup); 
     265        List<HisHealthDocument> groupHealthDocuments = healthDocumentService.findByPatientGroup(patientGroup); 
    274266        if (groupHealthDocuments.size() == 0) { 
    275267            patientGroupDocument = new PatientGroupDocument(); 
    276268        } else { 
    277269            // Retrieve from XML 
    278             for (HealthDocumentInfo healthDocumentInfo : groupHealthDocuments) { 
    279                 HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), patientGroup); 
    280                 patientGroupDocument = PatientGroupDocument.fromXML(XmlUtils.getAsString(healthDocument.getData())); 
     270            for (HisHealthDocument healthDocument : groupHealthDocuments) { 
     271                patientGroupDocument = PatientGroupDocument.fromXML(XmlUtils.getAsString(healthDocument.getHealthDocument())); 
    281272            } 
    282273        } 
     
    295286            Patient patient = (Patient) attendeeReference.getAttendee(); 
    296287            PatientDetail patientDetail = new PatientDetail(patient, patientGroup); 
    297             List<HealthDocumentInfo> healthdocuments = healthRecordService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), metaData.getFormId()); 
     288            List<HisHealthDocument> healthdocuments = healthDocumentService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), metaData.getFormId()); 
    298289 
    299290            if (healthdocuments.size() == 0) { 
     
    302293            } else { 
    303294                // Retrieve from XML 
    304                 for (HealthDocumentInfo healthDocumentInfo : healthdocuments) { 
    305                     HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), patientDetail.getPathwayParticipation()); 
    306                     patientDocument = PatientDocument.fromXML(XmlUtils.getAsString(healthDocument.getData())); 
     295                for (HisHealthDocument healthDocument : healthdocuments) { 
     296                    patientDocument = PatientDocument.fromXML(XmlUtils.getAsString(healthDocument.getHealthDocument())); 
    307297                } 
    308298            } 
     
    394384    private void saveOrUpdatePatientGroupDocument() { 
    395385        Document document = XmlUtils.loadDocument(patientGroupDocument.toXML()); 
    396         HealthDocumentMetaData metaData = new HealthDocumentMetaData(PatientHealthDocumentFormFactory.FORM_NAME, PatientHealthDocumentFormFactory.FORM_VERSION); 
    397  
    398         List<HealthDocumentInfo> healthdocuments = healthRecordService.getAllHealthRecordInfo(patientGroup); 
     386 
     387        List<HisHealthDocument> healthdocuments = healthDocumentService.findByPatientGroup(patientGroup); 
    399388        if (healthdocuments.size() == 0) { 
    400389            // Create new 
    401             final HealthDocument healthDocument = new HealthDocument(document, metaData); 
    402             healthRecordService.add(healthDocument, patientGroup); 
     390            final HisHealthDocument healthDocument = new HisHealthDocument(PatientHealthDocumentFormFactory.FORM_VERSION, 
     391                    PatientHealthDocumentFormFactory.FORM_NAME, patientGroup, document); 
     392 
     393            healthDocumentService.create(healthDocument); 
    403394 
    404395        } else { 
    405396            // Update existing 
    406             for (HealthDocumentInfo healthDocumentInfo : healthdocuments) { 
    407                 HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), patientGroup); 
     397            for (HisHealthDocument healthDocument : healthdocuments) { 
    408398                if (healthDocument != null) { 
    409                     healthDocument.setData(document.getDocumentElement()); 
    410                     healthRecordService.update(healthDocument, patientGroup); 
     399                    healthDocument.setHealthDocument(document); 
     400                    healthDocumentService.update(healthDocument); 
    411401                } 
    412402            } 
     
    462452    private void updatePatientDocument(PatientDocument patientDocument, PathwayParticipation pathwayParticipation) { 
    463453        Document document = XmlUtils.loadDocument(patientDocument.toXML()); 
    464         HealthDocumentMetaData metaData = new HealthDocumentMetaData(PatientHealthDocumentFormFactory.FORM_NAME, PatientHealthDocumentFormFactory.FORM_VERSION); 
    465  
    466         List<HealthDocumentInfo> healthdocuments = healthRecordService.getAllHealthRecordInfo(pathwayParticipation, metaData.getFormId()); 
     454 
     455        List<HisHealthDocument> healthdocuments = healthDocumentService.getAllHealthRecordInfo(pathwayParticipation, 
     456                PatientHealthDocumentFormFactory.FORM_NAME + "_" + PatientHealthDocumentFormFactory.FORM_VERSION); 
    467457        if (healthdocuments.size() == 0) { 
    468458            // Create new 
    469             final HealthDocument healthDocument = new HealthDocument(document, metaData); 
    470             healthRecordService.add(healthDocument, pathwayParticipation); 
     459            final HisHealthDocument healthDocument = new HisHealthDocument(PatientHealthDocumentFormFactory.FORM_VERSION, 
     460                    PatientHealthDocumentFormFactory.FORM_NAME, pathwayParticipation, document); 
     461            healthDocumentService.create(healthDocument); 
    471462        } else { 
    472463            // Update existing 
    473             for (HealthDocumentInfo healthDocumentInfo : healthdocuments) { 
    474                 HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), pathwayParticipation); 
     464            for (HisHealthDocument healthDocument : healthdocuments) { 
    475465                if (healthDocument != null) { 
    476                     healthDocument.setData(document.getDocumentElement()); 
    477                     healthRecordService.update(healthDocument, pathwayParticipation); 
     466                    healthDocument.setHealthDocument(document); 
     467                    healthDocumentService.update(healthDocument); 
    478468                } 
    479469            } 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/PatientSignOffPanel.java

    r2507 r2594  
    2424import org.joiningtracks.his.pathway.nok.treatment.data.model.PatientDocument; 
    2525import org.joiningtracks.his.service.appointment.AppointmentService; 
    26 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     26import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    2727import org.joiningtracks.his.service.ldap.LdapEmployeeService; 
    2828import org.joiningtracks.his.support.util.xml.XmlUtils; 
     
    4545    protected LdapEmployeeService ldapEmployeeService; 
    4646    @SpringBean 
    47     protected HealthRecordService healthRecordService; 
     47    protected HealthDocumentService healthDocumentService; 
    4848    @SpringBean 
    4949    protected AppointmentService appointmentService; 
     
    7474        PatientDocument patientDocument = patientDetail.getPatientDocument(); 
    7575        Document document = XmlUtils.loadDocument(patientDocument.toXML()); 
    76         HealthDocumentMetaData metaData = new HealthDocumentMetaData(PatientHealthDocumentFormFactory.FORM_NAME, PatientHealthDocumentFormFactory.FORM_VERSION); 
    77         List<HealthDocumentInfo> healthdocuments = healthRecordService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), metaData.getFormId()); 
     76        List<HisHealthDocument> healthdocuments = healthDocumentService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), 
     77                PatientHealthDocumentFormFactory.FORM_NAME + "_" + PatientHealthDocumentFormFactory.FORM_VERSION); 
    7878        if (healthdocuments.size() == 0) { 
    7979            // Create new 
    80             final HealthDocument healthDocument = new HealthDocument(document, metaData); 
    81             healthRecordService.add(healthDocument, patientDetail.getPathwayParticipation()); 
     80            final HisHealthDocument healthDocument = new HisHealthDocument(PatientHealthDocumentFormFactory.FORM_VERSION, 
     81                    PatientHealthDocumentFormFactory.FORM_NAME, patientDetail.getPathwayParticipation(), document); 
     82            healthDocumentService.create(healthDocument); 
    8283        } else { 
    8384            // Update existing 
    84             for (HealthDocumentInfo healthDocumentInfo : healthdocuments) { 
    85                 HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), patientDetail.getPathwayParticipation()); 
     85            for (HisHealthDocument healthDocument : healthdocuments) { 
    8686                if (healthDocument != null) { 
    87                     healthDocument.setData(document.getDocumentElement()); 
    88                     healthRecordService.update(healthDocument, patientDetail.getPathwayParticipation()); 
     87                    healthDocument.setHealthDocument(document); 
     88                    healthDocumentService.update(healthDocument); 
    8989                } 
    9090            } 
     
    9797     */ 
    9898    protected PatientDetail getUpdatedPatientDocument(PatientDetail patientDetail) { 
    99         HealthDocumentMetaData metaData = new HealthDocumentMetaData(PatientHealthDocumentFormFactory.FORM_NAME, PatientHealthDocumentFormFactory.FORM_VERSION); 
    100         List<HealthDocumentInfo> healthdocuments = healthRecordService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), metaData.getFormId()); 
     99        List<HisHealthDocument> healthdocuments = healthDocumentService.getAllHealthRecordInfo(patientDetail.getPathwayParticipation(), 
     100                PatientHealthDocumentFormFactory.FORM_NAME + "_" + PatientHealthDocumentFormFactory.FORM_VERSION); 
    101101        // Get updated document 
    102         for (HealthDocumentInfo healthDocumentInfo : healthdocuments) { 
    103             HealthDocument healthDocument = healthRecordService.get(healthDocumentInfo.getId(), patientDetail.getPathwayParticipation()); 
     102        for (HisHealthDocument healthDocument : healthdocuments) { 
    104103            if (healthDocument != null) { 
    105                 PatientDocument existingDocument = PatientDocument.fromXML(XmlUtils.getAsString(healthDocument.getData())); 
     104                PatientDocument existingDocument = PatientDocument.fromXML(XmlUtils.getAsString(healthDocument.getHealthDocument())); 
    106105                patientDetail.setPatientDocument(existingDocument); 
    107106            } 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/form/TreatmentFormDetailsPanel.java

    r2507 r2594  
    2121import org.apache.wicket.markup.html.panel.Panel; 
    2222import org.apache.wicket.spring.injection.annot.SpringBean; 
    23 import org.joiningtracks.his.data.model.HealthDocument; 
    24 import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
     23import org.joiningtracks.his.data.model.HisHealthDocument; 
    2524import org.joiningtracks.his.data.model.PathwayParticipation; 
    2625import org.joiningtracks.his.frontend.common.wicket.form.FormWithAssociatedMarkup; 
     
    3029import org.joiningtracks.his.plugin.form.FormFactory; 
    3130import org.joiningtracks.his.plugin.form.FormManager; 
    32 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     31import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    3332import org.joiningtracks.his.service.transaction.TransactionCallback; 
    3433import org.joiningtracks.his.service.transaction.TransactionTemplate; 
     
    5150    private PathwayPluginService pathwayPluginService; 
    5251    @SpringBean 
    53     private HealthRecordService healthRecordService; 
     52    private HealthDocumentService healthDocumentService; 
    5453    @SpringBean 
    5554    private TransactionTemplate transactionTemplate; 
     
    5756    private FormManager formManager; 
    5857 
    59     private HealthDocument healthDocument; 
    60     private String documentId; 
     58    private HisHealthDocument healthDocument; 
     59    private Long documentId; 
    6160 
    6261    /** 
     
    6867     * @param documentId             document id 
    6968     */ 
    70     public TreatmentFormDetailsPanel(String id, FormConfig formConfig, PathwayParticipation pathwayParticipation, String documentId) { 
     69    public TreatmentFormDetailsPanel(String id, FormConfig formConfig, PathwayParticipation pathwayParticipation, Long documentId) { 
    7170        super(id); 
    7271        setOutputMarkupId(true); 
     
    8584        // get the healthDocument (if it already exists) 
    8685        if (documentId != null) { 
    87             healthDocument = healthRecordService.get(documentId, pathwayParticipation); 
     86            healthDocument = healthDocumentService.getById(documentId); 
    8887        } 
    8988        addForm(formConfig, pathwayParticipation); 
     
    9392        final FormFactory factory = pathwayPluginService.getFormFactoryForProvidedForm(formConfig.getType(), formConfig.getVersion()); 
    9493        Form foundForm; 
    95         if (healthDocument != null && healthDocument.getData() != null) { 
    96             foundForm = factory.createForm("theProvidedForm", XmlUtils.resolveDocument(healthDocument.getData()), new DocumentSubmissionHandler() { 
     94        if (healthDocument != null && healthDocument.getHealthDocument() != null) { 
     95            foundForm = factory.createForm("theProvidedForm", XmlUtils.resolveDocument(healthDocument.getHealthDocument()), new DocumentSubmissionHandler() { 
    9796                public void handle(FormWithAssociatedMarkup form, Document document) { 
    98                     healthDocument.setData(document.getDocumentElement()); 
     97                    healthDocument.setHealthDocument(document); 
    9998 
    10099                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    101100                        public Object execute() { 
    102                             healthRecordService.update(healthDocument, pathwayParticipation); 
     101                            healthDocumentService.update(healthDocument); 
    103102                            return null; 
    104103                        } 
     
    110109            foundForm = factory.createForm("theProvidedForm", new DocumentSubmissionHandler() { 
    111110                public void handle(FormWithAssociatedMarkup form, Document document) { 
    112                     HealthDocumentMetaData metaData = new HealthDocumentMetaData(formConfig.getType(), formConfig.getVersion()); 
    113                     final HealthDocument healthDocument = new HealthDocument(formConfig.getIdentifier(), new DateTime(), document, metaData); 
     111                    final HisHealthDocument healthDocument = new HisHealthDocument(formConfig.getVersion(), 
     112                            formConfig.getType(), pathwayParticipation, document); 
     113                    healthDocument.setFormId(formConfig.getIdentifier()); 
    114114                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    115115                        public Object execute() { 
    116                             documentId = healthRecordService.add(healthDocument, pathwayParticipation); 
     116                            documentId = healthDocumentService.create(healthDocument).getId(); 
    117117                            return null; 
    118118                        } 
     
    144144 
    145145 
    146     abstract void handleSave(String healthRecordId); 
     146    abstract void handleSave(Long healthRecordId); 
    147147 
    148148    abstract void handleCancel(AjaxRequestTarget target); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/form/TreatmentFormPanel.java

    r2507 r2594  
    127127                            theFormConfig, patientDetail.getPathwayParticipation(), formDocument.getDocumentId()) { 
    128128 
    129                         void handleSave(String healthRecordId) { 
     129                        void handleSave(Long healthRecordId) { 
    130130                            saveForm(healthRecordId, theFormConfig); 
    131131 
     
    162162        } 
    163163 
    164         private void saveForm(String healthRecordId, FormConfig theFormConfig) { 
     164        private void saveForm(Long healthRecordId, FormConfig theFormConfig) { 
    165165            getUpdatedPatientDocument(patientDetail); 
    166166            formDocument = patientDetail.getPatientDocument().getAppointmentByIdentifier(appointment.getAppointmentNumber()) 
     
    171171        } 
    172172 
    173         private FormDocument createOrRetrieveFormDocument(String documentId) { 
     173        private FormDocument createOrRetrieveFormDocument(String formId) { 
    174174            AppointmentDocument appointmentDocument = patientDetail.getPatientDocument().getAppointmentByIdentifier(appointment.getAppointmentNumber()); 
    175175            if (appointmentDocument == null) { 
     
    177177                patientDetail.getPatientDocument().addAppointment(appointmentDocument); 
    178178            } 
    179             FormDocument formDocument = appointmentDocument.getFormByDocumentId(documentId); 
     179            FormDocument formDocument = appointmentDocument.getFormByDocumentId(formId); 
    180180            if (formDocument == null) { 
    181                 formDocument = new FormDocument(documentId); 
     181                formDocument = new FormDocument(formId); 
    182182                appointmentDocument.addForm(formDocument); 
    183183                updatePatientDocument(patientDetail); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/questionnaire/DisplayQuestionnairePanel.java

    r2581 r2594  
    2424import org.apache.wicket.markup.html.panel.Panel; 
    2525import org.apache.wicket.spring.injection.annot.SpringBean; 
    26 import org.joiningtracks.his.data.model.HealthDocument; 
    27 import org.joiningtracks.his.data.model.HealthDocumentInfo; 
     26import org.joiningtracks.his.data.model.HisHealthDocument; 
    2827import org.joiningtracks.his.data.model.PathwayParticipation; 
    29 import org.joiningtracks.his.frontend.employee.patient.dossier.form.FormPanel; 
    3028import org.joiningtracks.his.frontend.employee.patient.dossier.form.StaticXmlFormPanel; 
    3129import org.joiningtracks.his.plugin.form.FormDescriptor; 
    3230import org.joiningtracks.his.plugin.form.FormManager; 
    33 import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    34 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    35 import org.w3c.dom.Document; 
    3631 
    3732/** 
     
    4540    FormManager formManager; 
    4641 
    47     public DisplayQuestionnairePanel(String id, HealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
     42    public DisplayQuestionnairePanel(String id, HisHealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
    4843        super(id); 
    4944        initUI(healthDocument, pathwayParticipation); 
     
    5146    } 
    5247 
    53     private void initUI(HealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
     48    private void initUI(HisHealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
    5449 
    5550        addFormPanel(healthDocument, pathwayParticipation); 
     
    6459    } 
    6560 
    66     public final void addFormPanel(HealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
     61    public final void addFormPanel(HisHealthDocument healthDocument, PathwayParticipation pathwayParticipation) { 
    6762 
    68         StaticXmlFormPanel formPanel = new StaticXmlFormPanel("questionnaire", healthDocument.getData()); 
     63        StaticXmlFormPanel formPanel = new StaticXmlFormPanel("questionnaire", healthDocument.getHealthDocument()); 
    6964        add(formPanel); 
    7065 
    71         FormDescriptor formDescriptor = formManager.getFormDescriptor(healthDocument.getMetaData()); 
     66        FormDescriptor formDescriptor = formManager.getFormDescriptor(healthDocument); 
    7267        // we couldn't find the appropriate form that can edit the document, so we just show the xml document. 
    7368        if (formDescriptor == null) { 
     
    7671            formPanel.setVisible(false); 
    7772 
    78             Form form = formDescriptor.getFormFactory().createForm("questionnaireform", (Document) healthDocument.getData(), null, pathwayParticipation.getPatient(), pathwayParticipation); 
     73            Form form = formDescriptor.getFormFactory().createForm("questionnaireform", healthDocument.getHealthDocument(), null, pathwayParticipation.getPatient(), pathwayParticipation); 
    7974            add(form); 
    8075            disableFormElements(form); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/appointment/signoff/questionnaire/QuestionnairePanel.java

    r2581 r2594  
    3131import org.apache.wicket.spring.injection.annot.SpringBean; 
    3232import org.joiningtracks.his.data.model.Appointment; 
    33 import org.joiningtracks.his.data.model.HealthDocument; 
     33import org.joiningtracks.his.data.model.HisHealthDocument; 
    3434import org.joiningtracks.his.pathway.nok.treatment.appointment.signoff.PatientSignOffPanel; 
    3535import org.joiningtracks.his.pathway.nok.treatment.config.AppointmentConfig; 
     
    9696        private QuestionnaireIntegrationService questionnaireIntegrationService; 
    9797 
    98         private HealthDocument healthDocument; 
     98        private HisHealthDocument healthDocument; 
    9999        private QuestionnaireDocument questionnaireDocument; 
    100100        private FeedbackPanel feedbackPanel; 
     
    156156                String healthDocumentId = respondent.getHealthDocumentId(); 
    157157                if (healthDocumentId != null) { 
    158                     healthDocument = healthRecordService.get(healthDocumentId, patientDetail.getPathwayParticipation()); 
     158                    healthDocument = healthDocumentService.getById(new Long(healthDocumentId)); 
    159159                    if (healthDocument != null) { 
    160160                        isAnsweredField.setModel(new Model<Boolean>(true)); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/bloodvalues/BloodValueFormPanel.java

    r2586 r2594  
    55import org.apache.wicket.spring.injection.annot.SpringBean; 
    66import org.jbpm.taskmgmt.exe.TaskInstance; 
    7 import org.joiningtracks.his.data.model.HealthDocument; 
    8 import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
    9 import org.joiningtracks.his.data.model.PathwayParticipation; 
    10 import org.joiningtracks.his.data.model.Patient; 
     7import org.joiningtracks.his.data.model.*; 
    118import org.joiningtracks.his.frontend.common.wicket.form.FormWithAssociatedMarkup; 
    129import org.joiningtracks.his.frontend.common.wicket.form.dom.DocumentSubmissionHandler; 
    1310import org.joiningtracks.his.frontend.common.wicket.taskpanel.AbstractTaskPanel; 
    14 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     11import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    1512import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    1613import org.joiningtracks.his.service.process.TaskService; 
     
    2421    private PathwayParticipationService pathwayParticipationService; 
    2522    @SpringBean 
    26     private HealthRecordService healthRecordService; 
     23    private HealthDocumentService healthDocumentService; 
    2724    @SpringBean 
    2825    private TaskService taskService; 
     
    3330 
    3431    private final BloodValueForm bloodValueForm; 
    35     private HealthDocument healthDocument; 
     32    private HisHealthDocument healthDocument; 
    3633 
    3734    /** 
     
    8178        bloodValueForm = (BloodValueForm) bloodValueFormFactory.createForm("blood_value_form", new DocumentSubmissionHandler() { 
    8279            public void handle(FormWithAssociatedMarkup form, Document document) { 
    83                 HealthDocumentMetaData metaData = new HealthDocumentMetaData(BloodValueFormFactory.FORM_NAME, BloodValueFormFactory.FORM_VERSION); 
    84                 final HealthDocument healthDocument = new HealthDocument(document, metaData); 
     80                final HisHealthDocument healthDocument = new HisHealthDocument(BloodValueFormFactory.FORM_VERSION, 
     81                        BloodValueFormFactory.FORM_NAME, pathwayParticipation, document); 
    8582 
    8683                transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    8784                    public Object execute() { 
    88                         String recordId = healthRecordService.add(healthDocument, pathwayParticipation); 
    89                         taskService.setVariable(taskInstance, "BloodValue_recordId", recordId); 
     85                        HisHealthDocument savedDocument = healthDocumentService.create(healthDocument); 
     86                        taskService.setVariable(taskInstance, "BloodValue_recordId", savedDocument.getId()); 
    9087 
    9188                        return null; 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/data/model/AppointmentDocument.java

    r2507 r2594  
    8787        FormDocument formDocument = null; 
    8888        for (FormDocument form : forms) { 
    89             if (form.getDocumentId().equals(identifier)) { 
     89            if (form.getFormId().equals(identifier)) { 
    9090                formDocument = form; 
    9191                break; 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/data/model/FormDocument.java

    r2507 r2594  
    2525public class FormDocument implements Serializable { 
    2626 
    27     private String documentId; 
     27    private Long documentId; 
     28    private String formId; 
    2829    private boolean filled; 
    2930 
    30     public FormDocument(String documentId, boolean filled) { 
     31    public FormDocument(Long documentId, boolean filled) { 
    3132        this.documentId = documentId; 
    3233        this.filled = filled; 
     
    3637    } 
    3738 
    38     public FormDocument(String documentId) { 
     39    public FormDocument(String formId) { 
     40        this.formId = formId; 
     41    } 
     42 
     43    public Long getDocumentId() { 
     44        return documentId; 
     45    } 
     46 
     47    public void setDocumentId(Long documentId) { 
    3948        this.documentId = documentId; 
    4049    } 
    4150 
    42     public String getDocumentId() { 
    43         return documentId; 
     51    public String getFormId() { 
     52        return formId; 
    4453    } 
    4554 
    46     public void setDocumentId(String documentId) { 
    47         this.documentId = documentId; 
     55    public void setFormId(String formId) { 
     56        this.formId = formId; 
    4857    } 
    4958 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/frontend/TreatmentGroupOverviewPanel.java

    r2507 r2594  
    3838import org.joiningtracks.his.pathway.nok.treatment.data.model.TreatmentTrajectData; 
    3939import org.joiningtracks.his.service.appointment.AppointmentService; 
    40 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    4140import org.joiningtracks.his.service.pathway.ClinicalPathwayService; 
    4241import org.joiningtracks.his.service.patientgroup.PatientGroupService; 
     
    5756    @SpringBean 
    5857    private AppointmentService appointmentService; 
    59  
    60     @SpringBean 
    61     private HealthRecordService healthRecordService; 
    62  
    6358 
    6459    private ProcessDefinition pathway; 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/surgical/OperatiePlanningFormPanel.java

    r2507 r2594  
    2020import org.apache.wicket.spring.injection.annot.SpringBean; 
    2121import org.jbpm.taskmgmt.exe.TaskInstance; 
    22 import org.joiningtracks.his.data.model.HealthDocument; 
    23 import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
     22import org.joiningtracks.his.data.model.HisHealthDocument; 
    2423import org.joiningtracks.his.data.model.PathwayParticipation; 
    2524import org.joiningtracks.his.data.model.Patient; 
     
    2726import org.joiningtracks.his.frontend.common.wicket.form.dom.DocumentSubmissionHandler; 
    2827import org.joiningtracks.his.frontend.common.wicket.taskpanel.AbstractTaskPanel; 
    29 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     28import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    3029import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    3130import org.joiningtracks.his.service.process.TaskService; 
     
    3534import org.w3c.dom.Document; 
    3635 
     36import java.util.List; 
    3737import java.util.Map; 
    3838 
     
    4747    private PathwayParticipationService pathwayParticipationService; 
    4848    @SpringBean 
    49     private HealthRecordService healthRecordService; 
     49    private HealthDocumentService healthDocumentService; 
    5050    @SpringBean 
    5151    private TaskService taskService; 
     
    5656 
    5757    private final OperatiePlanningForm operatiePlanningForm; 
    58     private HealthDocument healthDocument; 
     58    private HisHealthDocument healthDocument; 
    5959 
    6060    /** 
     
    102102        Patient patient = pathwayParticipation.getPatient(); 
    103103 
    104         String operatiePlanningRecordId = (String) taskService.getVariable(taskInstance, "OperatiePlanning_recordId"); 
     104        Long operatiePlanningRecordId = (Long) taskService.getVariable(taskInstance, "OperatiePlanning_recordId"); 
    105105        // get the healthDocument (if it already exists)  "operatie planning_1.0.0" 
    106106        if (operatiePlanningRecordId != null) { 
    107             healthDocument = healthRecordService.get(operatiePlanningRecordId, pathwayParticipation); 
     107            healthDocument = healthDocumentService.getById(operatiePlanningRecordId); 
    108108        } 
    109109        //if the healthDocument could not be collected the via the variable, scan for the healthDocument. There should only be one per participation. 
    110110        if (healthDocument == null) { 
    111             Map<String, HealthDocument> allDocs = healthRecordService.getAllDocuments(pathwayParticipation); 
    112             for (Map.Entry<String, HealthDocument> entry : allDocs.entrySet()) { 
    113                 if (entry.getValue().getMetaData().getFormId().equals(OperatiePlanningFormFactory.FORM_NAME + "_" + OperatiePlanningFormFactory.FORM_VERSION)) { 
    114                     healthDocument = entry.getValue()
     111            List<HisHealthDocument> allDocs = healthDocumentService.findByPathwayParticipation(pathwayParticipation); 
     112            for (HisHealthDocument hd : allDocs) { 
     113                if (hd.getFormId().equals(OperatiePlanningFormFactory.FORM_NAME + "_" + OperatiePlanningFormFactory.FORM_VERSION)) { 
     114                    healthDocument = hd
    115115                    break; 
    116116                } 
     
    118118        } 
    119119 
    120         if (healthDocument != null && healthDocument.getData() != null) { 
    121             operatiePlanningForm = (OperatiePlanningForm) operatiePlanningFormFactory.createForm("operatie_planning_form", XmlUtils.resolveDocument(healthDocument.getData()), new DocumentSubmissionHandler() { 
     120        if (healthDocument != null && healthDocument.getHealthDocument() != null) { 
     121            operatiePlanningForm = (OperatiePlanningForm) operatiePlanningFormFactory.createForm("operatie_planning_form", XmlUtils.resolveDocument(healthDocument.getHealthDocument()), new DocumentSubmissionHandler() { 
    122122                public void handle(FormWithAssociatedMarkup form, Document document) { 
    123                     healthDocument.setData(document.getDocumentElement()); 
     123                    healthDocument.setHealthDocument(document); 
    124124 
    125125                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    126126                        public Object execute() { 
    127                             healthRecordService.update(healthDocument, pathwayParticipation); 
     127                            healthDocumentService.update(healthDocument); 
    128128                            if (operatiePlanningForm.isCompleted()) { 
    129129                                taskService.markTaskAsCompleted(taskInstance); 
     
    137137            operatiePlanningForm = (OperatiePlanningForm) operatiePlanningFormFactory.createForm("operatie_planning_form", new DocumentSubmissionHandler() { 
    138138                public void handle(FormWithAssociatedMarkup form, Document document) { 
    139                     HealthDocumentMetaData metaData = new HealthDocumentMetaData(OperatiePlanningFormFactory.FORM_NAME, OperatiePlanningFormFactory.FORM_VERSION); 
    140                     final HealthDocument healthDocument = new HealthDocument(document, metaData); 
     139                    final HisHealthDocument healthDocument = new HisHealthDocument(OperatiePlanningFormFactory.FORM_VERSION, 
     140                            OperatiePlanningFormFactory.FORM_NAME, pathwayParticipation, document); 
    141141 
    142142                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    143143                        public Object execute() { 
    144                             String recordId = healthRecordService.add(healthDocument, pathwayParticipation); 
    145                             taskService.setVariable(taskInstance, "OperatiePlanning_recordId", recordId); 
     144                            HisHealthDocument savedDoc = healthDocumentService.create(healthDocument); 
     145                            taskService.setVariable(taskInstance, "OperatiePlanning_recordId", savedDoc.getId()); 
    146146                            if (operatiePlanningForm.isCompleted()) { 
    147147                                taskService.markTaskAsCompleted(taskInstance); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/surgical/post/OperatieVerwerkingFormTaskPanel.java

    r2507 r2594  
    2020import org.apache.wicket.spring.injection.annot.SpringBean; 
    2121import org.jbpm.taskmgmt.exe.TaskInstance; 
    22 import org.joiningtracks.his.data.model.HealthDocument; 
    23 import org.joiningtracks.his.data.model.HealthDocumentMetaData; 
    24 import org.joiningtracks.his.data.model.PathwayParticipation; 
    25 import org.joiningtracks.his.data.model.Patient; 
     22import org.joiningtracks.his.data.model.*; 
    2623import org.joiningtracks.his.frontend.common.wicket.form.FormWithAssociatedMarkup; 
    2724import org.joiningtracks.his.frontend.common.wicket.form.dom.DocumentSubmissionHandler; 
    2825import org.joiningtracks.his.frontend.common.wicket.taskpanel.AbstractTaskPanel; 
    29 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
     26import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    3027import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    3128import org.joiningtracks.his.service.process.TaskService; 
     
    3532import org.w3c.dom.Document; 
    3633 
     34import java.util.List; 
    3735import java.util.Map; 
    3836 
     
    4745    private PathwayParticipationService pathwayParticipationService; 
    4846    @SpringBean 
    49     private HealthRecordService healthRecordService; 
     47    private HealthDocumentService healthDocumentService; 
    5048    @SpringBean 
    5149    private TaskService taskService; 
     
    5654 
    5755    private final OperatieVerwerkingForm operatieVerwerkingForm; 
    58     private HealthDocument healthDocument; 
     56    private HisHealthDocument healthDocument; 
    5957 
    6058    /** 
     
    107105        Patient patient = pathwayParticipation.getPatient(); 
    108106 
    109         String operatieVerwerkingRecordId = (String) taskService.getVariable(taskInstance, "OperatieVerwerking_recordId"); 
     107        Long operatieVerwerkingRecordId = (Long) taskService.getVariable(taskInstance, "OperatieVerwerking_recordId"); 
    110108        // get the healthDocument (if it already exists)  "operatie verwerking_1.0.0" 
    111109        if (operatieVerwerkingRecordId != null) { 
    112             healthDocument = healthRecordService.get(operatieVerwerkingRecordId, pathwayParticipation); 
     110            healthDocument = healthDocumentService.getById(operatieVerwerkingRecordId); 
    113111        } 
    114112        //if the healthDocument could not be collected the via the variable, scan for the healthDocument. There should only be one per participation. 
    115113        if (healthDocument == null) { 
    116             Map<String, HealthDocument> allDocs = healthRecordService.getAllDocuments(pathwayParticipation); 
    117             for (Map.Entry<String, HealthDocument> entry : allDocs.entrySet()) { 
    118                 if (entry.getValue().getMetaData().getFormId().equals(OperatieVerwerkingFormFactory.FORM_NAME + "_" + OperatieVerwerkingFormFactory.FORM_VERSION)) { 
    119                     healthDocument = entry.getValue()
     114            List<HisHealthDocument> allDocs = healthDocumentService.findByPathwayParticipation(pathwayParticipation); 
     115            for (HisHealthDocument thd : allDocs) { 
     116                if (thd.getFormId().equals(OperatieVerwerkingFormFactory.FORM_NAME + "_" + OperatieVerwerkingFormFactory.FORM_VERSION)) { 
     117                    healthDocument = thd
    120118                    break; 
    121119                } 
     
    123121        } 
    124122 
    125         if (healthDocument != null && healthDocument.getData() != null) { 
    126             operatieVerwerkingForm = (OperatieVerwerkingForm) operatieVerwerkingFormFactory.createForm("operatie_verwerking_form", XmlUtils.resolveDocument(healthDocument.getData()), new DocumentSubmissionHandler() { 
     123        if (healthDocument != null && healthDocument.getHealthDocument() != null) { 
     124            operatieVerwerkingForm = (OperatieVerwerkingForm) operatieVerwerkingFormFactory.createForm("operatie_verwerking_form", 
     125                    XmlUtils.resolveDocument(healthDocument.getHealthDocument()), new DocumentSubmissionHandler() { 
    127126                public void handle(FormWithAssociatedMarkup form, Document document) { 
    128                     healthDocument.setData(document.getDocumentElement()); 
     127                    healthDocument.setHealthDocument(document); 
    129128 
    130129                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    131130                        public Object execute() { 
    132                             healthRecordService.update(healthDocument, pathwayParticipation); 
     131                            healthDocumentService.update(healthDocument); 
    133132                            if (operatieVerwerkingForm.isCompleted()) { 
    134133                                taskService.markTaskAsCompleted(taskInstance); 
     
    142141            operatieVerwerkingForm = (OperatieVerwerkingForm) operatieVerwerkingFormFactory.createForm("operatie_verwerking_form", new DocumentSubmissionHandler() { 
    143142                public void handle(FormWithAssociatedMarkup form, Document document) { 
    144                     HealthDocumentMetaData metaData = new HealthDocumentMetaData(OperatieVerwerkingFormFactory.FORM_NAME, OperatieVerwerkingFormFactory.FORM_VERSION); 
    145                     final HealthDocument healthDocument = new HealthDocument(document, metaData); 
     143                    final HisHealthDocument healthDocument = new HisHealthDocument(OperatieVerwerkingFormFactory.FORM_VERSION, 
     144                            OperatieVerwerkingFormFactory.FORM_NAME, pathwayParticipation, document); 
    146145 
    147146                    transactionTemplate.runInTransaction(new TransactionCallback<Object>() { 
    148147                        public Object execute() { 
    149                             String recordId = healthRecordService.add(healthDocument, pathwayParticipation); 
    150                             taskService.setVariable(taskInstance, "OperatieVerwerking_recordId", recordId); 
     148                            HisHealthDocument savedDoc = healthDocumentService.create(healthDocument); 
     149                            taskService.setVariable(taskInstance, "OperatieVerwerking_recordId", savedDoc.getId()); 
    151150                            if (operatieVerwerkingForm.isCompleted()) { 
    152151                                taskService.markTaskAsCompleted(taskInstance); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/java/org/joiningtracks/his/pathway/nok/treatment/tasks/SelectPatientGroupPanel.java

    r2507 r2594  
    9797            @Override 
    9898            protected void populateItem(ListItem item) { 
    99                 final PatientGroup patientGroup = (PatientGroup) item.getDefaultModelObject(); 
     99                PatientGroup pg = (PatientGroup) item.getDefaultModelObject(); 
     100                final PatientGroup patientGroup = patientGroupService.getById(pg.getId()); 
    100101 
    101102                item.add(new Radio("radio", item.getDefaultModel())); 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/main/resources/META-INF/spring/bundle-config.xml

    r2586 r2594  
    9999    <osgi:reference id="pathwayPluginService" interface="org.joiningtracks.his.plugin.bridge.pathway.PathwayPluginService"/> 
    100100     
    101     <osgi:reference id="healthRecordService" 
    102                     interface="org.joiningtracks.his.service.healthrecord.HealthRecordService"/> 
     101    <osgi:reference id="healthDocumentService" 
     102                    interface="org.joiningtracks.his.service.healthdocument.HealthDocumentService"/> 
    103103 
    104104    <osgi:reference id="appointmentService" interface="org.joiningtracks.his.service.appointment.AppointmentService"/> 
  • his-extensions/plugins/trunk/treatment/treatment-base/src/test/java/org/joiningtracks/his/pathway/nok/treatment/surgical/post/OperatieVerwerkingFormTest.java

    r2507 r2594  
    1818import org.apache.wicket.markup.html.WebPage; 
    1919import org.apache.wicket.model.CompoundPropertyModel; 
    20 import org.apache.wicket.model.Model; 
    2120import org.apache.wicket.spring.injection.annot.SpringComponentInjector; 
    2221import org.apache.wicket.spring.test.ApplicationContextMock; 
     
    2625import org.joiningtracks.his.data.model.PathwayParticipation; 
    2726import org.joiningtracks.his.data.model.Patient; 
    28 import org.joiningtracks.his.data.model.HealthDocument; 
    2927import org.joiningtracks.his.frontend.common.wicket.form.dom.DocumentSubmissionHandler; 
    3028import org.joiningtracks.his.frontend.common.wicket.form.FormWithAssociatedMarkup; 
  • his/trunk/README.txt

    r1300 r2594  
    5858 
    5959  
    60  
    61 2. Installing eXist 1.2.1. 
    62  
    63    For healthrecords a XML database is used, in our case the open source XML 
    64    database eXist. The release we use is: 1.2.1.. 
    65  
    66    - Download eXist 1.2.1 from http://exist.sourceforge.net/download.html 
    67    - Start the installation by running 'java -jar eXist-xxx.jar' 
    68    - See http://exist.sourceforge.net/quickstart.html for more information 
    69    - Open http://localhost:8080/exist/admin/admin.xql with username admin 
    70    - Create the collection: /his/healthrecords 
    71    - Create user 'build'. 
    72      Group: build. 
    73      Pasword: build. 
    74      Home collection: /his/healthrecords. 
    75    - Change 'data/src/test/resources/test.properties' 
    76             'configuration/default/tomcat/conf/his.properties' 
    77             'configuration/production/tomcat/conf/his.properties' 
    78      to contain the right eXist connection parameters. 
    79         xmldb.url=xmldb:exist://localhost:8080/exist/xmlrpc/db 
    80         xmldb.username=build 
    81         xmldb.password=build 
    82  
    83 3. Installing LDAP 
     602. Installing LDAP 
    8461 
    8562   So to fully test the system, you will have to setup an LDAP directory 
     
    9673        ldap.password=password 
    9774 
    98 4. Installing the certificate for the communication with the Vecozo webservice. 
     753. Installing the certificate for the communication with the Vecozo webservice. 
    9976 
    10077    We use one of the Vecozo webservices to verify and support the creation of new patients in the system. 
  • his/trunk/data/etc/create_db.sql

    r2291 r2594  
    598598    id                          BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, 
    599599    version                     BIGINT(20) NOT NULL default 0, 
    600     patient_id                  BIGINT(20) UNSIGNED NOT NULL
     600    patient_id                  BIGINT(20) UNSIGNED
    601601    pathway_participation_id    BIGINT(20) UNSIGNED, 
     602    patientgroup_id             BIGINT(20) UNSIGNED, 
    602603    document_version            varchar(10) NOT NULL, 
    603604    document_type               varchar(255) NOT NULL, 
     
    614615    CONSTRAINT fk_healthdocument_pathway_participation_id FOREIGN KEY (pathway_participation_id) 
    615616        REFERENCES pathway_participation(id) 
     617        ON DELETE RESTRICT ON UPDATE RESTRICT, 
     618 
     619    CONSTRAINT fk_healthdocument_patientgroup_id FOREIGN KEY (patientgroup_id) 
     620        REFERENCES patientgroup(id) 
    616621        ON DELETE RESTRICT ON UPDATE RESTRICT 
    617622 
  • his/trunk/data/src/main/java/org/joiningtracks/his/data/dao/HealthDocumentDao.java

    r2593 r2594  
    1919import org.joiningtracks.his.data.model.PathwayParticipation; 
    2020import org.joiningtracks.his.data.model.Patient; 
     21import org.joiningtracks.his.data.model.PatientGroup; 
    2122import org.joiningtracks.his.support.data.dao.Dao; 
    2223 
     
    2728 * 
    2829 * @author Daan van Etten 
     30 * @author Wouter Ketting 
    2931 */ 
    3032public interface HealthDocumentDao extends Dao<HisHealthDocument>{ 
     
    3739 
    3840    List<HisHealthDocument> findByPatient(Patient patient); 
     41 
     42    List<HisHealthDocument> findByPatientGroup(PatientGroup patientGroup); 
    3943} 
  • his/trunk/data/src/main/java/org/joiningtracks/his/data/dao/jpa/JpaHealthDocumentDao.java

    r2593 r2594  
    2020import org.joiningtracks.his.data.model.PathwayParticipation; 
    2121import org.joiningtracks.his.data.model.Patient; 
     22import org.joiningtracks.his.data.model.PatientGroup; 
    2223import org.joiningtracks.his.support.data.dao.jpa.AbstractJpaDao; 
    2324 
     
    119120        return resultList; 
    120121    } 
     122 
     123    public List<HisHealthDocument> findByPatientGroup(PatientGroup patientGroup) { 
     124        Map<String, Object> parameters = new HashMap<String, Object>(); 
     125        parameters.put("patientGroup", patientGroup); 
     126 
     127        StringBuilder jql = new StringBuilder(); 
     128        jql.append("select h from HisHealthDocument h WHERE h.patientGroup = :patientGroup "); 
     129 
     130        Query query = getEntityManager().createQuery(jql.toString()); 
     131        for (Map.Entry<String, Object> entry : parameters.entrySet()) { 
     132            query.setParameter(entry.getKey(), entry.getValue()); 
     133        } 
     134 
     135        List<HisHealthDocument> resultList = query.getResultList(); 
     136 
     137        return resultList; 
     138    } 
    121139} 
    122140 
  • his/trunk/data/src/main/java/org/joiningtracks/his/data/model/HisHealthDocument.java

    r2593 r2594  
    5454    private PathwayParticipation pathwayParticipation; 
    5555 
    56     @OneToOne(optional = false, cascade = CascadeType.MERGE) 
    57     @JoinColumn(name = "patient_id"
     56    @OneToOne(optional = true, cascade = CascadeType.MERGE) 
     57    @JoinColumn(name = "patient_id", nullable = true
    5858    private Patient patient; 
     59 
     60    @OneToOne(optional = true, cascade = CascadeType.MERGE) 
     61    @JoinColumn(name = "patientgroup_id", nullable = true) 
     62    private PatientGroup patientGroup; 
    5963 
    6064    @Column(name = "document") 
     
    8791    } 
    8892 
     93    public HisHealthDocument(PatientGroup patientGroup){ 
     94        this.patientGroup = patientGroup; 
     95        this.created = new DateTime(); 
     96    } 
     97 
    8998    public HisHealthDocument(String documentVersion, String documentType, String formId, Document xmlDocument) { 
    9099        this.documentVersion = documentVersion; 
     
    93102        this.created = new DateTime(); 
    94103        setHealthDocument(xmlDocument); 
     104    } 
     105 
     106    public HisHealthDocument(String documentVersion, String documentType, PatientGroup patientGroup, Document healthDocument) { 
     107        this.documentVersion = documentVersion; 
     108        this.documentType = documentType; 
     109        this.formId = documentType + "_" + documentVersion; 
     110        this.patientGroup = patientGroup; 
     111        this.created = new DateTime(); 
     112        setHealthDocument(healthDocument); 
    95113    } 
    96114 
     
    124142                .append(pathwayParticipation, other.pathwayParticipation) 
    125143                .append(patient, other.patient) 
     144                .append(patientGroup, other.patientGroup) 
    126145                .append(document, other.document) 
    127146                .isEquals(); 
     
    137156             append(pathwayParticipation). 
    138157             append(patient). 
     158             append(patientGroup). 
    139159             append(document). 
    140160             toHashCode(); 
     
    187207    public void setPatient(Patient patient) { 
    188208        this.patient = patient; 
     209    } 
     210 
     211    public PatientGroup getPatientGroup() { 
     212        return patientGroup; 
     213    } 
     214 
     215    public void setPatientGroup(PatientGroup patientGroup) { 
     216        this.patientGroup = patientGroup; 
    189217    } 
    190218 
  • his/trunk/frontend/internal/src/main/java/org/joiningtracks/his/frontend/employee/patient/dossier/form/FormsTabPanel.java

    r2593 r2594  
    6464        add(new Panel(getContentId())); 
    6565 
    66 //        HealthRecordVerificationResult result = healthRecordService.verifyAvailability(patient); 
    67 //        switch (result) { 
    68 //            case REGISTERED_NOT_AVAILABLE: { 
    69 //                error(getString("formsTabPanel.error.healthRecord.notAvailable")); 
    70 //                break; 
    71 //            } 
    72 // 
    73 //            case NOT_REGISTERED: { 
    74 //                healthRecordService.createRepository(patient); 
    75 //                info("formsTabPanel.info.healthRecord.created"); 
    76 //                break; 
    77 //            } 
    78 // 
    79 //            case AVAILABLE: { 
    80 //                 do nothing 
    81 //                break; 
    82 //            } 
    83 //        } 
    8466        showDashboard(); 
    8567    } 
  • his/trunk/service/src/main/java/org/joiningtracks/his/service/healthdocument/HealthDocumentService.java

    r2593 r2594  
    1919import org.joiningtracks.his.data.model.PathwayParticipation; 
    2020import org.joiningtracks.his.data.model.Patient; 
     21import org.joiningtracks.his.data.model.PatientGroup; 
    2122 
    2223import java.util.List; 
     
    2627 * 
    2728 * @author Daan van Etten 
     29 * @author Wouter Ketting 
    2830 */ 
    2931public interface HealthDocumentService { 
     
    6264    List<HisHealthDocument> findByPatient(Patient patient); 
    6365 
     66    List<HisHealthDocument> findByPatientGroup(PatientGroup patientGroup); 
     67 
    6468    HisHealthDocument removeById(long id); 
    6569} 
  • his/trunk/service/src/main/java/org/joiningtracks/his/service/healthdocument/impl/DefaultHealthDocumentService.java

    r2593 r2594  
    2020import org.joiningtracks.his.data.model.PathwayParticipation; 
    2121import org.joiningtracks.his.data.model.Patient; 
     22import org.joiningtracks.his.data.model.PatientGroup; 
    2223import org.joiningtracks.his.service.healthdocument.HealthDocumentService; 
    2324import org.springframework.beans.factory.annotation.Required; 
     25import org.springframework.transaction.annotation.Transactional; 
    2426 
    2527import java.util.List; 
     
    2931 * 
    3032 * @author Daan van Etten 
     33 * @author Wouter Ketting 
    3134 */ 
     35@Transactional 
    3236public class DefaultHealthDocumentService implements HealthDocumentService { 
    3337     
    3438    private HealthDocumentDao healthDocumentDao; 
    3539 
    36     public final HisHealthDocument getById(long id) { 
     40    public HisHealthDocument getById(long id) { 
    3741        return healthDocumentDao.getById(id); 
    3842    } 
    3943 
    40     public final HisHealthDocument create(HisHealthDocument healthDocumentReference) { 
    41         long id = healthDocumentDao.save(healthDocumentReference); 
     44    public HisHealthDocument create(HisHealthDocument healthDocument) { 
     45        long id = healthDocumentDao.save(healthDocument); 
    4246        return healthDocumentDao.getById(id); 
    4347    } 
    4448 
    45     public final HisHealthDocument update(HisHealthDocument healthDocumentReference) { 
    46         return healthDocumentDao.update(healthDocumentReference); 
     49    public HisHealthDocument update(HisHealthDocument healthDocument) { 
     50        return healthDocumentDao.update(healthDocument); 
    4751    } 
    4852 
     
    6367    } 
    6468 
     69    public List<HisHealthDocument> findByPatientGroup(PatientGroup patientGroup) { 
     70        return healthDocumentDao.findByPatientGroup(patientGroup); 
     71    } 
     72 
    6573    public HisHealthDocument removeById(long id) { 
    6674        return healthDocumentDao.removeById(id); 
     
    6876 
    6977    @Required 
    70     public final void setHealthDocumentDao(HealthDocumentDao healthDocumentDao) { 
     78    public void setHealthDocumentDao(HealthDocumentDao healthDocumentDao) { 
    7179        this.healthDocumentDao = healthDocumentDao; 
    7280    } 
  • his/trunk/service/src/main/java/org/joiningtracks/his/service/pathway/impl/DefaultPathwayParticipationService.java

    r2493 r2594  
    2727import org.joiningtracks.his.data.util.jbpm.JbpmTemplate; 
    2828import org.joiningtracks.his.events.RaisesEvent; 
    29 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    3029import org.joiningtracks.his.service.pathway.PathwayParticipationService; 
    3130import org.joiningtracks.his.service.pathway.PathwayParticipationAlreadyCancelledException; 
     
    5453    private PathwayParticipationCancellationDao pathwayParticipationCancellationDao; 
    5554    private JbpmTemplate jbpmTemplate; 
    56     private HealthRecordService healthRecordService; 
    5755 
    5856    public PathwayParticipation getById(long id) { 
     
    7270        pathwayParticipation.setPatient(patient); 
    7371        pathwayParticipationDao.save(pathwayParticipation); 
    74  
    75         healthRecordService.createRepository(pathwayParticipation); 
    7672 
    7773        try { 
     
    10298        pathwayParticipation.setPayingParties(payingParties); 
    10399        pathwayParticipationDao.save(pathwayParticipation); 
    104  
    105         healthRecordService.createRepository(pathwayParticipation); 
    106100 
    107101        try { 
     
    308302        this.jbpmTemplate = jbpmTemplate; 
    309303    } 
    310  
    311     @Required 
    312     public void setHealthRecordService(HealthRecordService healthRecordService) { 
    313         this.healthRecordService = healthRecordService; 
    314     } 
    315      
    316304} 
  • his/trunk/service/src/main/java/org/joiningtracks/his/service/patient/impl/DefaultPatientService.java

    r1631 r2594  
    2525import org.joiningtracks.his.data.model.Patient; 
    2626import org.joiningtracks.his.events.RaisesEvent; 
    27 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    2827import org.joiningtracks.his.service.mail.MailService; 
    2928import org.joiningtracks.his.service.patient.PatientService; 
     
    5049 
    5150    private PatientDao patientDao; 
    52     private HealthRecordService healthRecordService; 
    5351    private MailService mailService; 
    5452 
     
    6967        Patient updatedPatient; 
    7068        try { 
    71             patientDao.save(patient); 
    72             healthRecordService.createRepository(patient); 
    73             updatedPatient = patientDao.update(patient); 
     69            long patientId = patientDao.save(patient); 
     70            updatedPatient = getById(patientId); 
    7471        } catch (RuntimeException ex) { 
    7572            // Catch any exception thrown to allow reporting this exception by sending an mail. 
     
    152149 
    153150    @Required 
    154     public void setHealthRecordService(HealthRecordService healthRecordService) { 
    155         this.healthRecordService = healthRecordService; 
    156     } 
    157  
    158     @Required 
    159151    public void setMailService(MailService mailService) { 
    160152        this.mailService = mailService; 
  • his/trunk/service/src/main/resources/context/services.xml

    r2283 r2594  
    2525    <bean id="patientService" class="org.joiningtracks.his.service.patient.impl.DefaultPatientService"> 
    2626        <property name="patientDao" ref="patientDao"/> 
    27         <property name="healthRecordService" ref="healthRecordService"/> 
    2827        <property name="mailService" ref="mailService"/> 
    2928    </bean> 
     
    115114        <property name="pathwayParticipationDao" ref="pathwayParticipationDao"/> 
    116115        <property name="jbpmTemplate" ref="jbpmTemplate"/> 
    117         <property name="healthRecordService" ref="healthRecordService"/> 
    118116        <property name="pathwayParticipationCancellationDao" ref="pathwayParticipationCancellationDao"/> 
    119117    </bean> 
  • his/trunk/service/src/test/java/org/joiningtracks/his/service/pathway/impl/DefaultPathwayParticipationServiceTest.java

    r1570 r2594  
    2828import org.joiningtracks.his.data.model.Patient; 
    2929import org.joiningtracks.his.data.util.jbpm.JbpmTemplate; 
    30 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    31 import org.joiningtracks.his.service.location.LocationService; 
    3230import org.junit.Assert; 
    3331import org.junit.Before; 
     
    7371        }, LogicalOperator.EQUAL))).andReturn(1L); 
    7472 
    75         HealthRecordService mockHealthRecordService = createMock(HealthRecordService.class); 
    76         mockHealthRecordService.createRepository(EasyMock.isA(PathwayParticipation.class)); 
    77         expectLastCall().once(); 
    78  
    79         replay(mockHealthRecordService); 
    80  
    8173        defaultPathwayParticipationService.setPathwayParticipationDao(mockParticipationDao); 
    8274        defaultPathwayParticipationService.setJbpmTemplate(jbpmTemplate); 
    83         defaultPathwayParticipationService.setHealthRecordService(mockHealthRecordService); 
    8475 
    8576        ProcessDefinition pathway = new ProcessDefinition("pathway 1"); 
     
    9586        Assert.assertSame(mockProcessInstance, result.getProcessInstance()); 
    9687 
    97         verify(jbpmTemplate, mockProcessInstance, mockParticipationDao, mockHealthRecordService); 
     88        verify(jbpmTemplate, mockProcessInstance, mockParticipationDao); 
    9889    } 
    9990 
     
    10192    public void testFindAllPatientsWithNoPayingParties() { 
    10293        PathwayParticipationDao mockParticipationDao = createMock(PathwayParticipationDao.class); 
    103         LocationService mockLocationService = createMock(LocationService.class); 
    10494 
    10595        defaultPathwayParticipationService.setPathwayParticipationDao(mockParticipationDao); 
  • his/trunk/service/src/test/java/org/joiningtracks/his/service/patient/impl/DefaultPatientServiceTest.java

    r1625 r2594  
    2121import org.joiningtracks.his.data.dao.query.QueryParams; 
    2222import org.joiningtracks.his.data.model.Patient; 
    23 import org.joiningtracks.his.service.healthrecord.HealthRecordService; 
    2423import org.joiningtracks.his.service.mail.MailService; 
    2524import org.junit.Assert; 
     
    4342    private DefaultPatientService patientService; 
    4443    private PatientDao patientDao; 
    45     private HealthRecordService healthRecordService; 
    4644    private MailService mailService; 
    4745 
     
    5149 
    5250        patientDao = createMock(PatientDao.class); 
    53         healthRecordService = createMock(HealthRecordService.class); 
    5451        mailService = createMock(MailService.class); 
    5552    } 
     
    5855    public void testCreate() { 
    5956        patientService.setPatientDao(patientDao); 
    60         patientService.setHealthRecordService(healthRecordService); 
    6157        final long expectedId = 1L; 
    6258        Patient expectedPatient = new Patient(expectedId); 
    6359        expect(patientDao.save(expectedPatient)).andReturn(expectedId); 
    64         expect(patientDao.update(expectedPatient)).andReturn(expectedPatient); 
    65         healthRecordService.createRepository(expectedPatient); 
    66         expectLastCall(); 
    67         replay(patientDao, healthRecordService); 
     60        expect(patientDao.getById(1L)).andReturn(expectedPatient); 
     61        replay(patientDao); 
    6862 
    6963        Patient patient = patientService.create(expectedPatient); 
    7064 
    71         verify(patientDao, healthRecordService); 
     65        verify(patientDao); 
    7266        Assert.assertSame(expectedPatient, patient); 
    7367    } 
     
    9084        } catch (RuntimeException expected) { 
    9185            verify(patientDao, mailService); 
    92         } 
    93     } 
    94  
    95     @Test 
    96     public void testCreate_PropagatesExceptionsFromHealthRecordService() throws Exception { 
    97         patientService.setPatientDao(patientDao); 
    98         patientService.setHealthRecordService(healthRecordService); 
    99         patientService.setMailService(mailService); 
    100         final long expectedId = 1L; 
    101         Patient patient = new Patient(expectedId); 
    102         RuntimeException ex = new RuntimeException("Supposed failure creating repository for patient"); 
    103  
    104         expect(patientDao.save(patient)).andReturn(expectedId); 
    105         expectLastCall(); 
    106         healthRecordService.createRepository(patient); 
    107         expectLastCall().andThrow(ex); 
    108         mailService.sendPatientCreateFailureNotificationEmail(patient, ex); 
    109         expectLastCall(); 
    110  
    111         replay(patientDao, healthRecordService, mailService); 
    112  
    113         try { 
    114             patientService.create(patient); 
    115             Assert.fail("Exception expected"); 
    116         } catch (RuntimeException expected) { 
    117             verify(patientDao, healthRecordService, mailService); 
    11886        } 
    11987    }