/**
  * @see parent::addControlActProcess()
  */
 function addControlActProcess(CPatient $patient)
 {
     $dom = $this->dom;
     $controlActProcess = parent::addControlActProcess($patient);
     // reasonCode
     $reasonCode = $dom->addElement($controlActProcess, "reasonCode");
     $this->setCode($reasonCode, "TEST_EXST", "1.2.250.1.213.1.1.4.11", "Test d'existence de dossier");
     // queryByParameter
     $queryByParameter = $dom->addElement($controlActProcess, "queryByParameter");
     // queryId
     $queryId = $dom->addElement($queryByParameter, "queryId");
     $this->setII($queryId, $this->_exchange_hl7v3->_id, CMbOID::getOIDFromClass($this->_exchange_hl7v3, $this->_receiver));
     // statusCode
     $statusCode = $dom->addElement($queryByParameter, "statusCode");
     $dom->addAttribute($statusCode, "code", "new");
     // parameterList
     $parameterList = $dom->addElement($queryByParameter, "parameterList");
     // patientIdentifer
     $patientIdentifer = $dom->addElement($parameterList, "patientIdentifier");
     $value = $dom->addElement($patientIdentifer, "value");
     $this->setII($value, $patient->_ref_last_ins->ins, "1.2.250.1.213.1.4.2");
     $dom->addElement($patientIdentifer, "semanticsText", "Patient.id");
 }
 /**
  * @see parent::addControlActProcess()
  */
 function addControlActProcess(CPatient $patient)
 {
     $dom = $this->dom;
     $transform_date = false;
     $controlActProcess = parent::addControlActProcess($patient);
     // reasonCode
     $reasonCode = $dom->addElement($controlActProcess, "reasonCode");
     switch ($this->_reasonCode) {
         case 'REAC':
             $this->setCode($reasonCode, "REAC", "1.2.250.1.213.1.1.4.11", "Réactivation de dossier");
             break;
         case 'FERM':
             $this->setCode($reasonCode, "FERM", "1.2.250.1.213.1.1.4.11", "Fermeture de dossier");
             break;
         case 'MODIF_DATA':
             $this->setCode($reasonCode, "MODIF_DATA", "1.2.250.1.213.1.1.4.11", "Modification des données de gestion du dossier");
             $transform_date = true;
             break;
         default:
     }
     // subject
     $subject = $dom->addElement($controlActProcess, "subject");
     $dom->addAttribute($subject, "contextConductionInd", "false");
     $this->setTypeCode($subject, "SUBJ");
     // registrationRequest
     $registrationRequest = $dom->addElement($subject, "registrationRequest");
     $this->setClassMoodCode($registrationRequest, "REG", "RQO");
     // statusCode
     $statusCode = $dom->addElement($registrationRequest, "statusCode");
     $dom->addAttribute($statusCode, "code", $this->_reasonCode == "FERM" ? "terminated" : "active");
     // subject1
     $subject1 = $dom->addElement($registrationRequest, "subject1");
     $this->setTypeCode($subject1, "SBJ");
     // patient
     $patient_dom = $dom->addElement($subject1, "patient");
     $this->setClassCode($patient_dom, "PAT");
     $id = $dom->addElement($patient_dom, "id");
     $this->setII($id, $patient->_ref_last_ins->ins, "1.2.250.1.213.1.4.2");
     $statusCode = $dom->addElement($patient_dom, "statusCode");
     $dom->addAttribute($statusCode, "code", "active");
     // patientPerson
     $patientPerson = $dom->addElement($patient_dom, "patientPerson");
     $this->setClassDeterminerCode($patientPerson, "PSN", "INSTANCE");
     $this->addName($patientPerson, $patient);
     $this->addTelecom($patientPerson, $patient);
     $administrativeGenderCode = $dom->addElement($patientPerson, "administrativeGenderCode");
     $dom->addAttribute($administrativeGenderCode, "code", strtoupper($patient->sexe));
     $birthTime = $dom->addElement($patientPerson, "birthTime");
     $date = $this->getDateToFormatCDA($patient->_p_birth_date, $transform_date);
     $dom->addAttribute($birthTime, "value", $date);
     $this->addAdress($patientPerson, $patient);
     $this->addBirthPlace($patientPerson, $patient);
     // subjectOf
     $dmp_reactivation_dmp = $patient->_dmp_reactivation_dmp ? "true" : "false";
     $this->addSubjectOf($patient_dom, "CONSENTEMENT_REACTIVATION_DMP", "1.2.250.1.213.4.1.2.3", "Consentement à la réactivation du DMP", $dmp_reactivation_dmp, true);
     // author
     $author = $dom->addElement($registrationRequest, "author");
     $this->setTypeCode($author, "AUT");
     // assignedEntity
     $assignedEntity = $dom->addElement($author, "assignedEntity");
     $this->setClassCode($assignedEntity, "ASSIGNED");
     $id = $dom->addElement($assignedEntity, "id");
     $mediuser = $patient->_dmp_mediuser;
     $this->setII($id, $mediuser->_common_name, "1.2.250.1.71.4.2.1");
     // assignedPerson
     $assignedPerson = $dom->addElement($assignedEntity, "assignedPerson");
     $this->setClassDeterminerCode($assignedPerson, "PSN", "INSTANCE");
     $name = $dom->addElement($assignedPerson, "name");
     $name->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $name->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:type', 'PN');
     $dom->addElement($name, "family", $mediuser->_p_last_name);
     $dom->addElement($name, "given", $mediuser->_p_first_name);
     // representedOrganization
     $group = $mediuser->loadRefFunction()->loadRefGroup();
     $this->addRepresentedOrganizationGroup($assignedEntity, $group);
     if ($this->_reasonCode == "FERM") {
         $reasonOf = $dom->addElement($controlActProcess, "reasonOf");
         $this->setTypeCode($reasonOf, "RSON");
         $detectedIssueEvent = $dom->addElement($reasonOf, "detectedIssueEvent");
         $this->setClassMoodCode($detectedIssueEvent, "ALRT", "EVN");
         $code = $dom->addElement($detectedIssueEvent, "code");
         $this->setCode($code, "FERMETURE_DEMANDE_PATIENT", "1.2.250.1.213.4.1.2.4");
         $dom->addElement($detectedIssueEvent, "text", $patient->_dmp_reason_close);
     }
     // Traitement final
     $dom->purgeEmptyElements();
 }
 /**
  * @see parent::addControlActProcess()
  */
 function addControlActProcess(CPatient $patient)
 {
     $dom = $this->dom;
     $controlActProcess = parent::addControlActProcess($patient);
     // reasonCode
     $reasonCode = $dom->addElement($controlActProcess, "reasonCode");
     $this->setCode($reasonCode, "CREA_RD", "1.2.250.1.213.1.1.4.11", "Création de dossier");
     // subject
     $subject = $dom->addElement($controlActProcess, "subject");
     $dom->addAttribute($subject, "contextConductionInd", "false");
     $this->setTypeCode($subject, "SUBJ");
     // registrationRequest
     $registrationRequest = $dom->addElement($subject, "registrationRequest");
     $this->setClassMoodCode($registrationRequest, "REG", "RQO");
     // statusCode
     $statusCode = $dom->addElement($registrationRequest, "statusCode");
     $dom->addAttribute($statusCode, "code", "active");
     // subject1
     $subject1 = $dom->addElement($registrationRequest, "subject1");
     $this->setTypeCode($subject1, "SBJ");
     // patient
     $patient_dom = $dom->addElement($subject1, "patient");
     $this->setClassCode($patient_dom, "PAT");
     $id = $dom->addElement($patient_dom, "id");
     $this->setII($id, $patient->_ref_last_ins->ins, "1.2.250.1.213.1.4.2");
     $statusCode = $dom->addElement($patient_dom, "statusCode");
     $dom->addAttribute($statusCode, "code", "active");
     // patientPerson
     $patientPerson = $dom->addElement($patient_dom, "patientPerson");
     $this->setClassDeterminerCode($patientPerson, "PSN", "INSTANCE");
     $this->addName($patientPerson, $patient);
     $this->addTelecom($patientPerson, $patient);
     $administrativeGenderCode = $dom->addElement($patientPerson, "administrativeGenderCode");
     $dom->addAttribute($administrativeGenderCode, "code", strtoupper($patient->sexe));
     $birthTime = $dom->addElement($patientPerson, "birthTime");
     $date = $this->getDateToFormatCDA($patient->_p_birth_date);
     $dom->addAttribute($birthTime, "value", $date);
     $this->addAdress($patientPerson, $patient);
     $this->addContactParty($patientPerson, $patient);
     $this->addBirthPlace($patientPerson, $patient);
     // providerOrganization
     $providerOrganization = $dom->addElement($patient_dom, "providerOrganization");
     $providerOrganization->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $providerOrganization->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:nil', 'true');
     $this->setClassDeterminerCode($providerOrganization, "ORG", "INSTANCE");
     // subjectOf
     $this->addSubjectOf($patient_dom, "CONSENTEMENT_OUVERTURE_DMP", "1.2.250.1.213.4.1.2.3", "Consentement à l'ouverture du DMP", "true", true);
     // subjectOf
     $dmp_bris_de_glace = $patient->_dmp_urgence_PS ? "true" : "false";
     $this->addSubjectOf($patient_dom, "OPPOSITION_BRIS_DE_GLACE", "1.2.250.1.213.4.1.2.3", "opposition au mode bris de glace", $dmp_bris_de_glace);
     // subjectOf
     $dmp_acces_urgence = $patient->_dmp_urgence_15 ? "true" : "false";
     $this->addSubjectOf($patient_dom, "OPPOSITION_ACCES_URGENCE", "1.2.250.1.213.4.1.2.3", "opposition à l'accès au mode urgence", $dmp_acces_urgence);
     // author
     $author = $dom->addElement($registrationRequest, "author");
     $this->setTypeCode($author, "AUT");
     // assignedEntity
     $assignedEntity = $dom->addElement($author, "assignedEntity");
     $this->setClassCode($assignedEntity, "ASSIGNED");
     $id = $dom->addElement($assignedEntity, "id");
     $mediuser = $patient->_dmp_mediuser;
     $this->setII($id, $mediuser->_common_name, "1.2.250.1.71.4.2.1");
     // assignedPerson
     $assignedPerson = $dom->addElement($assignedEntity, "assignedPerson");
     $this->setClassDeterminerCode($assignedPerson, "PSN", "INSTANCE");
     $name = $dom->addElement($assignedPerson, "name");
     $name->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
     $name->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsi:type', 'PN');
     $dom->addElement($name, "family", $mediuser->_p_last_name);
     $dom->addElement($name, "given", $mediuser->_p_first_name);
     // representedOrganization
     if ($mediuser->_id) {
         $group = $mediuser->loadRefFunction()->loadRefGroup();
         $this->addRepresentedOrganizationGroup($assignedEntity, $group);
     } else {
         $this->addRepresentedOrganization($assignedEntity, $mediuser->_struct_id_nat, $mediuser->_struct_name);
     }
 }