Ejemplo n.º 1
0
 public TransmissionSummaryResult GetPrescriptionTransmissionStatusV2(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, PrescriptionTransmissionQueryType queryType, string queryId) {
     object[] results = this.Invoke("GetPrescriptionTransmissionStatusV2", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 queryType,
                 queryId});
     return ((TransmissionSummaryResult)(results[0]));
 }
Ejemplo n.º 2
0
 public TransmissionSummaryResult GetPrescriptionTransmissionStatusByPatient(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string queryMode, string status, string subStatus, string archiveStatus) {
     object[] results = this.Invoke("GetPrescriptionTransmissionStatusByPatient", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 queryMode,
                 status,
                 subStatus,
                 archiveStatus});
     return ((TransmissionSummaryResult)(results[0]));
 }
Ejemplo n.º 3
0
 /// <remarks/>
 public void GetPrescriptionTransmissionStatusByPatientAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string queryMode, string status, string subStatus, string archiveStatus, object userState) {
     if ((this.GetPrescriptionTransmissionStatusByPatientOperationCompleted == null)) {
         this.GetPrescriptionTransmissionStatusByPatientOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPrescriptionTransmissionStatusByPatientOperationCompleted);
     }
     this.InvokeAsync("GetPrescriptionTransmissionStatusByPatient", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 queryMode,
                 status,
                 subStatus,
                 archiveStatus}, this.GetPrescriptionTransmissionStatusByPatientOperationCompleted, userState);
 }
Ejemplo n.º 4
0
 /// <remarks/>
 public void GetPatientFreeFormAllergyHistoryAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester) {
     this.GetPatientFreeFormAllergyHistoryAsync(credentials, accountRequest, patientRequest, patientInformationRequester, null);
 }
Ejemplo n.º 5
0
 public TransmissionSummaryResult GetPrescriptionTransmissionStatus(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string prescriptionIds) {
     object[] results = this.Invoke("GetPrescriptionTransmissionStatus", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 prescriptionIds});
     return ((TransmissionSummaryResult)(results[0]));
 }
Ejemplo n.º 6
0
 /// <remarks/>
 public void GetPatientFullMedicationHistory6Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PrescriptionHistoryRequest prescriptionHistoryRequest, PatientInformationRequester patientInformationRequester, string patientIdType, string includeSchema) {
     this.GetPatientFullMedicationHistory6Async(credentials, accountRequest, patientRequest, prescriptionHistoryRequest, patientInformationRequester, patientIdType, includeSchema, null);
 }
Ejemplo n.º 7
0
 public Result GetPatientAllergyHistoryV3(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester) {
     object[] results = this.Invoke("GetPatientAllergyHistoryV3", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester});
     return ((Result)(results[0]));
 }
Ejemplo n.º 8
0
 public DrugAllergyDetailResultV2 DrugAllergyInteractionV2(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string[] allergies, string[] proposedMedications, string drugStandardType) {
     object[] results = this.Invoke("DrugAllergyInteractionV2", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 allergies,
                 proposedMedications,
                 drugStandardType});
     return ((DrugAllergyDetailResultV2)(results[0]));
 }
Ejemplo n.º 9
0
 /// <remarks/>
 public void DrugAllergyInteractionV2Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string[] allergies, string[] proposedMedications, string drugStandardType) {
     this.DrugAllergyInteractionV2Async(credentials, accountRequest, patientRequest, patientInformationRequester, allergies, proposedMedications, drugStandardType, null);
 }
Ejemplo n.º 10
0
 /// <remarks/>
 public void GetSubmittedMessageTransactionStatusAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string messageTransactionId, string messageTransactionSource) {
     this.GetSubmittedMessageTransactionStatusAsync(credentials, accountRequest, patientRequest, patientInformationRequester, messageTransactionId, messageTransactionSource, null);
 }
Ejemplo n.º 11
0
 /// <remarks/>
 public void GetSubmittedMessageTransactionStatusAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string messageTransactionId, string messageTransactionSource, object userState) {
     if ((this.GetSubmittedMessageTransactionStatusOperationCompleted == null)) {
         this.GetSubmittedMessageTransactionStatusOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSubmittedMessageTransactionStatusOperationCompleted);
     }
     this.InvokeAsync("GetSubmittedMessageTransactionStatus", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 messageTransactionId,
                 messageTransactionSource}, this.GetSubmittedMessageTransactionStatusOperationCompleted, userState);
 }
Ejemplo n.º 12
0
 public MessageTransactionStatusResult GetSubmittedMessageTransactionStatus(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string messageTransactionId, string messageTransactionSource) {
     object[] results = this.Invoke("GetSubmittedMessageTransactionStatus", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 messageTransactionId,
                 messageTransactionSource});
     return ((MessageTransactionStatusResult)(results[0]));
 }
Ejemplo n.º 13
0
 /// <remarks/>
 public void GetPrescriptionTransmissionStatusV2Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, PrescriptionTransmissionQueryType queryType, string queryId, object userState) {
     if ((this.GetPrescriptionTransmissionStatusV2OperationCompleted == null)) {
         this.GetPrescriptionTransmissionStatusV2OperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPrescriptionTransmissionStatusV2OperationCompleted);
     }
     this.InvokeAsync("GetPrescriptionTransmissionStatusV2", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 queryType,
                 queryId}, this.GetPrescriptionTransmissionStatusV2OperationCompleted, userState);
 }
Ejemplo n.º 14
0
 /// <remarks/>
 public void GetPrescriptionTransmissionStatusV2Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, PrescriptionTransmissionQueryType queryType, string queryId) {
     this.GetPrescriptionTransmissionStatusV2Async(credentials, accountRequest, patientRequest, patientInformationRequester, queryType, queryId, null);
 }
Ejemplo n.º 15
0
 public PatientDrugDetailResult5 GetPatientFullMedicationHistory5(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PrescriptionHistoryRequest prescriptionHistoryRequest, PatientInformationRequester patientInformationRequester, string patientIdType) {
     object[] results = this.Invoke("GetPatientFullMedicationHistory5", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 prescriptionHistoryRequest,
                 patientInformationRequester,
                 patientIdType});
     return ((PatientDrugDetailResult5)(results[0]));
 }
Ejemplo n.º 16
0
 /// <remarks/>
 public void DrugAllergyInteractionV2Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string[] allergies, string[] proposedMedications, string drugStandardType, object userState) {
     if ((this.DrugAllergyInteractionV2OperationCompleted == null)) {
         this.DrugAllergyInteractionV2OperationCompleted = new System.Threading.SendOrPostCallback(this.OnDrugAllergyInteractionV2OperationCompleted);
     }
     this.InvokeAsync("DrugAllergyInteractionV2", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 allergies,
                 proposedMedications,
                 drugStandardType}, this.DrugAllergyInteractionV2OperationCompleted, userState);
 }
Ejemplo n.º 17
0
 public Result GetPatientFullMedicationHistory6(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PrescriptionHistoryRequest prescriptionHistoryRequest, PatientInformationRequester patientInformationRequester, string patientIdType, string includeSchema) {
     object[] results = this.Invoke("GetPatientFullMedicationHistory6", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 prescriptionHistoryRequest,
                 patientInformationRequester,
                 patientIdType,
                 includeSchema});
     return ((Result)(results[0]));
 }
Ejemplo n.º 18
0
 public Result GetMeaningfulUsePatientEncounterInfo(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string encounterId, string includeSchema) {
     object[] results = this.Invoke("GetMeaningfulUsePatientEncounterInfo", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 encounterId,
                 includeSchema});
     return ((Result)(results[0]));
 }
Ejemplo n.º 19
0
 /// <remarks/>
 public void GetPatientFullMedicationHistory6Async(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PrescriptionHistoryRequest prescriptionHistoryRequest, PatientInformationRequester patientInformationRequester, string patientIdType, string includeSchema, object userState) {
     if ((this.GetPatientFullMedicationHistory6OperationCompleted == null)) {
         this.GetPatientFullMedicationHistory6OperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPatientFullMedicationHistory6OperationCompleted);
     }
     this.InvokeAsync("GetPatientFullMedicationHistory6", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 prescriptionHistoryRequest,
                 patientInformationRequester,
                 patientIdType,
                 includeSchema}, this.GetPatientFullMedicationHistory6OperationCompleted, userState);
 }
Ejemplo n.º 20
0
 /// <remarks/>
 public void GetMeaningfulUsePatientEncounterInfoAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string encounterId, string includeSchema) {
     this.GetMeaningfulUsePatientEncounterInfoAsync(credentials, accountRequest, patientRequest, patientInformationRequester, encounterId, includeSchema, null);
 }
Ejemplo n.º 21
0
 public PatientFreeFormAllergyExtendedDetailResult GetPatientFreeFormAllergyHistory(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester) {
     object[] results = this.Invoke("GetPatientFreeFormAllergyHistory", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester});
     return ((PatientFreeFormAllergyExtendedDetailResult)(results[0]));
 }
Ejemplo n.º 22
0
 /// <remarks/>
 public void GetMeaningfulUsePatientEncounterInfoAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string encounterId, string includeSchema, object userState) {
     if ((this.GetMeaningfulUsePatientEncounterInfoOperationCompleted == null)) {
         this.GetMeaningfulUsePatientEncounterInfoOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetMeaningfulUsePatientEncounterInfoOperationCompleted);
     }
     this.InvokeAsync("GetMeaningfulUsePatientEncounterInfo", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 encounterId,
                 includeSchema}, this.GetMeaningfulUsePatientEncounterInfoOperationCompleted, userState);
 }
Ejemplo n.º 23
0
 /// <remarks/>
 public void GetPatientFreeFormAllergyHistoryAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, object userState) {
     if ((this.GetPatientFreeFormAllergyHistoryOperationCompleted == null)) {
         this.GetPatientFreeFormAllergyHistoryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetPatientFreeFormAllergyHistoryOperationCompleted);
     }
     this.InvokeAsync("GetPatientFreeFormAllergyHistory", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester}, this.GetPatientFreeFormAllergyHistoryOperationCompleted, userState);
 }
Ejemplo n.º 24
0
 public Result DoseCheck(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string drugId, string drugTypeId, string birthDateCCYYMMDD, string gender, string diagnosis, string doseType, string dose, string doseUOM, string weightInKg, string includeSchema) {
     object[] results = this.Invoke("DoseCheck", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 drugId,
                 drugTypeId,
                 birthDateCCYYMMDD,
                 gender,
                 diagnosis,
                 doseType,
                 dose,
                 doseUOM,
                 weightInKg,
                 includeSchema});
     return ((Result)(results[0]));
 }
Ejemplo n.º 25
0
 /// <remarks/>
 public void GetPrescriptionTransmissionStatusAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string prescriptionIds) {
     this.GetPrescriptionTransmissionStatusAsync(credentials, accountRequest, patientRequest, patientInformationRequester, prescriptionIds, null);
 }
Ejemplo n.º 26
0
 /// <remarks/>
 public void DoseCheckAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string drugId, string drugTypeId, string birthDateCCYYMMDD, string gender, string diagnosis, string doseType, string dose, string doseUOM, string weightInKg, string includeSchema) {
     this.DoseCheckAsync(credentials, accountRequest, patientRequest, patientInformationRequester, drugId, drugTypeId, birthDateCCYYMMDD, gender, diagnosis, doseType, dose, doseUOM, weightInKg, includeSchema, null);
 }
Ejemplo n.º 27
0
 /// <remarks/>
 public void GetPrescriptionTransmissionStatusByPatientAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string queryMode, string status, string subStatus, string archiveStatus) {
     this.GetPrescriptionTransmissionStatusByPatientAsync(credentials, accountRequest, patientRequest, patientInformationRequester, queryMode, status, subStatus, archiveStatus, null);
 }
Ejemplo n.º 28
0
 /// <remarks/>
 public void DoseCheckAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string drugId, string drugTypeId, string birthDateCCYYMMDD, string gender, string diagnosis, string doseType, string dose, string doseUOM, string weightInKg, string includeSchema, object userState) {
     if ((this.DoseCheckOperationCompleted == null)) {
         this.DoseCheckOperationCompleted = new System.Threading.SendOrPostCallback(this.OnDoseCheckOperationCompleted);
     }
     this.InvokeAsync("DoseCheck", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 drugId,
                 drugTypeId,
                 birthDateCCYYMMDD,
                 gender,
                 diagnosis,
                 doseType,
                 dose,
                 doseUOM,
                 weightInKg,
                 includeSchema}, this.DoseCheckOperationCompleted, userState);
 }
Ejemplo n.º 29
0
		///<summary>Returns true if new information was pulled back from NewCrop.</summary>
		private bool NewCropRefreshPrescriptions() {
			Program programNewCrop=Programs.GetCur(ProgramName.NewCrop);
			if(!programNewCrop.Enabled) {
				return false;
			}
			if(PatCur==null) {
				return false;
			}
			string newCropAccountId=PrefC.GetString(PrefName.NewCropAccountId);
			if(newCropAccountId=="") {//We check for NewCropAccountID validity below, but we also need to be sure to exit this check for resellers if blank.
				return false;
			}
			if(!NewCropIsAccountIdValid()) {
				//The NewCropAccountID will be invalid for resellers, because the checksum will be wrong.
				//Therefore, resellers should be allowed to continue if both the NewCropName and NewCropPassword are specified. NewCrop does not allow blank passwords.
				if(PrefC.GetString(PrefName.NewCropName)=="" || PrefC.GetString(PrefName.NewCropPassword)=="") {
					return false;
				}
			}
			NewCrop.Update1 wsNewCrop=new NewCrop.Update1();//New Crop web services interface.
			NewCrop.Credentials credentials=new NewCrop.Credentials();
			NewCrop.AccountRequest accountRequest=new NewCrop.AccountRequest();
			NewCrop.PatientRequest patientRequest=new NewCrop.PatientRequest();
			NewCrop.PrescriptionHistoryRequest prescriptionHistoryRequest=new NewCrop.PrescriptionHistoryRequest();
			NewCrop.PatientInformationRequester patientInfoRequester=new NewCrop.PatientInformationRequester();
			NewCrop.Result response=new NewCrop.Result();
#if DEBUG
			wsNewCrop.Url="https://preproduction.newcropaccounts.com/v7/WebServices/Update1.asmx";
#endif
			credentials.PartnerName=ErxXml.NewCropPartnerName;
			credentials.Name=ErxXml.NewCropAccountName;
			credentials.Password=ErxXml.NewCropAccountPasssword;
			accountRequest.AccountId=newCropAccountId;
			accountRequest.SiteId="1";//Accounts are always created with SiteId=1.
			patientRequest.PatientId=POut.Long(PatCur.PatNum);
			prescriptionHistoryRequest.StartHistory=new DateTime(2012,11,2);//Only used for archived prescriptions. This is the date of first release for NewCrop integration.
			prescriptionHistoryRequest.EndHistory=DateTime.Now;//Only used for archived prescriptions.
			//Prescription Archive Status Values:
			//N = Not archived (i.e. Current Medication) 
			//Y = Archived (i.e. Previous Mediation)
			//% = Both Not Archived and Archived
			//Note: This field will contain values other than Y,N in future releases.
			prescriptionHistoryRequest.PrescriptionArchiveStatus="N";
			//Prescription Status Values:
			//C = Completed Prescription
			//P = Pending Medication
			//% = Both C and P.
			prescriptionHistoryRequest.PrescriptionStatus="C";
			//Prescription Sub Status Values:
			//% = All meds (Returns all meds regardless of the sub status)
			//A = NS (Returns only meds that have a 'NS' - Needs staff sub status)
			//U = DR (Returns only meds that have a 'DR' - Needs doctor review sub status)
			//P = Renewal Request that has been selected for processing on the NewCrop screens - it has not yet been denied, denied and re-written or accepted
			//S = Standard Rx (Returns only meds that have an 'InProc' - InProcess sub status)
			//D = DrugSet source - indicates the prescription was created by selecting the medication from the DrugSet selection box on the ComposeRx page
			//O = Outside Prescription - indicates the prescription was created on the MedEntry page, not prescribed.
			prescriptionHistoryRequest.PrescriptionSubStatus="S";
			patientInfoRequester.UserType="Staff";//Allowed values: Doctor,Staff
			if(Security.CurUser.ProvNum!=0) {//If the current OD user is associated to a doctor, then the request is from a doctor, otherwise from a staff member.
			  patientInfoRequester.UserType="Doctor";
			}
			patientInfoRequester.UserId=POut.Long(Security.CurUser.UserNum);
			//Send the request to NewCrop. Always returns all current medications, and returns medications between the StartHistory and EndHistory dates if requesting archived medications.
			//The patientIdType parameter was added for another vendor and is not often used. We do not use this field. We must pass empty string.
			//The includeSchema parameter is useful for first-time debugging, but in release mode, we should pass N for no.
			wsNewCrop.Timeout=3000;//3 second. The default is 100 seconds, but we cannot wait that long, because prescriptions are checked each time the Chart is refreshed. 1 second is too little, 2 seconds works most of the time. 3 seconds is safe.
			try {
				response=wsNewCrop.GetPatientFullMedicationHistory6(credentials,accountRequest,patientRequest,prescriptionHistoryRequest,patientInfoRequester,"","N");
			}
			catch { //An exception is thrown when the timeout is reached, or when the NewCrop servers are not accessible (because the servers are down, or because local internet is down).
				//We used to show a popup here, but users found it annoying when the NewCrop severs were down.
				//Instead, we now silently log a warning message into the Application log within the system EventViewer, so it is not annoying, but there is a way for the user to know if there was a problem.
				if(!EventLog.SourceExists("OpenDental")) {
					EventLog.CreateEventSource("OpenDental","Application");
				}
				EventLog.WriteEntry("OpenDental","Failed to communicate with NewCrop to retrieve completed prescription information. "
					+"A firewall or antivirus application might be blocking Open Dental, or this computer might not be able to see secure.newcropaccounts.com due to a network name resolution (DNS) issue. "
					+"If you do not use electronic prescriptions, consider disabling the NewCrop program link in Setup | Program Links.",EventLogEntryType.Warning);
				return false;
			}
			//response.Message = Error message if error.
			//response.RowCount = Number of prescription records returned.
			//response.Status = Status of request. "OK" = success.
			//response.Timing = Not sure what this is for. Tells us how quickly the server responded to the request?
			//response.XmlResponse = The XML data returned, encoded in base 64.
			if(response.Status!=NewCrop.StatusType.OK) {//Other statuses include Fail (ex if credentials are invalid), NotFound (ex if patientId invalid or accoundId invalid), Unknown (no known examples yet)
				//For now we simply abort gracefully.
				return false;
			}
			byte[] xmlResponseBytes=Convert.FromBase64String(response.XmlResponse);
			string xmlResponse=Encoding.UTF8.GetString(xmlResponseBytes);
#if DEBUG//For capturing the xmlReponse with the newlines properly showing.
			string tempFile=ODFileUtils.CreateRandomFile(Path.GetTempPath(),".txt");
			File.WriteAllText(tempFile,xmlResponse);
#endif
			XmlDocument xml=new XmlDocument();
			try {
				xml.LoadXml(xmlResponse);
			}
			catch { //In case NewCrop returns invalid XML.
				return false;//abort gracefully
			}
			DateTime rxStartDateT=PrefC.GetDateT(PrefName.ElectronicRxDateStartedUsing131);
			XmlNode nodeNewDataSet=xml.FirstChild;
			foreach(XmlNode nodeTable in nodeNewDataSet.ChildNodes) {
				RxPat rxOld=null;
				MedicationPat medOrderOld=null;
				RxPat rx=new RxPat();
				//rx.IsControlled not important.  Only used in sending, but this Rx was already sent.
				rx.Disp="";
				rx.DosageCode="";
				rx.Drug="";
				rx.Notes="";
				rx.Refills="";
				rx.SendStatus=RxSendStatus.SentElect;
				rx.Sig="";
				string additionalSig="";
				bool isProv=true;
				long rxCui=0;
				string strDrugName="";
				string strGenericName="";
				string strProvNumOrNpi="";//We used to send ProvNum in LicensedPrescriber.ID to NewCrop, but now we send NPI. We will receive ProvNum for older prescriptions.
				foreach(XmlNode nodeRxFieldParent in nodeTable.ChildNodes) {
					XmlNode nodeRxField=nodeRxFieldParent.FirstChild;
					if(nodeRxField==null) {
						continue;
					}
					switch(nodeRxFieldParent.Name.ToLower()) {
						case "dispense"://ex 5.555
							rx.Disp=nodeRxField.Value;
							break;
						case "druginfo"://ex lisinopril 5 mg Tab
							rx.Drug=nodeRxField.Value;
							break;
						case "drugname"://ex lisinopril
							strDrugName=nodeRxField.Value;
							break;
						case "externalpatientid"://patnum passed back from the compose request that initiated this prescription
							rx.PatNum=PIn.Long(nodeRxField.Value);
							break;
						case "externalphysicianid"://NPI passed back from the compose request that initiated this prescription.  For older prescriptions, this will be ProvNum.
							strProvNumOrNpi=nodeRxField.Value;
							break;
						case "externaluserid"://The person who ordered the prescription. Is a ProvNum when provider, or an EmployeeNum when an employee. If EmployeeNum, then is prepended with "emp" because of how we sent it to NewCrop in the first place.
							if(nodeRxField.Value.StartsWith("emp")) {
								isProv=false;
							}
							break;
						case "genericname":
							strGenericName=nodeRxField.Value;
							break;
						case "patientfriendlysig"://The concat of all the codified fields.
							rx.Sig=nodeRxField.Value;
							break;
						case "pharmacyncpdp"://ex 9998888
							//We will use this information in the future to find a pharmacy already entered into OD, or to create one dynamically if it does not exist.
							//rx.PharmacyNum;//Get the pharmacy where pharmacy.PharmID = node.Value
							break;
						case "prescriptiondate":
							rx.RxDate=PIn.DateT(nodeRxField.Value);
							break;
						case "prescriptionguid"://32 characters with 4 hyphens. ex ba4d4a84-af0a-4cbf-9437-36feda97d1b6
							rx.NewCropGuid=nodeRxField.Value;
							rxOld=RxPats.GetRxNewCrop(nodeRxField.Value);
							medOrderOld=MedicationPats.GetMedicationOrderByNewCropGuid(nodeRxField.Value);
							break;
						case "prescriptionnotes"://from the Additional Sig box at the bottom
							additionalSig=nodeRxField.Value;
							break;
						case "refills"://ex 1
							rx.Refills=nodeRxField.Value;
							break;
						case "rxcui"://ex 311354
							rxCui=PIn.Long(nodeRxField.Value);//The RxCui is not returned with all prescriptions, so it can be zero (not set).
							break;						
					}
				}//end inner foreach
				if(rx.RxDate<rxStartDateT) {//Ignore prescriptions created before version 13.1.14, because those prescriptions were entered manually by the user.
					continue;
				}
				if(additionalSig!="") {
					if(rx.Sig!="") {//If patient friend SIG is present.
						rx.Sig+=" ";
					}
					rx.Sig+=additionalSig;
				}
				//Determine the provider. This is a mess, because we used to send ProvNum in the outgoing XML LicensedPrescriber.ID,
				//but now we send NPI to avoid multiple billing charges for two provider records with the same NPI
				//(the same doctor entered multiple times, for example, one provider for each clinic).
				ErxLog erxLog=ErxLogs.GetLatestForPat(rx.PatNum,rx.RxDate);//Locate the original request corresponding to this prescription.
				if((erxLog==null || erxLog.ProvNum==0)) {//Not found or the provnum is unknown.
					//The erxLog.ProvNum will be 0 for prescriptions fetched from NewCrop before version 13.3. Could also happen if
					//prescriptions were created when NewCrop was brand new (right before ErxLog was created),
					//or if someone lost a database and they are downloading all the prescriptions from scratch again.
					if(rxOld==null) {//The prescription is being dowloaded for the first time, or is being downloaded again after it was deleted manually by the user.
						for(int j=0;j<ProviderC.ListShort.Count;j++) {//Try to locate a visible provider matching the NPI on the prescription.
							if(strProvNumOrNpi.Length==10 && ProviderC.ListShort[j].NationalProvID==strProvNumOrNpi) {
								rx.ProvNum=ProviderC.ListShort[j].ProvNum;
								break;
							}
						}
						if(rx.ProvNum==0) {//No visible provider found matching the NPI on the prescription.
							for(int j=0;j<ProviderC.ListLong.Count;j++) {//Try finding a hidden provider matching the NPI on the prescription, or a matching provnum.
								if(strProvNumOrNpi.Length==10 && ProviderC.ListLong[j].NationalProvID==strProvNumOrNpi) {
									rx.ProvNum=ProviderC.ListLong[j].ProvNum;
									break;
								}
								if(ProviderC.ListLong[j].ProvNum.ToString()==strProvNumOrNpi) {
									rx.ProvNum=ProviderC.ListLong[j].ProvNum;
									break;
								}
							}
						}
						//If rx.ProvNum is still zero, then that means the provider NPI/ProvNum has been modified or somehow deleted (for example, database was lost) for the provider record originally used.
						if(rx.ProvNum==0) {//Catch all
							if(PatCur.PriProv!=0) {
								rx.ProvNum=PatCur.PriProv;
							}
							else {
								rx.ProvNum=PrefC.GetLong(PrefName.PracticeDefaultProv);
							}
						}
					}
					else {//The prescription has already been downloaded in the past.
						rx.ProvNum=rxOld.ProvNum;//Preserve the provnum if already in the database, because it may have already been corrected by the user after the previous download.
					}
				}
				else {
					rx.ProvNum=erxLog.ProvNum;
				}
				if(rxOld==null) {
					rx.IsNew=true;//Might not be necessary, but does not hurt.
					RxPats.Insert(rx);
				}
				else {//The prescription was already in our database. Update it.
					rx.RxNum=rxOld.RxNum;
					RxPats.Update(rx);
				}
				//If rxCui==0, then NewCrop did not provide an RxCui.  Attempt to locate an RxCui using the other provided drug information.  An RxCui is not required for our program.  Meds missing an RxCui are not exported in CCD messages.
				if(rxCui==0 && strDrugName!="") {
					List<RxNorm> listRxNorms=RxNorms.GetListByCodeOrDesc(strDrugName,true,true);//Exact case insensitive match ignoring numbers.
					if(listRxNorms.Count>0) {
						rxCui=PIn.Long(listRxNorms[0].RxCui);
					}					
				}
				//If rxCui==0, then NewCrop did not provide an RxCui and we could not locate an RxCui by DrugName.  Try searching by GenericName.
				if(rxCui==0 && strGenericName!="") {
					List<RxNorm> listRxNorms=RxNorms.GetListByCodeOrDesc(strGenericName,true,true);//Exact case insensitive match ignoring numbers.
					if(listRxNorms.Count>0) {
						rxCui=PIn.Long(listRxNorms[0].RxCui);
					}
				}
				//If rxCui==0, then NewCrop did not provide an RxCui and we could not locate an RxCui by DrugName or GenericName.
				if(rxCui==0) {
					//We may need to enhance in future to support more advanced RxNorm searches.
					//For example: DrugName=Cafatine, DrugInfo=Cafatine 1 mg-100 mg Tab, GenericName=ergotamine-caffeine.
					//This drug could not be found by DrugName nor GenericName, but could be found when the GenericName was split by non-alpha characters, then the words in the generic name were swapped.
					//Namely, "caffeine ergotamine" is in the RxNorm table.
				}
				MedicationPats.InsertOrUpdateMedOrderForRx(rx,rxCui,isProv);//MedicationNum of 0, because we do not want to bloat the medication list in OD. In this special situation, we instead set the MedDescript, RxCui and NewCropGuid columns.
			}//end foreach
			return true;
		}
Ejemplo n.º 30
0
 /// <remarks/>
 public void GetSideEffectsAsync(Credentials credentials, AccountRequest accountRequest, PatientRequest patientRequest, PatientInformationRequester patientInformationRequester, string drugConcept, string drugStandardType, string diseaseDescriptionType, string includeSchema, string sortOrder, object userState) {
     if ((this.GetSideEffectsOperationCompleted == null)) {
         this.GetSideEffectsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSideEffectsOperationCompleted);
     }
     this.InvokeAsync("GetSideEffects", new object[] {
                 credentials,
                 accountRequest,
                 patientRequest,
                 patientInformationRequester,
                 drugConcept,
                 drugStandardType,
                 diseaseDescriptionType,
                 includeSchema,
                 sortOrder}, this.GetSideEffectsOperationCompleted, userState);
 }